-
Notifications
You must be signed in to change notification settings - Fork 1
generalize graph partitioning. #11
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
Conversation
reminisce
left a comment
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.
Have you run the unit test in test_subgraph_op.py?
| */ | ||
| void LabelSubgraph(const Graph&g, | ||
| const std::unordered_set<std::string>& op_names, | ||
| SubgraphSelectPtr selectFunc, |
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.
select_func
| if (simple_nodes[nid]->label == -1) { | ||
| node_queue.push(simple_nodes[nid].get()); | ||
| } else { | ||
| CHECK_EQ(simple_nodes[nid]->label, label); |
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.
This disallows adjacent subgraphs. Need to revisit this rule.
| */ | ||
| void FindSubgraphs(const Graph& g, | ||
| const std::unordered_set<std::string>& op_names, | ||
| const SubgraphProperty &subgProperty, |
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.
subgraph_prop
| for (size_t i = 0; i < simple_nodes.size(); ++i) { | ||
| nnvm::Node* node = simple_nodes[i]->node; | ||
| if (!node->is_variable() && simple_nodes[i]->label == -1 && op_names.count(node->op()->name)) { | ||
| auto selectFunc = subgProperty.CreateSubgraphSelect(); |
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.
select_func
| orig_entries->push_back(*e); | ||
| nnvm::Symbol sym; | ||
| sym.outputs.push_back(*e); | ||
| nnvm::NodePtr n = nnvm::CreateVariableNode(sym.ListOutputNames()[0]); |
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.
In order to reorder input entries of the subgraph op node, we need to keep the new variable node name the same as e->node->attrs.name+to_string(e.index). I can change this later.
src/operator/subgraph/subgraph_op.h
Outdated
| std::shared_ptr<const std::unordered_set<std::string>> op_names; | ||
|
|
||
| public: | ||
| ContainOpSelect(std::shared_ptr<const std::unordered_set<std::string>> op_names) { |
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.
Why shared_ptr?
src/operator/subgraph/subgraph_op.h
Outdated
| // execute the operators in the subgraph. | ||
| virtual nnvm::NodePtr GetSubgraphNode(const nnvm::Symbol &s) const = 0; | ||
| // Create a subgraph operator for execution. | ||
| virtual OpStatePtr CreateSubgraphOperator(const nnvm::Symbol &sym) const = 0; |
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.
CreateSubgraphOp
|
|
||
| public: | ||
| SimpleSubgraphProperty(const std::unordered_set<std::string> &op_names) { | ||
| this->op_names = std::make_shared<std::unordered_set<std::string>>(op_names); |
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.
Why shared_ptr?
src/operator/subgraph/subgraph_op.h
Outdated
| n->attrs.op = Op::Get("_subgraph_op"); | ||
| n->attrs.name = "_subgraph_op"; | ||
| n->attrs.dict.insert(std::pair<std::string, std::string>("exec_type", GetType())); | ||
| n->attrs.parsed = std::move(sym); |
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.
Do not move on a const reference.
src/operator/subgraph/subgraph_op.h
Outdated
| } | ||
| }; | ||
|
|
||
| using SubgraphSelectPtr = std::shared_ptr<SubgraphSelect>; |
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.
SubgraphSelectorPtr
| return ret; | ||
| } else { | ||
| using namespace sg; | ||
| SubgraphPropertyPtr subg_prop = g.GetAttr<SubgraphPropertyPtr>("subgraph_property"); |
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.
This should be const SubgraphProperty&.
| return OpStatePtr::Create<SubgraphOpState>(op); | ||
| } | ||
|
|
||
| std::string exec_name = it->second; |
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.
const std::string
| const std::vector<NDArray>& inputs, | ||
| const std::vector<OpReqType>& req, | ||
| const std::vector<NDArray>& outputs) { | ||
| // We can create an executor to run this subgraph op |
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.
I will change the implementation here to adopt CachedOp since we want to support varied batch size seamlessly.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
* add functions for cutting edges. * construct subgraphs. * generalize graph partition. * restructure the code. * create SubgraphOpState. * register subgraph property. * rename. * address comments. * update select API. * rename. * set subgraph property. * fix bugs. * fix bugs.
Description
(Brief description on what this PR is about)
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments