Skip to content

Add support for _unsafe_index_put #1314

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

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions onnxscript/function_libs/torch_lib/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4076,6 +4076,8 @@ def aten_index_put(
return result




@torch_op("aten::index_put")
def aten_index_put_bool(
self: TReal,
Expand Down
8 changes: 8 additions & 0 deletions onnxscript/tests/function_libs/torch_lib/ops_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,14 @@ def _where_input_wrangler(
matcher=lambda sample: not (sample.args[0][0].dtype == torch.int64),
reason="this Aten overload only supports tensor(int) as indices",
)
TorchLibOpInfo(

Check failure

Code scanning / CodeQL

Syntax error

Syntax Error (in Python 3).
"_unsafe_index_put",
Copy link
Collaborator

@justinchuby justinchuby Mar 25, 2024

Choose a reason for hiding this comment

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

Since it looks like it is the same as index_put, we can actually make it the same function.

If for any reason we believe they could behave differently or if we want to safeguard the implementation, I would create test cases in extra_opinfo.py to run it against torch.ops.aten._unsafe_index_put (Looks like _unsafe_index_put does not exist in https://github.com/pytorch/pytorch/blob/main/torch/testing/_internal/common_methods_invocations.py so we may need to create our own test cases)

core_ops.aten__unsafe_index_put,
)
.skip(
matcher=lambda sample: not (sample.args[0][0].dtype == torch.int64),
reason="this Aten overload only supports tensor(int) as indices",
)
.xfail(
enabled_if=version_utils.onnxruntime_older_than("1.18"),
dtypes=(torch.float16,),
Expand Down