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

Method mixin_infer_output_comp_node

src/core/impl/graph/operator_node.cpp:521–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521CompNode mixin::SingleCNOperatorNode::mixin_infer_output_comp_node(
522 const OperatorNodeBase& opr, bool cross_mem) {
523 CompNode cn = opr.config().get_single_comp_node();
524 bool infer_from_input = !cn.valid();
525 for (auto&& i : opr.input()) {
526 CompNode cur = i->comp_node();
527 if (infer_from_input && !cn.valid())
528 cn = cur;
529 if (!cross_mem) {
530 mgb_assert(
531 cn.mem_node() == cur.mem_node(),
532 "opr %s{%s} requires all input to be on the same memory "
533 "node of its output; expect=%s cur_var=%s cur_cn=%s",
534 opr.cname(), opr.dyn_typeinfo()->name, cn.to_string().c_str(),
535 i->cname(), cur.to_string().c_str());
536 }
537 if (infer_from_input) {
538 mgb_assert(
539 cn == cur,
540 "comp_node of opr %s{%s} should be inferred from input, "
541 "but different input comp_nodes found: %s vs %s",
542 opr.cname(), opr.dyn_typeinfo()->name, cn.to_string().c_str(),
543 cur.to_string().c_str());
544 }
545 }
546 mgb_throw_if(
547 !cn.valid(), GraphError, "could not infer comp node for opr %s{%s}",
548 opr.cname(), opr.dyn_typeinfo()->name);
549 return cn;
550}
551
552void mixin::SingleCNOperatorNode::mixin_comp_node(
553 OperatorNodeBase& opr, CompNode node) {

Callers

nothing calls this directly

Calls 7

get_single_comp_nodeMethod · 0.80
validMethod · 0.45
inputMethod · 0.45
comp_nodeMethod · 0.45
mem_nodeMethod · 0.45
cnameMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected