MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / replace_vars_comp_graph

Method replace_vars_comp_graph

src/core/impl/graph/helper.cpp:272–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272SymbolVarArray cg::replace_vars_comp_graph(
273 const SymbolVarArray& dest, ComputingGraph* new_graph) {
274 ComputingGraph* orig_graph = dest[0].node()->owner_graph();
275 mgb_assert(new_graph != orig_graph);
276 auto on_opr = [&](OperatorNodeBase* opr, gopt::SubGraph::Rewriter& rewriter) {
277 OperatorNodeBase* new_opr;
278 if (opr->input().size()) {
279 rewriter.auto_replace_outputs(opr);
280 } else {
281 mgb_assert(opr->owner_graph() != new_graph);
282 new_opr = serialization::copy_opr_shallow(
283 *opr, {}, opr->config(), {new_graph});
284 auto &&out0 = opr->output(), &&out1 = new_opr->output();
285 mgb_assert(out0.size() == out1.size());
286 for (size_t i = 0; i < out0.size(); ++i) {
287 rewriter.replace_var(out0[i], out1[i], "replace comp graph.");
288 }
289 }
290 };
291 return replace_vars_internal(dest, on_opr);
292}
293
294SymbolVarArray cg::find_h2d(const SymbolVarArray& dest) {
295 mgb_assert(!dest.empty());

Callers

nothing calls this directly

Calls 8

replace_vars_internalFunction · 0.85
owner_graphMethod · 0.45
nodeMethod · 0.45
sizeMethod · 0.45
inputMethod · 0.45
auto_replace_outputsMethod · 0.45
outputMethod · 0.45
replace_varMethod · 0.45

Tested by

no test coverage detected