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

Saving an attribute #53

Open
fabiozappo opened this issue Oct 13, 2023 · 2 comments
Open

Saving an attribute #53

fabiozappo opened this issue Oct 13, 2023 · 2 comments

Comments

@fabiozappo
Copy link

Hi, I am exporting a model using torch neuron but I can't find any reference to save a custom attribute in the model.

For instance I would like to save the dimension of input image as an integer so to be able to get again this value doing something like:

model = torch.jit.load('"/path/to/my/model.pt")
image_size = model.image_size
@jyang-aws
Copy link
Contributor

@fabiozappo as mentioned in torch.jit.load, the pb needs to have saved modules (for a model). a separate tensor is not part of a module.
You can get the image_size by either query from the model, say model.layer.weight[0] if it can be inferred from the model. or use something similar to torch.save, which can store dictionary dtype: https://pytorch.org/tutorials/beginner/saving_loading_models.html#save

@jyang-aws jyang-aws reopened this Nov 22, 2023
@fayyadd
Copy link

fayyadd commented Nov 21, 2024

Closing the issue as workarounds above are provided, and this issue has been inactive since 11/2023. Please reach out if there are any further questions or issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants