larroy commented on a change in pull request #11641: [WIP] make CachedOp a 
normal operator
URL: https://github.com/apache/incubator-mxnet/pull/11641#discussion_r201622787
 
 

 ##########
 File path: src/c_api/c_api_symbolic.cc
 ##########
 @@ -366,6 +367,36 @@ int MXSymbolGetInputSymbols(SymbolHandle sym, 
SymbolHandle **input_arr, int *inp
   API_END_HANDLE_ERROR();
 }
 
+int MXMakeSubgraph(SymbolHandle sym, SymbolHandle *input_symbols, mx_uint 
num_inputs,
+                   SymbolHandle *out) {
+  API_BEGIN();
+  nnvm::Symbol *s = static_cast<nnvm::Symbol*>(sym);
+  CHECK_EQ(s->ListInputs(nnvm::Symbol::kAll).size(), num_inputs)
+      << "The number of inputs needs to match the inputs in the subgraph";
+
+  // Construct a node for this subgraph.
+  std::vector<nnvm::NodeEntry> inputs(num_inputs);
+  for (size_t i = 0; i < inputs.size(); i++) {
+    nnvm::Symbol *s = static_cast<nnvm::Symbol*>(input_symbols[i]);
+    CHECK_EQ(s->outputs.size(), 1U) << "The input symbol should have one 
output";
+    inputs[i] = s->outputs[0];
+  }
+  nnvm::NodeEntry entry = nnvm::MakeNode("_CachedOp", "_CachedOp", inputs);
+  nnvm::NodePtr n = entry.node;
+
+  // Create CachedOp for the node.
+  std::vector<std::pair<std::string, std::string> > kwargs;
+  kwargs.push_back(std::pair<std::string, std::string>("inline_limit", "0"));
 
 Review comment:
   Why not emplace back? More efficient and less noisy...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to