Here is an example(I also updated my code above according as there is a minor problem), to construct the code manually
```python mod = ModuleMetaDataWrapper(metadata) mod.import_module(CSourceModule(dnnl_code); mod.export_library("xyz.so") loaded = tvm.runtime.load_module("xyz.so"); ``` After we load it backin, it becomes ```python loaded = ModuleInitWrapper() loaded.import_modules = [DSOModule()] ``` Now when we call `f = loaded.get_function(name)`, the call steps are as follows: - Calls into ModuleInitWrapper.GetFunction, which checks if the imported module is initialized - If the imported dso module is not intialized, ModuleInitWrapper.GetFunction will call `__InitModule` in the DSO module by passing the meta data to it - All the get function calls redirects into the DSOModule then it can return the function as normal - When ModuleMetaDataWrapper destructs, it calls into the destroy function. ```c++ // implementation of ModuleMetaDataWrapper.GetFunction class ModuleMetaDataWrapper : public runtime::ModuleNode { public: GetFunction(name) { if (!initialzied_) this->InitSubModule(); if (name != "__InitModule" && name != "__DestroyModule") { return this->imported_modules[0]->GetFunction(name); } } private: bool initialized_{false}; Array<NDArray> metadata_; }; ``` --- [Visit Topic](https://discuss.tvm.ai/t/byoc-runtime-json-runtime-for-byoc/6579/7) to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/39e852577c24a00bab10bcc4305bb2ce0cbba31a1d571c03ee21e947c3f007f0).