Skip to content

Add op(select_scatter) | feat(torchlib) #901

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

Merged
merged 5 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion onnxscript/function_libs/torch_lib/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5827,10 +5827,16 @@ def aten_select_backward(
raise NotImplementedError()


@torch_op("aten::select_scatter")
def aten_select_scatter(self: TensorType, src: TensorType, dim: int, index: int) -> TensorType:
"""select_scatter(Tensor self, Tensor src, int dim, int index) -> Tensor"""

raise NotImplementedError()
# Change src rank to self rank according to dim
# e.g. if self is [2,3,4], src is [2,4], dim=1, then update is [2,1,4]
update = op.Unsqueeze(src, axes=dim)
# Change index rank to the same as 'update' [2,1,4]
indices = op.Expand(index, op.Shape(update))
return op.ScatterElements(self, indices, update, axis=dim, reduction="none")


@torch_op("aten::selu")
Expand Down
1 change: 1 addition & 0 deletions onnxscript/tests/function_libs/torch_lib/ops_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ def _where_input_wrangler(
reason="fixme: ORT failed",
),
TorchLibOpInfo("select", core_ops.aten_select),
TorchLibOpInfo("select_scatter", core_ops.aten_select_scatter),
TorchLibOpInfo("sigmoid", core_ops.aten_sigmoid),
TorchLibOpInfo("sign", core_ops.aten_sign),
TorchLibOpInfo("sin", core_ops.aten_sin),
Expand Down