Hi,
I am following the BYOC example for the C codegen in the documentation, I have a few questions:
- During testing, do I need to recompile the whole TVM everytime I make a modification to the codegen?
- Once I compiled tvm with my C codegen, how can I make sure it is available? What target name should I use when building a model?
- Do I need to write annotations for my codegen using the python API in order for it to be used when building a model?
- Is it possible to get the generated C without building the model? If so, how?
(Edit: answer is calling
Module.get_source()
from the python API)
Cheers
Edit: I have another question to add:
- For learning/testing purpose, can the generated functions ignore the output? I mean, is it possible to not bother about copying any result to the output tensor (just printing a message instead for example)?
Edit 2: This is where I am at:
-
I compiled tvm with the C codegen example (adding the cmake in contrib and using the right flag in the main cmake to activate it during compilation)
-
I registered the operators in
python/tvm/relay/op/contrib/ccompiler.py
. I used the nameccompiler
as it is the one use incodegen.cc
in the callTVM_REGISTER_GLOBAL("relay.ext.ccompiler").set_body_typed(CCompiler)
. -
For the registration, I basically copied the
dnnl.py
one, renaming occurences ofdnnl
intoccompiler
and commenting out:- some of the registered operators which are not present in the codegen
make_conv_pattern
make_dence_pattern
make_dnnl_pattern
- the pattern table registration
-
I try compiling an ir module using the
ccompiler
target, it fails with the following error:
ValueError: Traceback (most recent call last):
2: TVMFuncCall
1: tvm::TargetInternal::ConstructorDispatcher(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
0: tvm::Target::Target(tvm::runtime::String const&) [clone .cold]
File "/home/nicolas/work/tvm_codegen/tvm/src/target/target.cc", line 473
ValueError: Target kind "ccompiler" is not defined. Target creation from string failed: ccompiler