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

Method find_h2d

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

Source from the content-addressed store, hash-verified

292}
293
294SymbolVarArray cg::find_h2d(const SymbolVarArray& dest) {
295 mgb_assert(!dest.empty());
296 SymbolVarArray h2d;
297 auto on_opr = [&](OperatorNodeBase* opr) {
298 if (opr->same_type<opr::Host2DeviceCopy>()) {
299 h2d.emplace_back(opr->output(0));
300 }
301 };
302
303 // check that they belong to the same graph
304 mgb_assert(dest[0].node());
305 auto og = dest[0].node()->owner_graph();
306 for (auto i : dest) {
307 mgb_assert(i.node() && i.node()->owner_graph() == og);
308 }
309
310 auto dest_with_extra_deps = get_dest_vars_with_extra_deps(dest);
311
312 gopt::SubGraph graph{dest_with_extra_deps};
313 graph.iter([&](OperatorNodeBase* opr) { on_opr(opr); });
314
315 return h2d;
316}
317
318OperatorNodeBase* cg::get_opr_root_source_opr(OperatorNodeBase* opr) {
319 auto&& attr = opr->node_prop().attribute();

Callers

nothing calls this directly

Calls 6

emplace_backMethod · 0.80
emptyMethod · 0.45
outputMethod · 0.45
nodeMethod · 0.45
owner_graphMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected