Skip to content

Conversation

@zheng-da
Copy link

Description

(Brief description on what this PR is about)

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Feature1, tests, (and when applicable, API doc)
  • Feature2, tests, (and when applicable, API doc)

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

Copy link
Owner

@reminisce reminisce left a 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,
Copy link
Owner

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);
Copy link
Owner

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,
Copy link
Owner

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();
Copy link
Owner

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]);
Copy link
Owner

@reminisce reminisce May 31, 2018

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.

std::shared_ptr<const std::unordered_set<std::string>> op_names;

public:
ContainOpSelect(std::shared_ptr<const std::unordered_set<std::string>> op_names) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why shared_ptr?

// 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;
Copy link
Owner

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);
Copy link
Owner

Choose a reason for hiding this comment

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

Why shared_ptr?

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);
Copy link
Owner

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.

}
};

using SubgraphSelectPtr = std::shared_ptr<SubgraphSelect>;
Copy link
Owner

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");
Copy link
Owner

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;
Copy link
Owner

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
Copy link
Owner

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.

@reminisce reminisce merged commit 2f65d64 into reminisce:subgraph_op Jun 1, 2018
reminisce pushed a commit that referenced this pull request Jun 6, 2018
* 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.
reminisce pushed a commit that referenced this pull request Jun 6, 2018
* 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.
reminisce pushed a commit that referenced this pull request Jun 8, 2018
* 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.
reminisce pushed a commit that referenced this pull request Jun 9, 2018
* 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.
reminisce pushed a commit that referenced this pull request Jun 13, 2018
* 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.
reminisce pushed a commit that referenced this pull request Jun 20, 2018
* 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.
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.

2 participants