Skip to content

Commit bb75e2b

Browse files
authored
Support math trunc (#2653)
Fix pytorch/pytorch#166110
1 parent 8c0b72b commit bb75e2b

File tree

1 file changed

+8
-0
lines changed
  • onnxscript/function_libs/torch_lib/ops

1 file changed

+8
-0
lines changed

onnxscript/function_libs/torch_lib/ops/core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8533,6 +8533,14 @@ def aten_trunc(self: TFloat) -> TFloat:
85338533
return op.Floor(op.Abs(self)) * op.Sign(self)
85348534

85358535

8536+
@torch_op("math::trunc", trace_only=True)
8537+
def python_math_trunc(self: TFloat) -> TInt:
8538+
"""trunc(Tensor self) -> Tensor"""
8539+
# NOTE: This is used in SymInt/SymBool/SymFloat context, so
8540+
# we don't expect overflow to happen here.
8541+
return op.Cast(self, to=INT64.dtype)
8542+
8543+
85368544
@torch_op("aten::type_as", trace_only=True)
85378545
def aten_type_as(self: TTensor, other: TTensor2) -> TTensor2:
85388546
"""type_as(Tensor self, Tensor other) -> Tensor"""

0 commit comments

Comments
 (0)