After implement my BYOC codegen, I call relay.build
it returns me error like this
File "../src/target/stackvm/codegen_stackvm.cc",
TVMError: unknown function call Op(tir.call_pure_extern)
Is there any reason and solution to this?
After implement my BYOC codegen, I call relay.build
it returns me error like this
File "../src/target/stackvm/codegen_stackvm.cc",
TVMError: unknown function call Op(tir.call_pure_extern)
Is there any reason and solution to this?
First, you shouldn’t use stackvm
. Use llvm for host codegen.
unknown function call Op(tir.call_pure_extern)
means you have some backend-specific intrinsic functions our codegen doesn’t know about. You can dump the intrinsic name.
I follow the instructions at here Bring Your Own Codegen To TVM — tvm 0.9.dev182+ge718f5a8a documentation to add the backend codegen for myop
, this is code in my codegen.cc
runtime::Module MyopCompiler(const ObjectRef& ref) {
MyopCodegen myop;
return myop.CreateCSourceModule(ref);
}
TVM_REGISTER_GLOBAL("relay.ext.myop").set_body_typed(myopCompiler);
at the python side for building my network with only one layer (myop
), here are my code
input1 = relay.var('data', shape=(),dtype='float32')
myop = relay.nn.myop(input1)
args = relay.analysis.free_vars(myop)
net = relay.Function(args, myop)
mod = tvm.IRModule.from_expr(net)
mod = relay.transform.InferType()(mod)
lib = relay.build(mod, target, params)
is there any step that I was missing? should I use relay.compile
instead of relay.build
?
when I print tvm.get_global_func("relay.ext.myop", True)
it can return me something like
<tvm.runtime.packed_func.PackedFunc object at 0x7fabe521dc00>