From 719e5c3983762c08f5b77d339e672e6ca92e0314 Mon Sep 17 00:00:00 2001 From: Kavin-mcw Date: Wed, 23 Apr 2025 11:55:01 +0530 Subject: [PATCH 1/2] Fix bug of mod op --- .../tvm/relax/frontend/torch/exported_program_translator.py | 4 ++-- python/tvm/relax/frontend/torch/fx_translator.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/tvm/relax/frontend/torch/exported_program_translator.py b/python/tvm/relax/frontend/torch/exported_program_translator.py index cdf0c46bb5ef..44036a45e763 100644 --- a/python/tvm/relax/frontend/torch/exported_program_translator.py +++ b/python/tvm/relax/frontend/torch/exported_program_translator.py @@ -352,8 +352,8 @@ def create_convert_map( "min.other": self._binary_op(relax.op.minimum, min), "max.default": self._unary_op(relax.op.max), "min.default": self._unary_op(relax.op.min), - "remainder.Tensor": self._binary_op(relax.op.mod, operator.mod), - "remainder.Scalar": self._binary_op(relax.op.mod, operator.mod), + "remainder.Tensor": self._binary_op(relax.op.floor_mod, operator.mod), + "remainder.Scalar": self._binary_op(relax.op.floor_mod, operator.mod), "mul.Tensor": self._binary_op(relax.op.multiply, operator.mul), "mul_.Tensor": self._binary_op(relax.op.multiply, operator.mul), "ne.Tensor": self._binary_op(relax.op.not_equal, operator.ne), diff --git a/python/tvm/relax/frontend/torch/fx_translator.py b/python/tvm/relax/frontend/torch/fx_translator.py index c3bf8f045410..4d81ff349258 100644 --- a/python/tvm/relax/frontend/torch/fx_translator.py +++ b/python/tvm/relax/frontend/torch/fx_translator.py @@ -742,7 +742,7 @@ def create_convert_map( ), "max": self._binary_op(relax.op.maximum, max), "min": self._binary_op(relax.op.minimum, min), - "mod": self._binary_op(relax.op.mod, operator.mod), + "mod": self._binary_op(relax.op.floor_mod, operator.mod), "mul": self._binary_op(relax.op.multiply, operator.mul), "ne": self._binary_op(relax.op.not_equal, operator.ne), "pow": self._binary_op(relax.op.power, operator.pow), From 4bcb8cec7d333efebeb0748c70c7f1ed212785ad Mon Sep 17 00:00:00 2001 From: Kavin-mcw Date: Thu, 24 Apr 2025 09:14:34 +0530 Subject: [PATCH 2/2] modify test case --- tests/python/relax/test_frontend_from_exported_program.py | 2 +- tests/python/relax/test_frontend_from_fx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/python/relax/test_frontend_from_exported_program.py b/tests/python/relax/test_frontend_from_exported_program.py index c6ead5aaccfb..e206f1f26baa 100644 --- a/tests/python/relax/test_frontend_from_exported_program.py +++ b/tests/python/relax/test_frontend_from_exported_program.py @@ -853,7 +853,7 @@ def main( (operator.truediv, R.divide), (operator.floordiv, R.floor_divide), (operator.pow, R.power), - (operator.mod, R.mod), + (operator.mod, R.floor_mod), (operator.and_, R.bitwise_and), (operator.or_, R.bitwise_or), (operator.xor, R.bitwise_xor), diff --git a/tests/python/relax/test_frontend_from_fx.py b/tests/python/relax/test_frontend_from_fx.py index f21cde6df23c..312ec745ca30 100644 --- a/tests/python/relax/test_frontend_from_fx.py +++ b/tests/python/relax/test_frontend_from_fx.py @@ -1654,7 +1654,7 @@ def main( (operator.truediv, R.divide), (operator.floordiv, R.floor_divide), (operator.pow, R.power), - (operator.mod, R.mod), + (operator.mod, R.floor_mod), ]