Hi, there~ I encounter a problem when using TVMScript about literal True value. Take an small example:
@T.prim_func
def func(x: T.int32):
if True and x > 2:
T.evaluate(T.broadcast(True, 16))
T.evaluate(T.shift_left(True, x))
T.evaluate(T.call_extern("", "extern_func", True, 16))
Surprisingly, the behaviour diverges:
In condition, the “True” evaluates to IntImm("uint1", 1)
In broadcast and call, the “True” evaluates to IntImm("int32", 1)
In call extern, the “True” again evaluates to IntImm("uint1", 1)
cc @junrushao @yelite for help:)
In fact, I have the same question…@tqchen would you like to clarify what the default dtype is for boolean?
tqchen
January 10, 2023, 4:22am
3
I think it should be uint1
oh, I have tried raw python interface with
>> tvm.tir.Broadcast(True, 16)
And I get 1 with i32 type. It seems that is because the FFI? And the parser is actually consistent with that behavior? @junrushao
TVM’s FFI does not recognize python boolean independently, which means they are handled the same way as integer 1. I was wondering if it’s the behavior we should fix @tqchen
tqchen
January 10, 2023, 2:04pm
6
Yes, we have some opportunities to fix in https://github.com/apache/tvm-rfcs/pull/97