-
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
[REFACTOR][NODE][RUNTIME] Move Node to the new Object protocol. #4161
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,9 +47,10 @@ using ::tvm::AttrVisitor; | |
*/ | ||
#define TVM_DEFINE_NODE_REF_METHODS(TypeName, BaseTypeName, NodeName) \ | ||
TypeName() {} \ | ||
explicit TypeName(::tvm::NodePtr<::tvm::Node> n) : BaseTypeName(n) {} \ | ||
explicit TypeName(::tvm::ObjectPtr<::tvm::Object> n) \ | ||
: BaseTypeName(n) {} \ | ||
const NodeName* operator->() const { \ | ||
return static_cast<const NodeName*>(node_.get()); \ | ||
return static_cast<const NodeName*>(data_.get()); \ | ||
} \ | ||
operator bool() const { return this->defined(); } \ | ||
using ContainerType = NodeName; | ||
|
@@ -75,12 +76,12 @@ using ::tvm::AttrVisitor; | |
*/ | ||
#define TVM_DEFINE_NODE_REF_COW(NodeName) \ | ||
NodeName* CopyOnWrite() { \ | ||
CHECK(node_ != nullptr); \ | ||
if (!node_.unique()) { \ | ||
CHECK(data_ != nullptr); \ | ||
if (!data_.unique()) { \ | ||
NodePtr<NodeName> n = make_node<NodeName>(*(operator->())); \ | ||
NodePtr<Node>(std::move(n)).swap(node_); \ | ||
ObjectPtr<Object>(std::move(n)).swap(data_); \ | ||
} \ | ||
return static_cast<NodeName*>(node_.get()); \ | ||
return static_cast<NodeName*>(data_.get()); \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get_mutable() |
||
} | ||
|
||
/*! \brief Macro to make it easy to define node ref type given node */ | ||
|
@@ -160,7 +161,7 @@ std::string SaveJSON(const NodeRef& node); | |
* | ||
* \return The shared_ptr of the Node. | ||
*/ | ||
NodePtr<Node> LoadJSON_(std::string json_str); | ||
ObjectPtr<Object> LoadJSON_(std::string json_str); | ||
|
||
/*! | ||
* \brief Load the node from json string. | ||
|
@@ -233,6 +234,7 @@ struct NodeFactoryReg { | |
* \note This is necessary to enable serialization of the Node. | ||
*/ | ||
#define TVM_REGISTER_NODE_TYPE(TypeName) \ | ||
TVM_REGISTER_OBJECT_TYPE(TypeName); \ | ||
static DMLC_ATTRIBUTE_UNUSED ::tvm::NodeFactoryReg & __make_Node ## _ ## TypeName ## __ = \ | ||
::tvm::NodeFactoryReg::Registry()->__REGISTER__(TypeName::_type_key) \ | ||
.set_creator([](const std::string&) { return ::tvm::make_node<TypeName>(); }) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
get()