Cody, I realized using conv2d is wrong with ccompiler, so I changed the example slightly
import numpy
import tvm
import tvm.relay
x = tvm.relay.var("x", shape=(3,), dtype="float32")
y = tvm.relay.var("y", shape=(3,), dtype="float32")
z = x + y
mod = tvm.IRModule.from_expr(tvm.relay.Function([x, y], z))
mod = tvm.relay.transform.AnnotateTarget(["ccompiler"])(mod)
with tvm.transform.PassContext(opt_level=3):
graph, module, params = tvm.relay.build(mod, target='c')
module.save('y.cc', fmt='cc')
and now it breaks with this error
Traceback (most recent call last):
File "y.py", line 12, in <module>
graph, module, params = tvm.relay.build(mod, target='c')
File "/Users/dmakarov/work/git/tvm/python/tvm/relay/build_module.py", line 275, in build
graph_json, mod, params = bld_mod.build(mod, target, target_host, params)
File "/Users/dmakarov/work/git/tvm/python/tvm/relay/build_module.py", line 138, in build
self._build(mod, target, target_host)
File "/Users/dmakarov/work/git/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] (8) 9 libtvm.dylib 0x0000000116590cdd tvm::relay::ScheduleGetter::VisitExpr_(tvm::relay::CallNode const*) + 2781
[bt] (7) 8 libtvm.dylib 0x000000011659bca0 tvm::runtime::TVMRetValue tvm::runtime::PackedFunc::operator()<tvm::relay::Call, tvm::runtime::Array<tvm::te::Tensor, void>&, tvm::Target&>(tvm::relay::Call&&, tvm::runtime::Array<tvm::te::Tensor, void>&, tvm::Target&) const + 304
[bt] (6) 7 libtvm.dylib 0x00000001142c2561 std::__1::function<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const + 65
[bt] (5) 6 libtvm.dylib 0x00000001142c279a std::__1::__function::__value_func<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) const + 106
[bt] (4) 5 libtvm.dylib 0x0000000116b64b98 std::__1::__function::__func<TVMFuncCreateFromCFunc::$_2, std::__1::allocator<TVMFuncCreateFromCFunc::$_2>, void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) + 72
[bt] (3) 4 libtvm.dylib 0x0000000116b660c7 std::__1::__function::__alloc_func<TVMFuncCreateFromCFunc::$_2, std::__1::allocator<TVMFuncCreateFromCFunc::$_2>, void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) + 71
[bt] (2) 3 libtvm.dylib 0x0000000116b66117 void std::__1::__invoke_void_return_wrapper<void>::__call<TVMFuncCreateFromCFunc::$_2&, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*>(TVMFuncCreateFromCFunc::$_2&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) + 71
[bt] (1) 2 libtvm.dylib 0x0000000116b661b3 decltype(std::__1::forward<TVMFuncCreateFromCFunc::$_2&>(fp)(std::__1::forward<tvm::runtime::TVMArgs>(fp0), std::__1::forward<tvm::runtime::TVMRetValue*>(fp0))) std::__1::__invoke<TVMFuncCreateFromCFunc::$_2&, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*>(TVMFuncCreateFromCFunc::$_2&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) + 115
[bt] (0) 1 libtvm.dylib 0x0000000116b6628e TVMFuncCreateFromCFunc::$_2::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const + 190
File "/Users/dmakarov/work/git/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 81, in cfun
rv = local_pyfunc(*pyargs)
File "/Users/dmakarov/work/git/tvm/python/tvm/relay/backend/compile_engine.py", line 297, in lower_call
best_impl, outputs = select_implementation(op, call.attrs, inputs, ret_type, target)
File "/Users/dmakarov/work/git/tvm/python/tvm/relay/backend/compile_engine.py", line 186, in select_implementation
all_impls = get_valid_implementations(op, attrs, inputs, out_type, target)
File "/Users/dmakarov/work/git/tvm/python/tvm/relay/backend/compile_engine.py", line 125, in get_valid_implementations
assert fstrategy is not None, "%s doesn't have FTVMStrategy registered" % op.name
AssertionError: annotation.compiler_end doesn't have FTVMStrategy registered
I’d like to see the custom codegen invoked on an entire graph