This is an automated email from the ASF dual-hosted git repository.
spectrometerHBH pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new fe0e8cb6c8 [REFACTOR] Phase out include/tvm/runtime/module.h (#19441)
fe0e8cb6c8 is described below
commit fe0e8cb6c814476b436465c9d41044d04edbb281
Author: Tianqi Chen <[email protected]>
AuthorDate: Sat Apr 25 11:01:57 2026 -0400
[REFACTOR] Phase out include/tvm/runtime/module.h (#19441)
## Summary
`include/tvm/runtime/module.h` had accumulated three unrelated
responsibilities; this PR
relocates each of them and removes the header. C++ callers now include
either
`<tvm/ffi/extra/module.h>` (for `ffi::Module`) or
`<tvm/runtime/device_api.h>` (for
`RuntimeEnabled` and the runtime `symbol::*` constants), depending on
what they actually use.
## Changes
- `details::ModuleVTableEntryHelper` and the `TVM_MODULE_VTABLE_*`
macros move to a new
private header `src/runtime/vm/module_utils.h` (in
`tvm::runtime::vm::details`) since
they are only used by VM modules.
- `RuntimeEnabled` and `namespace symbol { tvm_set_device,
tvm_global_barrier_state,
tvm_prepare_global_barrier }` move to
`include/tvm/runtime/device_api.h`.
- `VMExecutable::kind` and `VMExecutable::GetFunction` are now declared
in the public
header and defined out-of-line in `executable.cc`, so the vtable macros
stay private to
`src/runtime/vm/`.
---
apps/cpp_rpc/rpc_env.cc | 2 +-
apps/hexagon_launcher/launcher_core.h | 18 +++----
docs/arch/runtime.rst | 2 +-
include/tvm/runtime/device_api.h | 18 +++++++
include/tvm/runtime/disco/builtin.h | 2 +-
include/tvm/runtime/profiling.h | 2 +-
include/tvm/runtime/vm/executable.h | 18 +++----
include/tvm/target/codegen.h | 2 +-
src/ir/op.cc | 1 -
src/relax/backend/contrib/cutlass/codegen.cc | 2 +-
src/relax/transform/fold_constant.cc | 2 +-
src/relax/transform/run_codegen.cc | 2 +-
src/runtime/cuda/cuda_module.cc | 1 +
src/runtime/cuda/cuda_module.h | 2 +-
src/runtime/device_api.cc | 1 -
src/runtime/hexagon/hexagon_buffer.cc | 2 -
src/runtime/metadata.h | 2 +-
src/runtime/module.cc | 2 +-
src/runtime/rpc/rpc_session.h | 2 +-
src/runtime/static_library.cc | 2 +-
src/runtime/static_library.h | 2 +-
src/runtime/vm/executable.cc | 16 ++++++
.../module.h => src/runtime/vm/module_utils.h | 59 ++++++++--------------
src/runtime/vm/vm.cc | 2 +
src/s_tir/transform/thread_storage_sync.cc | 1 +
src/support/ffi_testing.cc | 2 +-
src/target/codegen.cc | 2 +-
src/target/llvm/codegen_blob.cc | 2 +-
src/target/llvm/codegen_cpu.cc | 2 +-
src/target/llvm/codegen_hexagon.cc | 2 +-
src/target/llvm/llvm_module.h | 3 +-
src/target/source/codegen_cuda.cc | 1 +
src/tirx/transform/make_packed_api.cc | 1 -
tests/cpp-runtime/opencl/texture_copy_test.cc | 1 +
34 files changed, 100 insertions(+), 81 deletions(-)
diff --git a/apps/cpp_rpc/rpc_env.cc b/apps/cpp_rpc/rpc_env.cc
index a9d463a1aa..cc2c5f798a 100644
--- a/apps/cpp_rpc/rpc_env.cc
+++ b/apps/cpp_rpc/rpc_env.cc
@@ -20,9 +20,9 @@
* \file rpc_env.cc
* \brief Server environment of the RPC.
*/
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/runtime/logging.h>
-#include <tvm/runtime/module.h>
#include <cerrno>
#ifndef _WIN32
diff --git a/apps/hexagon_launcher/launcher_core.h
b/apps/hexagon_launcher/launcher_core.h
index b8c3c6f56b..1af8a1fbf8 100644
--- a/apps/hexagon_launcher/launcher_core.h
+++ b/apps/hexagon_launcher/launcher_core.h
@@ -22,9 +22,9 @@
#include <dlpack/dlpack.h>
#include <tvm/ffi/extra/json.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/runtime/data_type.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/tensor.h>
#include <string>
@@ -81,10 +81,10 @@ struct OutputConfig {
};
struct Model {
- Model(tvm::runtime::Module executor, tvm::runtime::Module module,
std::string json);
+ Model(tvm::ffi::Module executor, tvm::ffi::Module module, std::string json);
- tvm::runtime::Module model_executor;
- tvm::runtime::Module graph_module;
+ tvm::ffi::Module model_executor;
+ tvm::ffi::Module graph_module;
std::string graph_json;
static tvm::Device device() { return
tvm::Device{static_cast<DLDeviceType>(kDLHexagon), 0}; }
@@ -121,13 +121,13 @@ bool write_output_config(const std::string& file_name,
OutputConfig* output_conf
void reset_device_api();
-tvm::runtime::Module load_module(const std::string& file_name);
+tvm::ffi::Module load_module(const std::string& file_name);
const tvm::ffi::Function get_runtime_func(const std::string& name);
-const tvm::ffi::Function get_module_func(tvm::runtime::Module module, const
std::string& name);
+const tvm::ffi::Function get_module_func(tvm::ffi::Module module, const
std::string& name);
-tvm::runtime::Module create_aot_executor(tvm::runtime::Module factory_module,
tvm::Device device);
-tvm::runtime::Module create_graph_executor(const std::string& graph_json,
- tvm::runtime::Module graph_module,
tvm::Device device);
+tvm::ffi::Module create_aot_executor(tvm::ffi::Module factory_module,
tvm::Device device);
+tvm::ffi::Module create_graph_executor(const std::string& graph_json,
tvm::ffi::Module graph_module,
+ tvm::Device device);
#endif // TVM_RUNTIME_HEXAGON_LAUNCHER_LAUNCHER_CORE_H_
diff --git a/docs/arch/runtime.rst b/docs/arch/runtime.rst
index 9839e559cf..575451d8fe 100644
--- a/docs/arch/runtime.rst
+++ b/docs/arch/runtime.rst
@@ -169,7 +169,7 @@ TVM defines the compiled object as `Module`_.
The user can get the compiled function from Module as PackedFunc.
The generated compiled code can dynamically get function from Module in
runtime. It caches the function handle in the first call and reuses in
subsequent calls. We use this to link device code and callback into any
PackedFunc(e.g., python) from generated code.
-.. _Module:
https://github.com/apache/tvm/blob/main/include/tvm/runtime/module.h
+.. _Module:
https://github.com/apache/tvm/blob/main/3rdparty/tvm-ffi/include/tvm/ffi/extra/module.h
The ModuleNode is an abstract class that can be implemented by each type of
device.
So far we support modules for CUDA, Metal, OpenCL and loading dynamic shared
libraries. This abstraction makes introduction
diff --git a/include/tvm/runtime/device_api.h b/include/tvm/runtime/device_api.h
index 7139d41cbb..91fc1f1296 100644
--- a/include/tvm/runtime/device_api.h
+++ b/include/tvm/runtime/device_api.h
@@ -26,6 +26,7 @@
#include <tvm/ffi/any.h>
#include <tvm/ffi/optional.h>
+#include <tvm/ffi/string.h>
#include <tvm/runtime/base.h>
#include <tvm/runtime/logging.h>
@@ -404,6 +405,23 @@ inline Device AddRPCSessionMask(Device dev, int
session_table_index) {
return dev;
}
+/*!
+ * \brief Check if runtime module is enabled for target.
+ * \param target The target module name.
+ * \return Whether runtime is enabled.
+ */
+TVM_DLL bool RuntimeEnabled(const ffi::String& target);
+
+/*! \brief namespace for constant symbols */
+namespace symbol {
+/*! \brief global function to set device */
+constexpr const char* tvm_set_device = "__tvm_set_device";
+/*! \brief Auxiliary counter to global barrier. */
+constexpr const char* tvm_global_barrier_state = "__tvm_global_barrier_state";
+/*! \brief Prepare the global barrier before kernels that uses global barrier.
*/
+constexpr const char* tvm_prepare_global_barrier =
"__tvm_prepare_global_barrier";
+} // namespace symbol
+
} // namespace runtime
} // namespace tvm
diff --git a/include/tvm/runtime/disco/builtin.h
b/include/tvm/runtime/disco/builtin.h
index 3a1e4850a4..a9d2a52c41 100644
--- a/include/tvm/runtime/disco/builtin.h
+++ b/include/tvm/runtime/disco/builtin.h
@@ -19,8 +19,8 @@
#ifndef TVM_RUNTIME_DISCO_BUILTIN_H_
#define TVM_RUNTIME_DISCO_BUILTIN_H_
+#include <tvm/ffi/extra/module.h>
#include <tvm/runtime/data_type.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/tensor.h>
#include <string>
diff --git a/include/tvm/runtime/profiling.h b/include/tvm/runtime/profiling.h
index c04310d9db..39fc1f39c9 100644
--- a/include/tvm/runtime/profiling.h
+++ b/include/tvm/runtime/profiling.h
@@ -26,10 +26,10 @@
#include <tvm/ffi/container/array.h>
#include <tvm/ffi/container/map.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/runtime/base.h>
#include <tvm/runtime/device_api.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/object.h>
#include <tvm/runtime/tensor.h>
diff --git a/include/tvm/runtime/vm/executable.h
b/include/tvm/runtime/vm/executable.h
index 5ee47694dd..39195802cd 100644
--- a/include/tvm/runtime/vm/executable.h
+++ b/include/tvm/runtime/vm/executable.h
@@ -23,8 +23,8 @@
#ifndef TVM_RUNTIME_VM_EXECUTABLE_H_
#define TVM_RUNTIME_VM_EXECUTABLE_H_
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/object.h>
#include <tvm/support/io.h>
#include <tvm/support/serializer.h>
@@ -166,14 +166,14 @@ class VMExecutable : public ffi::ModuleObj {
virtual ~VMExecutable() {}
- TVM_MODULE_VTABLE_BEGIN("relax.VMExecutable");
- TVM_MODULE_VTABLE_ENTRY("stats", &VMExecutable::Stats);
- TVM_MODULE_VTABLE_ENTRY("as_text", &VMExecutable::AsText);
- TVM_MODULE_VTABLE_ENTRY("as_python", &VMExecutable::AsPython);
- TVM_MODULE_VTABLE_ENTRY("vm_load_executable",
&VMExecutable::VMLoadExecutable);
- TVM_MODULE_VTABLE_ENTRY("vm_profiler_load_executable",
&VMExecutable::VMProfilerLoadExecutable);
- TVM_MODULE_VTABLE_ENTRY("has_function", &VMExecutable::HasFunction);
- TVM_MODULE_VTABLE_END();
+ /*! \brief Module type key. */
+ const char* kind() const final;
+ /*!
+ * \brief Look up an exported function by name.
+ * \param name The function name.
+ * \return The function if found, otherwise std::nullopt.
+ */
+ ffi::Optional<ffi::Function> GetFunction(const ffi::String& name) override;
private:
/*!
diff --git a/include/tvm/target/codegen.h b/include/tvm/target/codegen.h
index 59db02f8b8..32baf16d4a 100644
--- a/include/tvm/target/codegen.h
+++ b/include/tvm/target/codegen.h
@@ -24,8 +24,8 @@
#ifndef TVM_TARGET_CODEGEN_H_
#define TVM_TARGET_CODEGEN_H_
+#include <tvm/ffi/extra/module.h>
#include <tvm/ir/module.h>
-#include <tvm/runtime/module.h>
#include <tvm/target/target.h>
#include <tvm/tirx/expr.h>
diff --git a/src/ir/op.cc b/src/ir/op.cc
index 0f8ff2ea7d..3a260e886a 100644
--- a/src/ir/op.cc
+++ b/src/ir/op.cc
@@ -25,7 +25,6 @@
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ir/op.h>
#include <tvm/ir/type.h>
-#include <tvm/runtime/module.h>
#include <tvm/tirx/op_attr_types.h>
#include <memory>
diff --git a/src/relax/backend/contrib/cutlass/codegen.cc
b/src/relax/backend/contrib/cutlass/codegen.cc
index bc24fad3b9..1340ba5935 100644
--- a/src/relax/backend/contrib/cutlass/codegen.cc
+++ b/src/relax/backend/contrib/cutlass/codegen.cc
@@ -21,13 +21,13 @@
* \file src/relax/backend/contrib/cutlass/codegen.cc
* \brief Implementation of the CUTLASS code generator for Relax.
*/
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ir/module.h>
#include <tvm/ir/name_supply.h>
#include <tvm/relax/analysis.h>
#include <tvm/relax/attrs/nn.h>
#include <tvm/relax/type.h>
-#include <tvm/runtime/module.h>
#include <memory>
#include <string>
diff --git a/src/relax/transform/fold_constant.cc
b/src/relax/transform/fold_constant.cc
index e68b9232e4..f699775af9 100644
--- a/src/relax/transform/fold_constant.cc
+++ b/src/relax/transform/fold_constant.cc
@@ -17,6 +17,7 @@
* under the License.
*/
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ir/function.h>
#include <tvm/relax/analysis.h>
@@ -24,7 +25,6 @@
#include <tvm/relax/op_attr_types.h>
#include <tvm/relax/transform.h>
#include <tvm/relax/type.h>
-#include <tvm/runtime/module.h>
#include <tvm/tirx/function.h>
#include <tvm/tirx/op.h>
diff --git a/src/relax/transform/run_codegen.cc
b/src/relax/transform/run_codegen.cc
index 14b64c34d6..22828f8bf7 100644
--- a/src/relax/transform/run_codegen.cc
+++ b/src/relax/transform/run_codegen.cc
@@ -23,11 +23,11 @@
* \brief Run codegen for annotated relax functions.
*/
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/relax/analysis.h>
#include <tvm/relax/expr_functor.h>
#include <tvm/relax/transform.h>
-#include <tvm/runtime/module.h>
#include "../../support/ordered_set.h"
#include "utils.h"
diff --git a/src/runtime/cuda/cuda_module.cc b/src/runtime/cuda/cuda_module.cc
index d529af126b..d06f5a9d5c 100644
--- a/src/runtime/cuda/cuda_module.cc
+++ b/src/runtime/cuda/cuda_module.cc
@@ -27,6 +27,7 @@
#include <tvm/ffi/extra/c_env_api.h>
#include <tvm/ffi/function.h>
#include <tvm/ffi/reflection/registry.h>
+#include <tvm/runtime/device_api.h>
#include <tvm/support/io.h>
#include <array>
diff --git a/src/runtime/cuda/cuda_module.h b/src/runtime/cuda/cuda_module.h
index 58776dd7e5..418d8ee8eb 100644
--- a/src/runtime/cuda/cuda_module.h
+++ b/src/runtime/cuda/cuda_module.h
@@ -24,7 +24,7 @@
#ifndef TVM_RUNTIME_CUDA_CUDA_MODULE_H_
#define TVM_RUNTIME_CUDA_CUDA_MODULE_H_
-#include <tvm/runtime/module.h>
+#include <tvm/ffi/extra/module.h>
#include <memory>
#include <string>
diff --git a/src/runtime/device_api.cc b/src/runtime/device_api.cc
index f95262424d..d8aff594ea 100644
--- a/src/runtime/device_api.cc
+++ b/src/runtime/device_api.cc
@@ -31,7 +31,6 @@
#include <tvm/runtime/base.h>
#include <tvm/runtime/c_backend_api.h>
#include <tvm/runtime/device_api.h>
-#include <tvm/runtime/module.h>
#include <algorithm>
#include <array>
diff --git a/src/runtime/hexagon/hexagon_buffer.cc
b/src/runtime/hexagon/hexagon_buffer.cc
index aa1453dbe5..84297c25e6 100644
--- a/src/runtime/hexagon/hexagon_buffer.cc
+++ b/src/runtime/hexagon/hexagon_buffer.cc
@@ -18,8 +18,6 @@
*/
#include "hexagon_buffer.h"
-#include <tvm/runtime/module.h>
-
#include <algorithm>
#include <string>
#include <utility>
diff --git a/src/runtime/metadata.h b/src/runtime/metadata.h
index adc5788485..877f7c926d 100644
--- a/src/runtime/metadata.h
+++ b/src/runtime/metadata.h
@@ -27,8 +27,8 @@
#include <tvm/ffi/container/array.h>
#include <tvm/ffi/container/map.h>
#include <tvm/ffi/extra/json.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/tensor.h>
#include <tvm/support/io.h>
#include <tvm/support/serializer.h>
diff --git a/src/runtime/module.cc b/src/runtime/module.cc
index fde00b7944..b72607134d 100644
--- a/src/runtime/module.cc
+++ b/src/runtime/module.cc
@@ -25,7 +25,7 @@
#include <tvm/ffi/function.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/c_backend_api.h>
-#include <tvm/runtime/module.h>
+#include <tvm/runtime/device_api.h>
#include <cstring>
#include <unordered_set>
diff --git a/src/runtime/rpc/rpc_session.h b/src/runtime/rpc/rpc_session.h
index 307469f131..096ab2bdf9 100644
--- a/src/runtime/rpc/rpc_session.h
+++ b/src/runtime/rpc/rpc_session.h
@@ -24,9 +24,9 @@
#ifndef TVM_RUNTIME_RPC_RPC_SESSION_H_
#define TVM_RUNTIME_RPC_RPC_SESSION_H_
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/runtime/device_api.h>
-#include <tvm/runtime/module.h>
#include <tvm/runtime/object.h>
#include <functional>
diff --git a/src/runtime/static_library.cc b/src/runtime/static_library.cc
index f53e12a15d..daa157435b 100644
--- a/src/runtime/static_library.cc
+++ b/src/runtime/static_library.cc
@@ -24,10 +24,10 @@
*/
#include "./static_library.h"
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/ffi/memory.h>
#include <tvm/ffi/reflection/registry.h>
-#include <tvm/runtime/module.h>
#include <tvm/support/io.h>
#include <tvm/support/serializer.h>
diff --git a/src/runtime/static_library.h b/src/runtime/static_library.h
index 2ebca2edd2..65ee6f8808 100644
--- a/src/runtime/static_library.h
+++ b/src/runtime/static_library.h
@@ -27,8 +27,8 @@
#define TVM_RUNTIME_STATIC_LIBRARY_H_
#include <tvm/ffi/container/array.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/runtime/logging.h>
-#include <tvm/runtime/module.h>
#include <array>
#include <memory>
diff --git a/src/runtime/vm/executable.cc b/src/runtime/vm/executable.cc
index ada04a1024..24ac2949b4 100644
--- a/src/runtime/vm/executable.cc
+++ b/src/runtime/vm/executable.cc
@@ -32,6 +32,7 @@
#include "../../support/bytes_io.h"
#include "../file_utils.h"
+#include "./module_utils.h"
namespace tvm {
namespace runtime {
@@ -45,6 +46,21 @@ constexpr uint64_t kTVMVMBytecodeMagicV2 =
0xD225DE2F4214151E;
TVM_FFI_ICHECK(val) << "Invalid VM file format in the " << section << "
section." \
<< "\n";
+const char* VMExecutable::kind() const { return "relax.VMExecutable"; }
+
+ffi::Optional<ffi::Function> VMExecutable::GetFunction(const ffi::String&
_name) {
+ using SelfPtr = std::remove_cv_t<decltype(this)>;
+ ::tvm::ffi::ObjectPtr<::tvm::ffi::Object> _self =
+ ::tvm::ffi::GetObjectPtr<::tvm::ffi::Object>(this);
+ TVM_MODULE_VTABLE_ENTRY("stats", &VMExecutable::Stats);
+ TVM_MODULE_VTABLE_ENTRY("as_text", &VMExecutable::AsText);
+ TVM_MODULE_VTABLE_ENTRY("as_python", &VMExecutable::AsPython);
+ TVM_MODULE_VTABLE_ENTRY("vm_load_executable",
&VMExecutable::VMLoadExecutable);
+ TVM_MODULE_VTABLE_ENTRY("vm_profiler_load_executable",
&VMExecutable::VMProfilerLoadExecutable);
+ TVM_MODULE_VTABLE_ENTRY("has_function", &VMExecutable::HasFunction);
+ return std::nullopt;
+}
+
std::string VMExecutable::Stats() const {
std::ostringstream oss;
oss << "Relax VM executable statistics:" << std::endl;
diff --git a/include/tvm/runtime/module.h b/src/runtime/vm/module_utils.h
similarity index 77%
rename from include/tvm/runtime/module.h
rename to src/runtime/vm/module_utils.h
index 51fe315903..f6c69c49dd 100644
--- a/include/tvm/runtime/module.h
+++ b/src/runtime/vm/module_utils.h
@@ -18,45 +18,28 @@
*/
/*!
- * \file tvm/runtime/module.h
- * \brief Runtime container of the functions generated by TVM,
- * This is used to support dynamically link, load and save
- * functions from different convention under unified API.
+ * \file src/runtime/vm/module_utils.h
+ * \brief Internal helpers for declaring VM module vtables.
+ *
+ * Provides the TVM_MODULE_VTABLE_* macros and ModuleVTableEntryHelper
+ * template that VM module implementations use to expose member
+ * functions as ffi::Function entries via ffi::ModuleObj::GetFunction.
+ *
+ * This header is private to src/runtime/vm/. Module implementations
+ * outside this directory should not depend on these macros.
*/
-#ifndef TVM_RUNTIME_MODULE_H_
-#define TVM_RUNTIME_MODULE_H_
+#ifndef TVM_RUNTIME_VM_MODULE_UTILS_H_
+#define TVM_RUNTIME_VM_MODULE_UTILS_H_
#include <tvm/ffi/cast.h>
#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
-#include <tvm/ffi/memory.h>
-#include <tvm/ffi/string.h>
-#include <tvm/runtime/base.h>
-#include <tvm/runtime/logging.h>
-#include <tvm/runtime/object.h>
#include <utility>
namespace tvm {
namespace runtime {
-
-/*!
- * \brief Check if runtime module is enabled for target.
- * \param target The target module name.
- * \return Whether runtime is enabled.
- */
-TVM_DLL bool RuntimeEnabled(const ffi::String& target);
-
-/*! \brief namespace for constant symbols */
-namespace symbol {
-/*! \brief global function to set device */
-constexpr const char* tvm_set_device = "__tvm_set_device";
-/*! \brief Auxiliary counter to global barrier. */
-constexpr const char* tvm_global_barrier_state = "__tvm_global_barrier_state";
-/*! \brief Prepare the global barrier before kernels that uses global barrier.
*/
-constexpr const char* tvm_prepare_global_barrier =
"__tvm_prepare_global_barrier";
-} // namespace symbol
-
+namespace vm {
namespace details {
template <typename T>
@@ -101,7 +84,9 @@ struct ModuleVTableEntryHelper<void (T::*)(Args...)> {
args.data(), args.size(), rv);
}
};
+
} // namespace details
+} // namespace vm
} // namespace runtime
} // namespace tvm
@@ -120,13 +105,13 @@ struct ModuleVTableEntryHelper<void (T::*)(Args...)> {
return (this->*f)(_name); \
} \
} // NOLINT(*)
-#define TVM_MODULE_VTABLE_ENTRY(Name, MemFunc)
\
- if (_name == Name) {
\
- return ffi::Function::FromPacked([_self](ffi::PackedArgs args, ffi::Any*
rv) -> void { \
- using Helper =
::tvm::runtime::details::ModuleVTableEntryHelper<decltype(MemFunc)>; \
- SelfPtr self = static_cast<SelfPtr>(_self.get());
\
- Helper::Call(rv, self, MemFunc, args);
\
- });
\
+#define TVM_MODULE_VTABLE_ENTRY(Name, MemFunc)
\
+ if (_name == Name) {
\
+ return ffi::Function::FromPacked([_self](ffi::PackedArgs args, ffi::Any*
rv) -> void { \
+ using Helper =
::tvm::runtime::vm::details::ModuleVTableEntryHelper<decltype(MemFunc)>; \
+ SelfPtr self = static_cast<SelfPtr>(_self.get());
\
+ Helper::Call(rv, self, MemFunc, args);
\
+ });
\
}
#define TVM_MODULE_VTABLE_ENTRY_PACKED(Name, MemFunc)
\
if (_name == Name) {
\
@@ -135,4 +120,4 @@ struct ModuleVTableEntryHelper<void (T::*)(Args...)> {
});
\
}
-#endif // TVM_RUNTIME_MODULE_H_
+#endif // TVM_RUNTIME_VM_MODULE_UTILS_H_
diff --git a/src/runtime/vm/vm.cc b/src/runtime/vm/vm.cc
index 16a2c5ea95..cc336ea696 100644
--- a/src/runtime/vm/vm.cc
+++ b/src/runtime/vm/vm.cc
@@ -30,6 +30,8 @@
#include <optional>
#include <thread>
+#include "./module_utils.h"
+
namespace tvm {
namespace runtime {
namespace vm {
diff --git a/src/s_tir/transform/thread_storage_sync.cc
b/src/s_tir/transform/thread_storage_sync.cc
index f854de249a..3ec44d7a3d 100644
--- a/src/s_tir/transform/thread_storage_sync.cc
+++ b/src/s_tir/transform/thread_storage_sync.cc
@@ -22,6 +22,7 @@
*/
#include <tvm/ffi/function.h>
#include <tvm/ffi/reflection/registry.h>
+#include <tvm/runtime/device_api.h>
#include <tvm/s_tir/stmt.h>
#include <tvm/s_tir/transform.h>
#include <tvm/tirx/analysis.h>
diff --git a/src/support/ffi_testing.cc b/src/support/ffi_testing.cc
index 29d671108d..9d7ac06b91 100644
--- a/src/support/ffi_testing.cc
+++ b/src/support/ffi_testing.cc
@@ -22,12 +22,12 @@
* \file ffi_testing.cc
*/
#include <tvm/ffi/container/variant.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ir/attrs.h>
#include <tvm/ir/env_func.h>
#include <tvm/runtime/device_api.h>
-#include <tvm/runtime/module.h>
#include <tvm/te/tensor.h>
#include <tvm/tirx/expr.h>
diff --git a/src/target/codegen.cc b/src/target/codegen.cc
index 714b0d7256..f24cb6a494 100644
--- a/src/target/codegen.cc
+++ b/src/target/codegen.cc
@@ -21,11 +21,11 @@
* \file codegen.cc
* \brief Common utilities to generated C style code.
*/
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/function.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/ir/module.h>
#include <tvm/runtime/base.h>
-#include <tvm/runtime/module.h>
#include <tvm/support/io.h>
#include <tvm/support/serializer.h>
#include <tvm/target/codegen.h>
diff --git a/src/target/llvm/codegen_blob.cc b/src/target/llvm/codegen_blob.cc
index 0bba8d492e..029327e977 100644
--- a/src/target/llvm/codegen_blob.cc
+++ b/src/target/llvm/codegen_blob.cc
@@ -46,7 +46,7 @@
#include <llvm/Support/Alignment.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>
-#include <tvm/runtime/module.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/target/target.h>
#include <cstring>
diff --git a/src/target/llvm/codegen_cpu.cc b/src/target/llvm/codegen_cpu.cc
index 2536386f66..974cbb1e8a 100644
--- a/src/target/llvm/codegen_cpu.cc
+++ b/src/target/llvm/codegen_cpu.cc
@@ -47,9 +47,9 @@
#include <llvm/Support/raw_ostream.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/base.h>
-#include <tvm/runtime/module.h>
#include <tvm/tirx/analysis.h>
#include <algorithm>
diff --git a/src/target/llvm/codegen_hexagon.cc
b/src/target/llvm/codegen_hexagon.cc
index bb1227b464..ac9c1a4b91 100644
--- a/src/target/llvm/codegen_hexagon.cc
+++ b/src/target/llvm/codegen_hexagon.cc
@@ -41,8 +41,8 @@
#include <llvm/Support/raw_ostream.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Transforms/Utils/Cloning.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/ffi/reflection/registry.h>
-#include <tvm/runtime/module.h>
#include <tvm/target/codegen.h>
#include <tvm/tirx/analysis.h>
diff --git a/src/target/llvm/llvm_module.h b/src/target/llvm/llvm_module.h
index 75897e539f..ddd07b0090 100644
--- a/src/target/llvm/llvm_module.h
+++ b/src/target/llvm/llvm_module.h
@@ -28,8 +28,7 @@
#ifdef TVM_LLVM_VERSION
#include <tvm/ffi/container/array.h>
-#include <tvm/runtime/metadata.h>
-#include <tvm/runtime/module.h>
+#include <tvm/ffi/extra/module.h>
#include <tvm/target/target.h>
namespace tvm {
diff --git a/src/target/source/codegen_cuda.cc
b/src/target/source/codegen_cuda.cc
index 8584f05804..4144326959 100644
--- a/src/target/source/codegen_cuda.cc
+++ b/src/target/source/codegen_cuda.cc
@@ -25,6 +25,7 @@
#include <tvm/arith/analyzer.h>
#include <tvm/ffi/function.h>
+#include <tvm/runtime/device_api.h>
#include <tvm/s_tir/stmt.h>
#include <tvm/tirx/index_map.h>
#include <tvm/tirx/stmt_functor.h>
diff --git a/src/tirx/transform/make_packed_api.cc
b/src/tirx/transform/make_packed_api.cc
index bc568589e5..f769d079f7 100644
--- a/src/tirx/transform/make_packed_api.cc
+++ b/src/tirx/transform/make_packed_api.cc
@@ -25,7 +25,6 @@
#include <tvm/ffi/reflection/access_path.h>
#include <tvm/ffi/reflection/registry.h>
#include <tvm/runtime/device_api.h>
-#include <tvm/runtime/module.h>
#include <tvm/target/target.h>
#include <tvm/tirx/analysis.h>
#include <tvm/tirx/buffer.h>
diff --git a/tests/cpp-runtime/opencl/texture_copy_test.cc
b/tests/cpp-runtime/opencl/texture_copy_test.cc
index 3cc4f2e5b8..fc96411da8 100644
--- a/tests/cpp-runtime/opencl/texture_copy_test.cc
+++ b/tests/cpp-runtime/opencl/texture_copy_test.cc
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include <tvm/ffi/function.h>
+#include <tvm/runtime/device_api.h>
#include <tvm/runtime/logging.h>
#include <cmath>