From a82885f7c3b9507e8bca6bab061797ed3fe51e15 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Aug 2026 17:29:21 +0000 Subject: [PATCH 1/3] Initial plan From 0406dc3f31bed4584bc01d044f79a1bbf9dff9fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Aug 2026 17:38:30 +0000 Subject: [PATCH 2/3] Fix missing aten.mul.Scalar registration and add regression test Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com> --- onnxscript/function_libs/torch_lib/ops/core.py | 8 ++++++++ tests/function_libs/torch_lib/e2e_ops_tests.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/onnxscript/function_libs/torch_lib/ops/core.py b/onnxscript/function_libs/torch_lib/ops/core.py index bae2e2cfb7..77163d65e8 100644 --- a/onnxscript/function_libs/torch_lib/ops/core.py +++ b/onnxscript/function_libs/torch_lib/ops/core.py @@ -6832,6 +6832,14 @@ def aten_mul_complex(self: TReal, other: TReal) -> TReal: return op.Concat(real, imag, axis=-1) +@torch_op(("aten::mul.Scalar", "aten::multiply.Scalar"), trace_only=True) +def aten_mul_scalar(self: TTensor, other: float) -> TTensor: + """mul.Scalar(Tensor self, Scalar other) -> Tensor""" + + other = op.Constant(value=ir.tensor(other, dtype=self.dtype)) + return aten_mul(self, other) + + @torch_op("aten::multinomial", trace_only=True) def aten_multinomial( self: TFloat, diff --git a/tests/function_libs/torch_lib/e2e_ops_tests.py b/tests/function_libs/torch_lib/e2e_ops_tests.py index 1bea819f11..7028523bfd 100644 --- a/tests/function_libs/torch_lib/e2e_ops_tests.py +++ b/tests/function_libs/torch_lib/e2e_ops_tests.py @@ -84,6 +84,16 @@ def forward(self, x: torch.Tensor) -> torch.Tensor: ) _testing.assert_onnx_program(onnx_program) + def test_mul_tensor_scalar_float(self): + class Model(torch.nn.Module): + def forward(self, x: torch.Tensor) -> torch.Tensor: + return x.to(torch.float32) * 1.0 + + onnx_program = torch.onnx.export( + Model(), (torch.tensor([1, 2, 3], dtype=torch.float16),), dynamo=True, optimize=False + ) + _testing.assert_onnx_program(onnx_program) + def test_bincount(self): class Model(torch.nn.Module): def forward(self, x: torch.Tensor) -> torch.Tensor: From d6479b96fcd392ab8796481bb3f4165c0defbcb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 22 Aug 2026 00:36:27 +0000 Subject: [PATCH 3/3] Fix lint formatting in scalar-multiply regression test Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com> --- tests/function_libs/torch_lib/e2e_ops_tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/function_libs/torch_lib/e2e_ops_tests.py b/tests/function_libs/torch_lib/e2e_ops_tests.py index 7028523bfd..8146510cc4 100644 --- a/tests/function_libs/torch_lib/e2e_ops_tests.py +++ b/tests/function_libs/torch_lib/e2e_ops_tests.py @@ -90,7 +90,10 @@ def forward(self, x: torch.Tensor) -> torch.Tensor: return x.to(torch.float32) * 1.0 onnx_program = torch.onnx.export( - Model(), (torch.tensor([1, 2, 3], dtype=torch.float16),), dynamo=True, optimize=False + Model(), + (torch.tensor([1, 2, 3], dtype=torch.float16),), + dynamo=True, + optimize=False, ) _testing.assert_onnx_program(onnx_program)