-
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
[RFC][RUNTIME] Introduce new object protocol. #4115
Conversation
cc @jroesch @icemelon9 @junrushao1994 @zhiics @jermainewang |
80d9573
to
f8f6f50
Compare
This PR introduces a new object protocol to unify the node and object. We also updated the existing runtime::vm code to make use of the new system. Update to the node will be done in a follow up PR. Other changes: - Remove object related code in json serializer as that code logic was not complete and we have a separate serializer for VM, can revisit later.
@junrushao1994 @icemelon9 @yzh119 can you help review this PR? |
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.
Thanks for this protocol. It will greatly reduce developers's effort to add a new runtime object so that it can interoperate between python and c++.
So currently we have Object/ObjectRef
and Node/NodeRef
and we are gonna migrate Node system to Object since it's more generic, right?
* the type index will be assigned during runtime. | ||
* Runtime type index can be accessed by ObjectType::type_index(); | ||
* - _type_key: | ||
* The unique string identifier of tyep type. |
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.
typo: tyep
include/tvm/runtime/object.h
Outdated
* - Use TVM_DECLARE_FINAL_OBJECT_INFO for object classes that cannot be sub-classed. | ||
* | ||
* New objects can be created using make_object function. | ||
* Which will automatically populate the type_index and deleterof the object. |
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.
s/deleterof/deleter of
include/tvm/runtime/object.h
Outdated
|
||
protected: | ||
// The fields of the base object cell. | ||
/*! \brief Type index(tag) that indicate the type of the object. */ |
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.
s/indicate/indicates
include/tvm/runtime/object.h
Outdated
* When the function is first time called for a type, | ||
* it will register the type to the type table in the runtime. | ||
* If the static_tindex is TypeIndex::kDynamic, the function will | ||
* will allocate a runtime type index. |
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.
s/will//
include/tvm/runtime/object.h
Outdated
class ObjectRef { | ||
public: | ||
/*! \brief default constructor */ | ||
ObjectRef() = default; |
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.
ObjectRef() = default; | |
ObjectRef() = default; |
size_t tag; | ||
/*! \brief The fields of the structure. */ | ||
std::vector<Object> fields; | ||
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName) \ |
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.
align ""
TVM_REGISTER_OBJECT_TYPE(ObjBase); | ||
TVM_REGISTER_OBJECT_TYPE(ObjA); | ||
TVM_REGISTER_OBJECT_TYPE(ObjB); | ||
TVM_REGISTER_OBJECT_TYPE(ObjAA); |
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.
TVM_DECLARE_FINAL_OBJECT_INFO? just to have a test for final object as well.
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.
good point
Yes, the goal is to migrate noderef/node to be subclass of object/objectref. The migration needs to take a few steps to complete |
ping @zhiics for another round of review |
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
@tqchen thanks. This is now merged. |
* [RUNTIME] Introduce new object protocol. This PR introduces a new object protocol to unify the node and object. We also updated the existing runtime::vm code to make use of the new system. Update to the node will be done in a follow up PR. Other changes: - Remove object related code in json serializer as that code logic was not complete and we have a separate serializer for VM, can revisit later. * address review comment * Fix the child slot logic
* [RUNTIME] Introduce new object protocol. This PR introduces a new object protocol to unify the node and object. We also updated the existing runtime::vm code to make use of the new system. Update to the node will be done in a follow up PR. Other changes: - Remove object related code in json serializer as that code logic was not complete and we have a separate serializer for VM, can revisit later. * address review comment * Fix the child slot logic
* master: (51 commits) [QNN][TFLite] Parsing QNN Add op. Adding MobilenetV2. (apache#4142) [CI] Pin NNPack pthreadtools version (apache#4152) Fix typo (apache#4144) [Relay][Frontend][TF] Add tensor array ops (apache#3798) [relay][vm] Separate VM runtime with executable (apache#4100) [PATCH] Fix undefined __floatdihf in libtvmruntime.so on aarch64. (apache#4119) [DOCKER] Pin torchvision==0.4.1 (apache#4140) [TOPI][x86] Cascade lake support. (apache#4123) [Relay] Improve build error when no lowered funcs are produced (apache#4132) [RUNTIME] Refactor object python FFI to new protocol. (apache#4128) Update PULL_REQUEST_TEMPLATE.md Adding support for dequantizing from int32 to float32. (apache#4130) [Relay][Training] Add and fix gradients (apache#4126) [QNN] Change default rouning to UPWARD. (apache#4131) Fix infer type of kernel in dense. (apache#4125) [Relay][AlterOpLayout] NHWC to NCHWc pad operator. (apache#4103) [ARITH] Fix lowering of floormod(x, y) != 0 (apache#4127) [RFC][RUNTIME] Introduce new object protocol. (apache#4115) [Relay][Topi] Disable conv NHWC pack int8. (apache#4038) Update task_cpp_unittest.sh ...
This PR introduces a new object protocol to unify the node and object.
We also updated the existing runtime::vm code to make use of the new system.
Update to the node will be done in a follow-up PR.
Other changes:
and we have a separate serializer for VM, can revisit later.
Terminology
Improvement over Node and old Object System