This is an automated email from the ASF dual-hosted git repository.
tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 9752557bf1 support integer types in fast_tanh and fast_exp (#18768)
9752557bf1 is described below
commit 9752557bf1d0647f65c52b8087d35613f5324a94
Author: Qingchao Shen <[email protected]>
AuthorDate: Sat Feb 21 00:52:11 2026 +0800
support integer types in fast_tanh and fast_exp (#18768)
Fix https://github.com/apache/tvm/issues/18767.
This PR fixes the issue by adding explicit type casting in `fast_tanh`
and `fast_exp` to convert integer inputs to float32.
---
python/tvm/topi/math.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/python/tvm/topi/math.py b/python/tvm/topi/math.py
index c47c3ca9e6..b53140e926 100644
--- a/python/tvm/topi/math.py
+++ b/python/tvm/topi/math.py
@@ -783,6 +783,8 @@ def fast_exp(x):
y : tvm.te.Tensor
The result.
"""
+ if x.dtype.startswith("int") or x.dtype.startswith("uint"):
+ x = cast(x, "float32")
return cpp.fast_exp(x, x.dtype, tag.ELEMWISE)
@@ -799,6 +801,8 @@ def fast_tanh(x):
y : tvm.te.Tensor
The result.
"""
+ if x.dtype.startswith("int") or x.dtype.startswith("uint"):
+ x = cast(x, "float32")
return cpp.fast_tanh(x, x.dtype, tag.ELEMWISE)