comaniac commented on issue #4280: [TVM][RUNTIME] A minimum example to generate external library wrappers for DSOModule URL: https://github.com/apache/incubator-tvm/pull/4280#issuecomment-554579198 > @comaniac Thanks for the update! Can you move the ExampleJSONModule into a formal module that is compiled by the TVM runtime? Because normally, we will need to implement a SaveToBinary and LoadFromBinary instead of pumping things into a DSO file The current implementation expects external codegens to write the JSON string directly to the DSO module so that we can have a unified interface. Do you mean we should also provide the following JSON module other than DSO module for developers to use: ```c++ JSONModule : runtime::Module { void SaveToBinary(); void LoadFromFile(); }; ``` Now, user would have two JSON files if the user invoke json_module.SaveToBinary() and relay.build()? Would this mean that we have to change API of graph_runtime.create() to include the second JSON file? Also, we will generate the following function in the .so. ```c++ // JSONModule compatible c function that can be compiled by gcc. extern "C" int foo(TVMValue* value, int *type_code, int nargs, std::string json_file) { CHECK_EQ(nargs, 3); DLTensor* arg0 = static_cast<DLTensor*>(value.v_handle); DLTensor* arg1 = static_cast<DLTensor*>(value.v_handle); // Parse json_file and use "foo" as the key to get the subgraph JSON. std::string subgraph_json = ...; foo_(static_cast<float*>(args0->data), args0->shape[0], static_cast<float*>(args1->data), args1->shape[0]), subgraph_json); } ``` So that the user codegen is expected to generate the following: ```c++ // the original foo you intended to generate void foo_(float* a, int N, float* b, int M, float* c, std::string subgraph_json) { // Launch the external engine with subgraph_json and arguements. } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
