Add Dynamic Output Shape Tag For data-dependent ops, handle in FakeTensor#79170
Add Dynamic Output Shape Tag For data-dependent ops, handle in FakeTensor#79170eellison wants to merge 4 commits intogh/eellison/307/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful links
❌ 1 New Failures, 1 PendingAs of commit 90a4bc6 (more details on the Dr. CI page): Expand to see more
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages
|
… in FakeTensor" [ghstack-poisoned]
…e in FakeTensor" [ghstack-poisoned]
|
|
||
|
|
||
| # TODO: use tags when available | ||
| # operators whose output shape depends on input tensor data |
…e in FakeTensor" Adds a tag for operators which have an output whose shape depends on input Tensor data. This tag is tested through the fake_tensor tests. If an operator is not tagged appropriately, the fake tensor test will fallback to cpu to run the operator, and then output metadata will diverge. This helped me find `linalg_lstsq` among others. I included in the tags CompositeImplicitAutograd ops, although I'm not sure what the general policy is for these operators. One difficulty wrt/fake tensors was [aten::one_hot](https://codebrowser.bddppq.com/pytorch/pytorch/aten/src/ATen/native/Onehot.cpp.html#23). Because it is a `CompositeImplicitAutograd`, it won't be seen by `__torch_dispatch__`. It would be possible to handle this case either a) always throwing with `local_scalar_dense`, but this would add a huge amount of false negatives where we think operators have data-dependent output shapes but are actually not. b) Maybe I should also be defining `__torch_function__` for fake_tensor to error on specific composites. (this didn't work when I tried it, didn't get invoked, so maybe there's something I'm missing) Feel free to suggest a different name than `dynamic_output_shape`. [ghstack-poisoned]
|
@pytorchbot merge |
|
@pytorchbot successfully started a merge job. Check the current status here |
|
Hey @eellison. |
…sor (#79170) Summary: Pull Request resolved: #79170 Approved by: https://github.com/ezyang Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/13a8867c01dd1191f21139915a8c821fa120cf58 Reviewed By: osalpekar Differential Revision: D37059412 Pulled By: osalpekar fbshipit-source-id: ee660b8792a03f1984216810c87f4975e9eac08e
Stack from ghstack (oldest at bottom):
Adds a tag for operators which have an output whose shape depends on input Tensor data. This tag is tested through the fake_tensor tests. If an operator is not tagged appropriately, the fake tensor test will fallback to cpu to run the operator, and then output metadata will diverge. This helped me find
linalg_lstsqamong others.I included in the tags CompositeImplicitAutograd ops, although I'm not sure what the general policy is for these operators.
One difficulty wrt/fake tensors was aten::one_hot. Because it is a
CompositeImplicitAutograd, it won't be seen by__torch_dispatch__. It would be possible to handle this case eithera) always throwing with
local_scalar_dense, but this would add a huge amount of false negatives where we think operators have data-dependent output shapes but are actually not.b) Maybe I should also be defining
__torch_function__for fake_tensor to error on specific composites. (this didn't work when I tried it, didn't get invoked, so maybe there's something I'm missing)Feel free to suggest a different name than
dynamic_output_shape.