[REFACTOR] Phase out include/tvm/runtime/module.h#19441
Merged
Conversation
This PR phases out `include/tvm/runtime/module.h` by relocating its three
remaining responsibilities to where they're actually used. 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).
Main changes:
- `details::ModuleVTableEntryHelper` plus the `TVM_MODULE_VTABLE_*` macros
move to a new private header `src/runtime/vm/module_utils.h`. The helper
is now in `tvm::runtime::vm::details` to reflect its VM-only audience.
- `RuntimeEnabled` and `namespace symbol { tvm_set_device,
tvm_global_barrier_state, tvm_prepare_global_barrier }` move to
`include/tvm/runtime/device_api.h`, the natural home for device-side
runtime hooks.
- `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/`.
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the TVM runtime module system by transitioning from tvm::runtime::Module to tvm::ffi::Module. Key changes include updating numerous include paths from tvm/runtime/module.h to tvm/ffi/extra/module.h, migrating core module declarations to tvm/runtime/device_api.h, and refactoring VMExecutable to implement the new FFI-based module interface. Additionally, internal VM module utilities were moved to a private header. I have no feedback to provide.
spectrometerHBH
approved these changes
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
include/tvm/runtime/module.hhad accumulated three unrelated responsibilities; this PRrelocates each of them and removes the header. C++ callers now include either
<tvm/ffi/extra/module.h>(forffi::Module) or<tvm/runtime/device_api.h>(forRuntimeEnabledand the runtimesymbol::*constants), depending on what they actually use.Changes
details::ModuleVTableEntryHelperand theTVM_MODULE_VTABLE_*macros move to a newprivate header
src/runtime/vm/module_utils.h(intvm::runtime::vm::details) sincethey are only used by VM modules.
RuntimeEnabledandnamespace symbol { tvm_set_device, tvm_global_barrier_state, tvm_prepare_global_barrier }move toinclude/tvm/runtime/device_api.h.VMExecutable::kindandVMExecutable::GetFunctionare now declared in the publicheader and defined out-of-line in
executable.cc, so the vtable macros stay private tosrc/runtime/vm/.