Hi, i write these code in relay:
x = relay.var("x", shape = (relay.Any(), 2), dtype = "float32")
n = relay.var("n", dtype = "int32")
mod = tvm.IRModule()
mod["main"] = relay.Function([x, n], relay.expand_dims(x, 0, n))
But i get error:
Traceback (most recent call last):
File "shape_func_test.py", line 29, in <module>
mod["main"] = relay.Function([x, n], relay.expand_dims(x, 0, n))
File "/opt/tvm/python/tvm/relay/op/transform.py", line 110, in expand_dims
return _make.expand_dims(data, axis, num_newaxis)
File "/opt/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (3) /opt/tvm/build/libtvm.so(TVMFuncCall+0x48) [0x7ff097a21368]
[bt] (2) /opt/tvm/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), void tvm::runtime::TypedPackedFunc<tvm::RelayExpr (tvm::RelayExpr, int, int)>::AssignTypedLambda<tvm::RelayExpr (*)(tvm::RelayExpr, int, int)>(tvm::RelayExpr (*)(tvm::RelayExpr, int, int))::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x150) [0x7ff097662570]
[bt] (1) /opt/tvm/build/libtvm.so(tvm::runtime::TVMPODValue_::operator int() const+0x23d) [0x7ff096e5ce4d]
[bt] (0) /opt/tvm/build/libtvm.so(+0x8863b0) [0x7ff096e563b0]
File "/opt/tvm/include/tvm/runtime/packed_func.h", line 384
TVMError: Check failed: type_code_ == kDLInt (8 vs. 0) : expected int but get Object
It seems n is not scalar, so how can i define a scalar var to run above code? Thank you very much!