Open smallcoscat opened 4 years ago
Hi. Really appreciate your work 'cause we are trying to do the exactly same thing. But I'm wondering if the project was modified after this issue, 'cause I cannot find the function converter_to_onnx() in the onnx.py. And other functions mentioned in this issue seem different with the ones in the latest files of the branch relay2onnx.
Refer to TVM tutorial Bring Your Own Codegen To TVM, which details how to create a self-defined c source module codegen.
However, ONNX is not a C source module, we should define an ONNX module node for codegen additionally. The following is the steps to create ONNX module codegen, and also applies to other external module codegen.
Create ONNXModuleCodegen to traverse relay IRModule and convert Relay op to ONNX op. (see codegen.cc)
Register a global function, "relay.ext.onnx", whose body is a wrapper function to create onnx module.
Instead of writing op conversions in C++, use _registerfunc to register a global function "tvm.relay.converter.to_onnx", and write op conversions in Python to convert relay module to onnx module. (see converter/onnx.py)
Create ONNXModuleNode which is subclass of ModuleNode to create a specific runtime module. (see source_module.cc)
Create a cmake file for ONNX, and include cmake in CMakeLists.txt. When user wants to use onnx module codegen, set _USE_ONNXCODEGEN "ON", and build TVM source code. (see ONNX.cmake)