Hello, I’m studying tvm and I would like to look how tvm compiles NNs on the simplest example. I’ve wrote a such one:
from tvm import relay
import tvm.relay.op
x = relay.expr.var('x', relay.scalar_type('int64'), dtype = 'int64')
one = relay.expr.const(1, dtype = 'int64')
add = relay.op.tensor.add(x, one)
body = relay.expr.Call(add, [x, one])
func = tvm.relay.expr.Function([x], body, relay.scalar_type('int64'))
json, mod, params = tvm.relay.build(body, 'llvm')
But method tvm.relay.build reports an error
Traceback (most recent call last): File “example.py”, line 10, in json, mod, params = tvm.relay.build(body, ‘llvm’) File “/workspace/python/tvm/relay/build_module.py”, line 262, in build func = optimize(func, target, params) File “/workspace/python/tvm/relay/build_module.py”, line 161, in optimize func = ir_pass.infer_type(func) File “/workspace/python/tvm/relay/ir_pass.py”, line 45, in infer_type return _ir_pass.infer_type(expr, mod) File “/workspace/python/tvm/_ffi/_ctypes/function.py”, line 185, in call ctypes.byref(ret_val), ctypes.byref(ret_tcode))) File “/workspace/python/tvm/_ffi/base.py”, line 71, in check_call raise TVMError(py_str(_LIB.TVMGetLastError())) tvm._ffi.base.TVMError: [14:28:41] /home/udav/projects/tvm/src/relay/ir/error.cc:112: Error(s) have occurred. We have annotated the program with them:
In
main
: fn () { free_var %x: int64 %0 = add(%x, int64(1)) # an internal invariant was violdated whiletypechecking your program[14:28:41] /home/udav/projects/tvm/src/relay/pass/type_solver.cc:99: Check failed: resolved.defined() Unable to unify parent types: TensorType(, int64) and FuncTypeNode(, [TensorType(, int64), TensorType(, int64)], IncompleteTypeNode(0, 0x21f7670), )Stack trace returned 10 entries: [bt] (0) /workspace/build/libtvm.so(+0x46f1a0) [0x7fef7e69c1a0] [bt] (1) /workspace/build/libtvm.so(+0x46f4c9) [0x7fef7e69c4c9] [bt] (2) /workspace/build/libtvm.so(+0xbadc7c) [0x7fef7eddac7c] [bt] (3) /workspace/build/libtvm.so(+0xba92f5) [0x7fef7edd62f5] [bt] (4) /workspace/build/libtvm.so(+0xbad4dc) [0x7fef7edda4dc] [bt] (5) /workspace/build/libtvm.so(+0xb1b99f) [0x7fef7ed4899f] [bt] (6) /workspace/build/libtvm.so(+0x9cbf7d) [0x7fef7ebf8f7d] [bt] (7) /workspace/build/libtvm.so(+0x9cbdb4) [0x7fef7ebf8db4] [bt] (8) /workspace/build/libtvm.so(+0x9cbbc9) [0x7fef7ebf8bc9] [bt] (9) /workspace/build/libtvm.so(+0x9cb8af) [0x7fef7ebf88af]
; %1 = %0(%x, int64(1)) # %1 }
Could anybody help me write an simple example please?
Thank you