tqchen commented on code in PR #20417:
URL: https://github.com/apache/tvm/pull/20417#discussion_r4077695313
##########
tests/python/relax/test_relax_operators.py:
##########
@@ -478,8 +481,81 @@ def multiple_calls(x: R.Tensor((2,), "float32")):
expected2 = 1.0 / (1.0 + np.exp(-np.maximum(y_data, 0.0)))
assert (result2.numpy() == expected2).all()
- clear_func = tvm.get_global_func("vm.builtin.clear_py_func_registry")
- clear_func()
+ unregister_func = tvm.get_global_func("vm.builtin.unregister_py_func")
+ unregister_func("torch_relu")
+ unregister_func("torch_sigmoid")
+
+
+def _make_py_module(*func_names):
+ """Build a BasePyModule that registers ``func_names``, without a device or
PyTorch.
+
+ ``__new__`` skips ``__init__``'s JIT compilation;
``_register_python_functions`` is the code
+ under test and only needs ``ir_mod.pyfuncs``.
+ """
+ from tvm.relax.base_py_module import BasePyModule
+
+ module = BasePyModule.__new__(BasePyModule)
+ module.ir_mod = SimpleNamespace(pyfuncs={name: lambda self, x: x for name
in func_names})
+ module._convert_tvm_to_pytorch = lambda arg: arg
Review Comment:
please minimize the testcases
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]