Commit e0810512 by Zhi Committed by Tianqi Chen

[TVM][RUNTIME] A minimum example to generate external library wrappers for DSOModule (#4280)

parent 74299972
......@@ -232,6 +232,12 @@ if(USE_VM_PROFILER)
list(APPEND RUNTIME_SRCS ${RUNTIME_VM_PROFILER_SRCS})
endif(USE_VM_PROFILER)
if(USE_EXAMPLE_EXT_RUNTIME)
message(STATUS "Build with example external runtime...")
file(GLOB RUNTIME_EXAMPLE_EXTERNAL_SRCS src/runtime/contrib/example_ext_runtime/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_EXAMPLE_EXTERNAL_SRCS})
endif(USE_EXAMPLE_EXT_RUNTIME)
# Module rules
include(cmake/modules/VTA.cmake)
include(cmake/modules/CUDA.cmake)
......
......@@ -181,3 +181,6 @@ set(USE_VTA_TSIM ON)
# Whether to build VTA FPGA driver (device side only)
set(USE_VTA_FPGA OFF)
# Whether to build the example external runtime module
set(USE_EXAMPLE_EXT_RUNTIME OFF)
......@@ -111,7 +111,7 @@ class Module : public ObjectRef {
*
* \endcode
*/
class ModuleNode : public Object {
class TVM_DLL ModuleNode : public Object {
public:
/*! \brief virtual destructor */
virtual ~ModuleNode() {}
......
......@@ -144,7 +144,12 @@ class Module(ModuleBase):
else:
fcompile = _cc.create_shared
if self.type_key == "c":
kwargs.update({'options': ["-I" + path for path in find_include_path()]})
options = []
if "options" in kwargs:
opts = kwargs["options"]
options = opts if isinstance(opts, (list, tuple)) else [opts]
opts = options + ["-I" + path for path in find_include_path()]
kwargs.update({'options': opts})
fcompile(file_name, files, **kwargs)
def time_evaluator(self, func_name, ctx, number=10, repeat=1, min_repeat_ms=0):
......
......@@ -185,5 +185,8 @@ runtime::Module DeviceSourceModuleCreate(
TVM_REGISTER_GLOBAL("module.source_module_create")
.set_body_typed(SourceModuleCreate);
TVM_REGISTER_GLOBAL("module.csource_module_create")
.set_body_typed(CSourceModuleCreate);
} // namespace codegen
} // namespace tvm
......@@ -18,7 +18,7 @@
*/
/*!
* \file dso_dll_module.cc
* \file dso_module.cc
* \brief Module to load from dynamic shared library.
*/
#include <tvm/runtime/module.h>
......
......@@ -396,7 +396,7 @@ std::pair<std::function<void()>, std::shared_ptr<GraphRuntime::OpArgs> > GraphRu
// Get compiled function from the module that contains both host and device
// code.
tvm::runtime::PackedFunc pf = module_.GetFunction(param.func_name, false);
tvm::runtime::PackedFunc pf = module_.GetFunction(param.func_name, true);
CHECK(pf != nullptr) << "no such function in module: " << param.func_name;
auto fexec = [arg_ptr, pf]() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment