-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[dynamo] support torch.dtype and torch.device in default class arguments #112332
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1848,7 +1848,7 @@ def __call__(self, tx, value) -> VariableTracker: | |||||||||||||
return SourcelessBuilder.wrap_constant_literal(value) | ||||||||||||||
elif is_builtin_callable(value): | ||||||||||||||
return BuiltinVariable(value) | ||||||||||||||
elif is_allowed(value): | ||||||||||||||
elif is_allowed(value) or isinstance(value, (torch.device, torch.dtype)): | ||||||||||||||
if is_user_defined_allowed(value): | ||||||||||||||
self.tx.output.has_user_defined_allowed_in_graph = True | ||||||||||||||
return TorchVariable(value) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think They are You need to change the definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing tests for torch.device show it as a TorchVariable pytorch/test/dynamo/test_misc.py Lines 7505 to 7507 in 85dedea
Is torch.device a TorchVariable but torch.dtype should be a constant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm that's weird, as variablebuilder seems to wrap it as a constantvariable. I guess both are technically fine, but changing is_literal can get rid of the special-casing here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pytorch/torch/_dynamo/variables/builder.py Line 302 in 919c9b7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
pytorch/torch/_dynamo/utils.py Lines 832 to 833 in bbd5b93
|
||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.