Skip to content

Conversation

@junrushao
Copy link
Member

This PR introduces a series of macros as part of TVM's runtime::Module-based calling convention.

TVM_MODULE_VTABLE_BEGIN(TypeKey);
TVM_MODULE_VTABLE_ENTRY(Name, MemFunc);
TVM_MODULE_VTABLE_ENTRY_PACKED(Name, Func);
TVM_MODULE_VTABLE_END();

This way, one could conveniently define the callable symbols a TVM Module exposes, for example, runtime::relax_vm::Exectuable, by looking at the vtable below:

TVM_MODULE_VTABLE_BEGIN("VMExecutable"); // type key
TVM_MODULE_VTABLE_ENTRY("get_lib", &Executable::GetLib); // const member functions
...
TVM_MODULE_VTABLE_ENTRY_PACKED("vm_load_executable", Executable::Load); // non-member functions
TVM_MODULE_VTABLE_ENTRY("move_late_bound_consts", &Executable::MoveLateBoundConstantsToFile); // mutable member function
TVM_MODULE_VTABLE_END();

@junrushao junrushao marked this pull request as ready for review November 1, 2023 07:45
@junrushao
Copy link
Member Author

CC @Lunderberg @MasterJH5574 if you guys are interested

@junrushao junrushao force-pushed the feature/2023-11-01/module-vtable branch 4 times, most recently from c999b7f to e34ccce Compare November 1, 2023 18:57
This PR introduces a series of macros as part of TVM's
runtime::Module-based calling convention.

```C++
TVM_MODULE_VTABLE_BEGIN(TypeKey);
TVM_MODULE_VTABLE_ENTRY(Name, MemFunc);
TVM_MODULE_VTABLE_ENTRY_PACKED(Name, Func);
TVM_MODULE_VTABLE_END();
```

This way, one could conveniently define the callable symbols a TVM
Module exposes, for example, `runtime::relax_vm::Exectuable`, by
looking at the vtable below:

```C++
TVM_MODULE_VTABLE_BEGIN("VMExecutable"); // type key
TVM_MODULE_VTABLE_ENTRY("get_lib", &Executable::GetLib); // const member functions
...
TVM_MODULE_VTABLE_ENTRY_PACKED("vm_load_executable", Executable::Load); // non-member functions
TVM_MODULE_VTABLE_ENTRY("move_late_bound_consts", &Executable::MoveLateBoundConstantsToFile); // mutable member function
TVM_MODULE_VTABLE_END();
```
@junrushao junrushao force-pushed the feature/2023-11-01/module-vtable branch from e34ccce to a0c3edd Compare November 1, 2023 20:44
@junrushao junrushao merged commit bd3e8bb into apache:main Nov 2, 2023
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