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][REFACTOR] Use object protocol to support runtime::Module #4289

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Nov 9, 2019

Previously runtime::Module was supported using shared_ptr.
This PR refactors the codebase to use the Object protocol.

It will open doors to allow easier interpolation between
Object containers and module in the future.

RFC #4286

@tqchen
Copy link
Member Author

tqchen commented Nov 9, 2019

cc @jroesch @junrushao1994 @yzhliu

@junrushao
Copy link
Member

Will do this Sunday

@tqchen tqchen force-pushed the object branch 4 times, most recently from 89eaafd to 75ddf51 Compare November 9, 2019 20:54
@@ -71,7 +70,11 @@ class Module {
* \note Cyclic dependency is not allowed among modules,
* An error will be thrown when cyclic dependency is detected.
*/
TVM_DLL void Import(Module other);
Copy link
Member

Choose a reason for hiding this comment

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

Do we intentionally remove the TVM_DLL here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The DLL function was moved to the Node class

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

This PR migrates tvm::runtime::Module from std::shared_ptr to the new TVM object protocol. The advantage of unifying this is obvious - no need to say.

One possible issue is that it introduces an internal header src/runtime/ffi_utils.h. The naming is somewhat vague...and why not simply put those 3 functions into include/tvm/runtime/object.h?

@tqchen
Copy link
Member Author

tqchen commented Nov 11, 2019

The main reason for the ffi_util.h is to keep these functionalities internal, as we do not want to expose these protected field of objects in most cases.

@junrushao
Copy link
Member

@tqchen The use case of the class FFIUtil makes sense to me now, but I think it would be great to have a better name to demonstrate its use case. What about something like ObjectInternal?

@tqchen
Copy link
Member Author

tqchen commented Nov 11, 2019

I thought a bit about Object::Internal, but eventually chose the name FFIUtil because it also has a name for runtime::Module.

@tqchen
Copy link
Member Author

tqchen commented Nov 11, 2019

after thinking a bit more, i agree that ObjectInternal could indeed be a better name, I just pushed a change to do the rename, thanks @junrushao1994

Previously runtime::Module was supported using shared_ptr.
This PR refactors the codebase to use the Object protocol.

It will open doors to allow easier interpolation between
Object containers and module in the future.
Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

LGTM

@tqchen
Copy link
Member Author

tqchen commented Nov 11, 2019

ping @yzhliu

Copy link
Contributor

@ZihengJiang ZihengJiang left a comment

Choose a reason for hiding this comment

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

LGTM

@tqchen tqchen merged commit f823c57 into apache:master Nov 11, 2019
zxy844288792 pushed a commit to neo-ai/tvm that referenced this pull request Nov 13, 2019
…pache#4289)

Previously runtime::Module was supported using shared_ptr.
This PR refactors the codebase to use the Object protocol.

It will open doors to allow easier interpolation between
Object containers and module in the future.
tqchen added a commit to tqchen/tvm that referenced this pull request Mar 29, 2020
…pache#4289)

Previously runtime::Module was supported using shared_ptr.
This PR refactors the codebase to use the Object protocol.

It will open doors to allow easier interpolation between
Object containers and module in the future.
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.

4 participants