Skip to content
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

Merged
merged 2 commits into from
Jan 7, 2020

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Jan 6, 2020

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.

@tqchen
Copy link
Member Author

tqchen commented Jan 6, 2020

cc @comaniac @zhiics @wweic @yzhliu @ZihengJiang @FrozenGene

NOTE: the macros are also useful for bring your own backend codegen

@comaniac
Copy link
Contributor

comaniac commented Jan 6, 2020

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.
Copy link
Member

@zhiics zhiics left a 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.

@@ -877,6 +894,104 @@ class TVMRetValue : public TVMPODValue_ {
}
};

/*!
* \brief Export a function with the PackedFunc signature
* as a PackedFunc that can loaded by LibraryModule.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* as a PackedFunc that can loaded by LibraryModule.
* as a PackedFunc that can be loaded by LibraryModule.


/*!
* \brief Export typed function as a PackedFunc
* that can loaded by LibraryModule.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* that can loaded by LibraryModule.
* that can loaded be by LibraryModule.

Copy link
Contributor

@wweic wweic left a comment

Choose a reason for hiding this comment

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

lgtm.

apps/dso_plugin_module/test_plugin_module.py Outdated Show resolved Hide resolved
@tqchen tqchen merged commit 77c4774 into apache:master Jan 7, 2020
@tqchen
Copy link
Member Author

tqchen commented Jan 7, 2020

Thanks @wweic @ZihengJiang @zhiics

alexwong pushed a commit to alexwong/tvm that referenced this pull request Feb 26, 2020
…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
alexwong pushed a commit to alexwong/tvm that referenced this pull request Feb 28, 2020
…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
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Mar 2, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants