KEMBAR78
[jit] Better error when using a constant tensor by driazati · Pull Request #16724 · pytorch/pytorch · GitHub
Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Feb 4, 2019

Fixes #16284

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Feb 4, 2019
@driazati driazati force-pushed the const_ten_error branch 2 times, most recently from 0b8546d to 89bf8df Compare February 4, 2019 19:45
@apaszke
Copy link
Contributor

apaszke commented Feb 5, 2019

Interesting. So it's not allowed to have a tensor in __constants__?

@driazati
Copy link
Contributor Author

driazati commented Feb 5, 2019

Not at the moment:

_constant_types = (bool, float, int, str, type(None), types.FunctionType, torch.device, torch.layout, torch.dtype)

I'm guessing most use cases are covered just by registering a buffer, but I don't really see any reason why we couldn't also allow constant tensors

@suo
Copy link
Member

suo commented Feb 5, 2019

Allowing tensors in __constants__ is potentially confusing, since we don't have the concept of a "const ref" in the type system. So we can't really enforce that it would not be mutated, etc.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@apaszke
Copy link
Contributor

apaszke commented Feb 23, 2019

@suo how do we enforce this for e.g. int lists then?

@ezyang ezyang added the merged label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JIT] Improve error messaging for using a tensor attribute in ScriptModule

5 participants