-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RUNTIME][DSO] Improve TVMBackendPackedCFunc to allow return val #4637
Conversation
cc @comaniac @zhiics @wweic @yzhliu @ZihengJiang @FrozenGene NOTE: the macros are also useful for bring your own backend codegen |
Thanks for the PR. The macros are indeed helpful for customized runtimes and can reduce the developer efforts. I'll file another PR to make use of them in this example after this one have been merged. The change are LGTM. Since I may not be aware of some concerns in backend APIs, I am leaving it for others. btw, you may need to fix the failed cases in CI. |
Previously the signature of LibraryModule's PackedFunc does not support return value. This wasn't a limitation for our current usecase but could become one as we start to generate more interesting functions. This feature also start to get interesting as we move towards unified object protocol and start to pass object around. This PR enhances the function signature to allow return values. We also created two macros TVM_DLL_EXPORT_PACKED_FUNC and TVM_DLL_EXPORT_TYPED_FUNC to allow manual creation of functions that can be loaded by a LibraryModule. Examples are added in apps/dso_plugin_module. The change to TVMBackendPackedCFunc is backward compatible, as previous function will simply ignore the return value field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tqchen Thanks for the PR. This is very helpful for small ops and it can work like currying functions. Only a few nitpicks.
include/tvm/runtime/packed_func.h
Outdated
@@ -877,6 +894,104 @@ class TVMRetValue : public TVMPODValue_ { | |||
} | |||
}; | |||
|
|||
/*! | |||
* \brief Export a function with the PackedFunc signature | |||
* as a PackedFunc that can loaded by LibraryModule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* as a PackedFunc that can loaded by LibraryModule. | |
* as a PackedFunc that can be loaded by LibraryModule. |
include/tvm/runtime/packed_func.h
Outdated
|
||
/*! | ||
* \brief Export typed function as a PackedFunc | ||
* that can loaded by LibraryModule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* that can loaded by LibraryModule. | |
* that can loaded be by LibraryModule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Thanks @wweic @ZihengJiang @zhiics |
…che#4637) * [RUNTIME][DSO] Improve TVMBackendPackedCFunc to allow return value. Previously the signature of LibraryModule's PackedFunc does not support return value. This wasn't a limitation for our current usecase but could become one as we start to generate more interesting functions. This feature also start to get interesting as we move towards unified object protocol and start to pass object around. This PR enhances the function signature to allow return values. We also created two macros TVM_DLL_EXPORT_PACKED_FUNC and TVM_DLL_EXPORT_TYPED_FUNC to allow manual creation of functions that can be loaded by a LibraryModule. Examples are added in apps/dso_plugin_module. The change to TVMBackendPackedCFunc is backward compatible, as previous function will simply ignore the return value field. * address review comments
…che#4637) * [RUNTIME][DSO] Improve TVMBackendPackedCFunc to allow return value. Previously the signature of LibraryModule's PackedFunc does not support return value. This wasn't a limitation for our current usecase but could become one as we start to generate more interesting functions. This feature also start to get interesting as we move towards unified object protocol and start to pass object around. This PR enhances the function signature to allow return values. We also created two macros TVM_DLL_EXPORT_PACKED_FUNC and TVM_DLL_EXPORT_TYPED_FUNC to allow manual creation of functions that can be loaded by a LibraryModule. Examples are added in apps/dso_plugin_module. The change to TVMBackendPackedCFunc is backward compatible, as previous function will simply ignore the return value field. * address review comments
…che#4637) * [RUNTIME][DSO] Improve TVMBackendPackedCFunc to allow return value. Previously the signature of LibraryModule's PackedFunc does not support return value. This wasn't a limitation for our current usecase but could become one as we start to generate more interesting functions. This feature also start to get interesting as we move towards unified object protocol and start to pass object around. This PR enhances the function signature to allow return values. We also created two macros TVM_DLL_EXPORT_PACKED_FUNC and TVM_DLL_EXPORT_TYPED_FUNC to allow manual creation of functions that can be loaded by a LibraryModule. Examples are added in apps/dso_plugin_module. The change to TVMBackendPackedCFunc is backward compatible, as previous function will simply ignore the return value field. * address review comments
Previously the signature of LibraryModule's PackedFunc does not support return value.
This wasn't a limitation for our current usecase but could become one
as we start to generate more interesting functions.
This feature will start to get interesting as we move towards unified
object protocol and start to pass object around.
This PR enhances the function signature to allow return values.
We also created two macros TVM_DLL_EXPORT_PACKED_FUNC and TVM_DLL_EXPORT_TYPED_FUNC
to allow manual creation of functions that can be loaded by a LibraryModule.
Examples are added in apps/dso_plugin_module.
The change to TVMBackendPackedCFunc is backward compatible,
as previous function will simply ignore the return value field.