Skip to content

[REFACTOR] Phase out include/tvm/runtime/module.h#19441

Merged
spectrometerHBH merged 1 commit into
apache:mainfrom
tqchen:phase-out-runtime-module-h
Apr 25, 2026
Merged

[REFACTOR] Phase out include/tvm/runtime/module.h#19441
spectrometerHBH merged 1 commit into
apache:mainfrom
tqchen:phase-out-runtime-module-h

Conversation

@tqchen

@tqchen tqchen commented Apr 25, 2026

Copy link
Copy Markdown
Member

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/.

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/`.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 spectrometerHBH merged commit fe0e8cb into apache:main Apr 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants