Skip to content

Add Op (Slice - complex) | feat torchlib #2089

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
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
15 changes: 15 additions & 0 deletions onnxscript/function_libs/torch_lib/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7698,6 +7698,21 @@
return op.Sinh(self)


@torch_op(("aten::slice.Tensor"), trace_only=True, complex=True)
def aten_slice_complex(
self: TTensor,
dim: int = 0,
start: Optional[INT64] = None,
end: Optional[INT64] = None,
step: Optional[INT64] = None,
) -> TTensor:
"""slice.Tensor(Tensor(a) self, int dim=0, SymInt? start=None, SymInt? end=None, SymInt step=1) -> Tensor(a)"""
if dim < 0:
# Account for the complex dimension in ONNX
dim = dim - 1

Check warning on line 7712 in onnxscript/function_libs/torch_lib/ops/core.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/function_libs/torch_lib/ops/core.py#L7712

Added line #L7712 was not covered by tests
return aten_slice(self, dim, start, end, step)


@torch_op(("aten::slice.Tensor"), trace_only=True)
def aten_slice(
self: TTensor,
Expand Down
1 change: 1 addition & 0 deletions tests/function_libs/torch_lib/ops_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ def _where_input_wrangler(
),
TorchLibOpInfo("ops.aten.slice_scatter", core_ops.aten_slice_scatter),
TorchLibOpInfo("slice", core_ops.aten_slice),
TorchLibOpInfo("slice", core_ops.aten_slice_complex, complex=True),
TorchLibOpInfo(
"sum",
core_ops.aten_sum_dim_IntList,
Expand Down
Loading