Hi all,
I register an operator named “nn.my_op”, its FTVMCompute attribute calls hybrid script compute_my_op function which is annotated by tvm.hybrid.script
@tvm.hybrid.script
def compute_my_op(x, y):
# x, y both Tensor type
res = …
return res
RELAY_REGISTER_OP(“nn.my_op”)
.set_num_inputs(2)
.add_argument(“data1”, “Tensor”, “The input tensor.”)
.add_argument(“data2”, “Tensor”, “The input tensor.”)
.set_support_level(2)
.add_type_rel(" ", MyOpRel)
.set_attr(“FTVMCompute”, MyOpCompute);
when I create a nn.myop function node and execute it by relay interpreter, and when fed with the same input parameters, it output different matrix results which are sometimes correct, and sometimes wrong; moverover, some of the wrong results contain values of “nan” or “inf”
x = relay.var(‘x’, shape=(10, 10))
y = relay.var(‘y’, shape=(10, 10))
func = relay.Function([x, y], relay.nn.my_op(x, y))
intrp = create_executor(mod=mod, ctx=ctx, target=target)
for i in range(10):
result = intrp.evaluate(expr)(*args)
print(result, ‘\n’) ## output different result !!!
while i refer to test_hybrid_script.py and write test case with the following way, it works correctly
zz = compute_my_op(x, y)
s = tvm.create_schedule(C.op)
f = tvm.build(s, [x, y, zz], “llvm”)a = tvm.ones((10, 10)).astype(‘float32’), ctx)
b = tvm.ones((10, 10)).astype(‘float32’), ctx)
c = tvm.nd.array(np.zeros((10, 10), dtype=a.dtype), ctx)
f(a, b, c) # The results c of each execution are the same
Does this mean relay interpreter can’t execute Op function whose computing calls hybrid script funciton?
or it is caused by something i did wrong, any idea how to solve this issue?
@were I found that the [hybrid script] module is developed by you, could you give me some tips? thank you!