| 519 | } |
| 520 | |
| 521 | CompNode 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 | |
| 552 | void mixin::SingleCNOperatorNode::mixin_comp_node( |
| 553 | OperatorNodeBase& opr, CompNode node) { |