forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support exporting aten::copy_ and aten::index_put to ONNX opset 11 (p…
…ytorch#26941) Summary: - [x] Add more comments and refactor the logic of `ReshapeToAdvancedIndexingFormat` - [x] Add more description here. Cases that are/aren't supported, and how they are supported. - [x] Need to merge this PR pytorch#27186 to enable testing inplace operators. We are now supporting exporting aten::copy_ and aten::index_put to ONNX. Here's a breakdown of the different cases in PyTorch code. ``` # Case 1: Scalar Indices x[0, 1, 2] = data # Case 2: Slice Indices x[1:3, :, ::2] = data # Case 3: Ellipsis Indices x[..., 0] = data # Case 4: Tensor Indices ind1 = torch.tensor([0, 2]) ind2 = torch.tensor([1, 1]) x[ind1, ind2] = data # Case 5: Mixing all the above cases ind1 = torch.tensor([0, 2]) ind2 = torch.tensor([1, 1]) x[1:3, ind1, ind2, ..., 3] = data ``` Limitations: Tensor indices must be consecutive, and 1-d tensors. ``` # Supported ind1 = torch.tensor([0, 2]) ind2 = torch.tensor([1, 1]) x[ind1, ind2] = data # Not supported ind1 = torch.tensor([0, 2]) ind2 = torch.tensor([1, 1]) ind3 = torch.tensor([[0], [1]]) x[ind1, :, ind2] = data x[ind3] = data ``` Negative indices are not supported. ``` # Not supported x[-1] = data ``` Pull Request resolved: pytorch#26941 Differential Revision: D17951030 Pulled By: houseroad fbshipit-source-id: 4357777072f53aa0bc4b297aa1ee53457a7f8dec
- Loading branch information
Showing
9 changed files
with
569 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.