For example, I run this script
import numpy
import tvm
import tvm.relay
dshape = (64, 1, 32, 32)
kshape = ( 1, 1, 1, 1)
eltype = 'uint16'
scale = 1
data = numpy.random.uniform(-scale, scale, size=dshape).astype(eltype)
kern = numpy.random.uniform(-scale, scale, size=kshape).astype(eltype)
w = tvm.relay.const(kern)
x = tvm.relay.var('x', shape=dshape, dtype=eltype)
y = tvm.relay.nn.conv2d(x, w, padding=(1, 1), dilation=(1, 1), groups=1, channels=1, kernel_size=(1, 1))
mod = tvm.IRModule()
mod['main'] = tvm.relay.Function([x], y)
mod = tvm.relay.transform.AnnotateTarget(["ccompiler"])(mod)
with tvm.transform.PassContext(opt_level=3):
graph, module, params = tvm.relay.build(mod, target='llvm')
and I get
Traceback (most recent call last):
File "y.py", line 3, in <module>
import tvm
File "/Users/dmakarov/work/git/tvm/python/tvm/__init__.py", line 41, in <module>
from .ir import IRModule
File "/Users/dmakarov/work/git/tvm/python/tvm/ir/__init__.py", line 34, in <module>
from . import diagnostics
File "/Users/dmakarov/work/git/tvm/python/tvm/ir/diagnostics/__init__.py", line 73, in <module>
class Diagnostic(Object):
File "/Users/dmakarov/work/git/tvm/python/tvm/_ffi/registry.py", line 69, in register
check_call(_LIB.TVMObjectTypeKey2Index(c_str(object_name), ctypes.byref(tidx)))
File "/Users/dmakarov/work/git/tvm/python/tvm/_ffi/base.py", line 344, in check_call
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
[bt] (7) 8 ??? 0x00007ffee5ac3f00 0x0 + 140732751691520
[bt] (6) 7 _ctypes.cpython-38-darwin.so 0x0000000114bb6177 ffi_call_unix64 + 79
[bt] (5) 6 libtvm.dylib 0x000000011a5fde6b TVMObjectTypeKey2Index + 43
[bt] (4) 5 libtvm.dylib 0x000000011a5fdf45 tvm::runtime::ObjectInternal::ObjectTypeKey2Index(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 21
[bt] (3) 4 libtvm.dylib 0x000000011a5fd67d tvm::runtime::Object::TypeKey2Index(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 29
[bt] (2) 3 libtvm.dylib 0x000000011a5fd7a4 tvm::runtime::TypeContext::TypeKey2Index(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 276
[bt] (1) 2 libtvm.dylib 0x000000011829ef75 dmlc::LogMessageFatal::~LogMessageFatal() + 21
[bt] (0) 1 libtvm.dylib 0x00000001182a2431 dmlc::LogMessageFatal::~LogMessageFatal() + 65
File "../src/runtime/object.cc", line 155
TVMError: Check failed: it != type_key2index_.end(): Cannot find type Diagnostic. Did you forget to register the node by TVM_REGISTER_NODE_TYPE ?
All I want is to understand how I can use a custom codegen from the user’s code.