kparzysz-quic commented on code in PR #15057:
URL: https://github.com/apache/tvm/pull/15057#discussion_r1224314593


##########
python/tvm/topi/hexagon/utils.py:
##########
@@ -24,10 +24,30 @@
 from typing import Dict, Tuple, Union
 
 import tvm
-from tvm import IRModule, te
+from tvm import IRModule, te, tir
 from tvm.tir import IndexMap, PrimFunc
 
 
+def is_scalar(expr):
+    if isinstance(expr, te.Tensor):
+        return expr.ndim == 0 and (isinstance(expr.op.body[0], (tir.FloatImm, 
tir.IntImm)))
+    return isinstance(expr, (tir.FloatImm, tir.IntImm))
+
+
+def get_const_int_value(expr):
+    if isinstance(expr, te.Tensor):
+        assert isinstance(expr.op.body[0], tir.IntImm)
+        return expr.op.body[0].value
+    return get_const_int(expr)
+
+
+def get_const_float_value(expr):
+    if isinstance(expr, te.Tensor):
+        assert isinstance(expr.op.body[0], tir.FloatImm)
+        return expr.op.body[0].value
+    return get_const_float(expr)
+
+

Review Comment:
   Sure, I can deduplicate the code.  I can't add Relax features here though as 
Relax is not in the main branch.



-- 
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]

Reply via email to