-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address itPRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug
Description
import tvm
from tvm import relay
from tvm.contrib import graph_executor
import numpy as np
x=relay.var("x",shape=[2,2],dtype="int32")
t1=relay.cast(x,"bool")
y=relay.sum(t1)
f = relay.Function([x],relay.Tuple([t1,y]))
mod = tvm.IRModule({"main":f})
target = "llvm"
with tvm.transform.PassContext(opt_level=3 ):
lib = relay.build(mod, target=target)
m = graph_executor.GraphModule(lib['default'](tvm.cpu()))
x = np.ones((2,2)).astype("int32")
m.set_input("x",x)
print(m.get_output(0))
print(m.get_output(1))The code snippets above should be equivalent to below:
x = np.ones((2,2)).astype("int32").astype(bool)
print(x)
print(np.sum(x,dtype=bool))Expected behavior
The relay program should always produce t1 all true and y true just like the numpy-based code outputs below. In common sense, it is expected to view non-zero elements as True and sum should perform reduction by OR operation for bool data type.
[[ True True]
[ True True]]
TrueActual behavior
However, the relay-based code produce rather random results.
[[ True False]
[False False]]
TrueOr
[[False False]
[False False]]
FalseEven
[[False False]
[False False]]
TrueEnvironment
commit id: 1258863
OS: ubuntu 20.04 or macos
LLVM 14
Steps to reproduce
Run the code snippets above.
Metadata
Metadata
Assignees
Labels
needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address itPRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug