hypercubestart commented on a change in pull request #5812:
URL: https://github.com/apache/incubator-tvm/pull/5812#discussion_r476001349



##########
File path: python/tvm/target/datatype.py
##########
@@ -135,8 +166,40 @@ def lower(op):
             dtype = "uint" + str(t.bits)
             if t.lanes > 1:
                 dtype += "x" + str(t.lanes)
-        if isinstance(op, (_Cast, _FloatImm)):
-            return tvm.tir.call_pure_extern(dtype, extern_func_name, op.value)
-        return tvm.tir.call_pure_extern(dtype, extern_func_name, op.a, op.b)
+        if isinstance(op, _Cast):
+            src_bits = bit_length(op.value.dtype)
+            return call_pure_extern(dtype, extern_func_map[(src_bits, 
t.bits)], op.value)
+        if isinstance(op, _FloatImm):
+            return call_pure_extern(dtype, extern_func_map[t.bits], op.value)
+        if isinstance(op, _Call):
+            return call_pure_extern(dtype, extern_func_map[t.bits], *op.args)
+        if isinstance(op, _BinaryOpExpr):
+            return call_pure_extern(dtype, extern_func_map[t.bits], op.a, op.b)

Review comment:
       @gussmith23 should we improve debugging message here?
   
   if the map does not contain the bit_width, this throws a KeyError on 
`extern_func_map[t.bits]`, which may be somewhat cryptic to the user




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to