-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Don't allocate result Tensors in out overloads: Reduction Ops #53218
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
Conversation
💊 CI failures summary and remediationsAs of commit 6a2c8a3 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
|
It looks like the duplicated logic doesn't perfectly reflect the original. If you want I can give you an accept (because I'm generally pro this PR) but it seems like there need to be substantive changes. |
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
bhosmer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezyang not sure I understand your comment re doesn't perfectly reflect, can you elaborate?
Well, this PR is failing tests. So definitionally, something wrong has happened. |
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
|
nvm, rebasing broke them again |
| ScalarType dtype) | ||
| { | ||
| auto shape = shape_from_dim_mask(self, mask, keepdim); | ||
| TORCH_CHECK(result.defined(), "Cannot create a new tensor inside a reduction op. You likely tried to call an operator with an out argument but the out argument was an undefined tensor."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INTERNAL_ASSERT me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be triggered by user code without a bug in PyTorch when they call an out overload from the C++ API with an undefined tensor. So this should stay a TORCH_CHECK.
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
…Ops" We have some operators that previously allowed you to pass in an undefined tensor to the out argument, and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going through IValue. This PR removes that behavior and forces out arguments to be defined tensors. It only looks at reduction ops for now, there's likely more PRs coming for other ops. BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore. Differential Revision: [D26795461](https://our.internmc.facebook.com/intern/diff/D26795461/) [ghstack-poisoned]
|
This pull request has been merged in db75eba. |
Mean is broken for complex types, since #53218 it's now allocating the result as a real tensor which discards the imaginary component. This wasn't picked up in testing because `_test_dim_ops` tests are defined as closures inside of `_test_dim_ops` instead of as methods on the test class. The result is, they never get run. For best results, view diff with "Hide whitespace changes". [ghstack-poisoned]
Mean is broken for complex types, since #53218 it's now allocating the result as a real tensor which discards the imaginary component. This wasn't picked up in testing because `_test_dim_ops` tests are defined as closures inside of `_test_dim_ops` instead of as methods on the test class. The result is, they never get run. For best results, view diff with "Hide whitespace changes". [ghstack-poisoned]
Summary: Pull Request resolved: #55640 Mean is broken for complex types, since #53218 it's now allocating the result as a real tensor which discards the imaginary component. This wasn't picked up in testing because `_test_dim_ops` tests are defined as closures inside of `_test_dim_ops` instead of as methods on the test class. The result is, they never get run. For best results, view diff with "Hide whitespace changes". Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D27671127 Pulled By: mruberry fbshipit-source-id: 4a1f6fea1048919fda7339c867ee78e88f2d7bd2
Summary: Pull Request resolved: pytorch#55640 Mean is broken for complex types, since pytorch#53218 it's now allocating the result as a real tensor which discards the imaginary component. This wasn't picked up in testing because `_test_dim_ops` tests are defined as closures inside of `_test_dim_ops` instead of as methods on the test class. The result is, they never get run. For best results, view diff with "Hide whitespace changes". Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D27671127 Pulled By: mruberry fbshipit-source-id: 4a1f6fea1048919fda7339c867ee78e88f2d7bd2
Stack from ghstack:
We have some operators that previously allowed you to pass in an undefined tensor to the out argument,
and then would go on to allocate that for you. This behavior is broken and doesn't work in JIT when things
are converted to/from IValues. Because of this, it blocks backend fallbacks because they force going
through IValue.
This PR removes that behavior and forces out arguments to be defined tensors.
It only looks at reduction ops for now, there's likely more PRs coming for other ops.
BC Breaking: This breaks BC of the C++ frontend API since those ops previously allowed calling with undefined tensors and that isn't allowed anymore.
Differential Revision: D26795461