tree: 0a4c0684e1ab1e114b6be4bc75d5033f59475b2a [path history] [tgz]
  1. .gitignore
  2. Makefile
  3. plugin_module.cc
  4. README.md
  5. test_plugin_module.py
apps/dso_plugin_module/README.md

Example Plugin Module

This folder contains an example that implements a C++ module that can be directly loaded as TVM's DSOModule (via tvm.runtime.load_module)

Guideline

When possible, we always recommend exposing functions that modifies memory passed by the caller, and calls into the runtime API for memory allocations.

Advanced Usecases

In advanced usecases, we do allow the plugin module to create and return managed objects. However, there are several restrictions to keep in mind:

  • If the module returns an object, we need to make sure that the object get destructed before the module get unloaded. Otherwise segfault can happen because of calling into an unloaded destructor.
  • If the module returns a PackedFunc, then we need to ensure that the libc of the DLL and tvm runtime matches. Otherwise segfault can happen due to incompatibility of std::function.