Skip to content

Conversation

@smessmer
Copy link
Contributor

@smessmer smessmer commented Mar 3, 2021

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

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 3, 2021

💊 CI failures summary and remediations

As 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.

@smessmer smessmer added the module: bc-breaking Related to a BC-breaking change label Mar 3, 2021
@smessmer smessmer requested review from bhosmer and ezyang March 3, 2021 23:48
@ezyang
Copy link
Contributor

ezyang commented Mar 4, 2021

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.

@ezyang ezyang requested a review from bdhirsh March 5, 2021 19:59
…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]
Copy link

@bhosmer bhosmer left a 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?

@ezyang
Copy link
Contributor

ezyang commented Mar 9, 2021

@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]
smessmer added 4 commits March 9, 2021 15:40
…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]
@smessmer smessmer requested review from bhosmer and ezyang March 18, 2021 17:10
@smessmer
Copy link
Contributor Author

tests are fixed. @ezyang @bhosmer PTAL

…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]
@smessmer
Copy link
Contributor Author

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.");
Copy link
Contributor

Choose a reason for hiding this comment

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

INTERNAL_ASSERT me

Copy link
Contributor Author

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]
smessmer added 4 commits April 5, 2021 17:14
…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]
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in db75eba.

peterbell10 added a commit that referenced this pull request Apr 8, 2021
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]
peterbell10 added a commit that referenced this pull request Apr 8, 2021
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]
facebook-github-bot pushed a commit that referenced this pull request Apr 9, 2021
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
@facebook-github-bot facebook-github-bot deleted the gh/smessmer/299/head branch April 10, 2021 14:17
krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: bc-breaking Related to a BC-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants