pytorch
1aabb8f9 - [ONNX] handle aten::_set_item on Dict in convertInplaceOpsAndTrackAlias (#58317) (#58696)

Commit
3 years ago
[ONNX] handle aten::_set_item on Dict in convertInplaceOpsAndTrackAlias (#58317) (#58696) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58696 It seems the JIT produces an output for aten::_set_item on lists but not on dicts. Previously the code would crash because it assumed it was operating on a list. The different behavior can be seen with the following test: ```python class DictModule(torch.nn.Module): def forward(self, x_in: torch.Tensor) -> typing.Dict[str, torch.Tensor]: x_out = {} x_out["test_key_out"] = x_in return x_out x_in = torch.tensor(1) dms = torch.jit.script(DictModule()) torch.onnx.export(dms, (x_in,), "/dev/null", example_outputs=(dms(x_in),)) ``` Before this change: `RuntimeError: outputs_.size() == 1INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/ir.h":452, please report a bug to PyTorch.` After this change: `RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 9 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.` This is a more useful error message. Test Plan: Imported from OSS Reviewed By: driazati Differential Revision: D28714804 Pulled By: SplitInfinity fbshipit-source-id: 1e5dc5fb44d1e3f971a22a79b5cf009d7590bf84 Co-authored-by: Gary Miguel <garymiguel@microsoft.com>
Author
Parents
Loading