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

[REFACTOR][Relay] Migrate Id ObjectRef to not-null #5748

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[REFACTOR][Relay] Migrate Id ObjectRef to not-null
ANSHUMAN TRIPATHY authored and ANSHUMAN TRIPATHY committed Jun 8, 2020
commit 9ad1610856f6d8ec0cd5cbcfa0cfc74535d652ee
2 changes: 1 addition & 1 deletion include/tvm/relay/base.h
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ class Id : public ObjectRef {
*/
TVM_DLL explicit Id(String name_hint);

TVM_DEFINE_OBJECT_REF_METHODS(Id, ObjectRef, IdNode);
TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(Id, ObjectRef, IdNode);
};

} // namespace relay
3 changes: 3 additions & 0 deletions include/tvm/relay/expr.h
Original file line number Diff line number Diff line change
@@ -152,6 +152,9 @@ class Var;
/*! \brief Container for Var */
class VarNode : public ExprNode {
public:
VarNode(Id vid, Type type_annotation) : vid(vid), type_annotation(type_annotation) {}
VarNode() : vid("") {}
Copy link
Member

Choose a reason for hiding this comment

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

The not-null that involves composite objects are more complicated and this is not necessarily the best approach, let us wait a bit before we find a better solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The not-null that involves composite objects are more complicated and this is not necessarily the best approach, let us wait a bit before we find a better solution

@tqchen : Thanks! I also felt that this is not best way. We might have to change Node registration framework i believe. Will wait for your future guidance!


/*!
* \brief The unique identifier of the Var.
*
4 changes: 1 addition & 3 deletions src/relay/ir/expr.cc
Original file line number Diff line number Diff line change
@@ -82,9 +82,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
});

Var::Var(Id vid, Type type_annotation) {
ObjectPtr<VarNode> n = make_object<VarNode>();
n->vid = std::move(vid);
n->type_annotation = std::move(type_annotation);
ObjectPtr<VarNode> n = make_object<VarNode>(vid, type_annotation);
data_ = std::move(n);
}