Skip to content

Commit

Permalink
Add Op (Slice - complex) | feat torchlib (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
titaiwangms authored Mar 7, 2025
1 parent 4c1cda2 commit 68d4b9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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 @@ def aten_sinh(self: TFloat) -> TFloat:
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
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

0 comments on commit 68d4b9f

Please sign in to comment.