Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "load pytorch tensor" section into the burn book #2316

Open
med1844 opened this issue Sep 30, 2024 · 2 comments
Open

Add "load pytorch tensor" section into the burn book #2316

med1844 opened this issue Sep 30, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@med1844
Copy link
Contributor

med1844 commented Sep 30, 2024

Issue based on discussion #2315, @antimora

To my best knowledge, here's how to load a tensor:

  1. In python:
    Ensure you wrap the tensor with dict before save, e.g.

    torch.save({"some_key": tensor}, "path/to/tensor.pt")
  2. In rust:

    #[derive(Module, Debug)]
    struct FloatTensor<B: Backend, const D: usize> {
        some_key: Param<Tensor<B, D>>,
    }
    
    fn main() {
        type B = NdArray;
        let device = Default::default();
        let tensor: FloatTensorRecord<B, 3> =
            PyTorchFileRecorder::<FullPrecisionSettings>::new()
                .load("path/to/tensor.pt".into(), &device)
                .unwrap();
        let tensor = tensor.value.val();
    }
@laggui laggui added documentation Improvements or additions to documentation good first issue Good for newcomers labels Sep 30, 2024
@csking101
Copy link

Hi, could I take up this issue?

@antimora
Copy link
Collaborator

Hi, could I take up this issue?

Yes! Please go ahead. We would appreciate your contribution. Let me know if you need more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants