You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/09/06 17:56:53 UTC
[GitHub] [incubator-mxnet] HahTK edited a comment on issue #16108: Subgraph
API creates duplicate inputs and outputs
HahTK edited a comment on issue #16108: Subgraph API creates duplicate inputs and outputs
URL: https://github.com/apache/incubator-mxnet/issues/16108#issuecomment-528951277
Two things to add :
1. A temporary fix has been tested for fixing the output duplication. (code below)
This fix fits things into the current function signatures and had to redo similar computation in 2 spot
2. A better fix would be to introduce a map for output_entries and input_entries to allow 1-many and many-1 mappings between the subgraph and the maingraph. Conceptually, similar with the fix in (1)
Code :
src/operator/subgraph/partition_graph.cc:CreateSubgraphNode()
nnvm::Symbol sym;
nnvm::NodeEntryEqual node_equal;
size_t idx = 0;
sym.outputs.resize(output_entries.size());
//only add to output_entries to sym.outputs
//relies on output_entries being pre-sorted
for (size_t i = 0; i < output_entries.size(); ++i) {
if (0 == i) {
sym.outputs[idx] = *output_entries[i];
} else {
if (!node_equal(*output_entries[i-1], *output_entries[i])) {
idx++;
sym.outputs[idx] = *output_entries[i];
} //else skip over dupe entry
}
}
sym.outputs.resize(idx+1);
In src/operator/subgraph/subgraph_property.h : ConnectSubgraphOutputs()
nnvm::NodeEntryEqual node_equal;
nnvm::NodeEntry prevNodeEntry;
uint32_t idx = 0;
//increment NodeEntry index only if the output_entrie is unique
for (size_t i = 0; i < output_entries->size(); ++i) {
if (0 != i ) {
if (!node_equal(prevNodeEntry, *output_entries->at(i))) {
idx++;
}
}
prevNodeEntry = *output_entries->at(i); //need a copy
*output_entries->at(i) = nnvm::NodeEntry{subgraph_node, idx, 0};
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services