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

Function concat_rule

imperative/src/impl/transformations/format.cpp:483–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483ValueRefList concat_rule(
484 const Concat& op, Span<ValueRef>& inputs, const bool& auto_convert,
485 const FormatTransformation& t) {
486 FT format = get_inputs_format(inputs, t);
487 if (!(format == FT::NHWC && auto_convert)) {
488 return t.wrap_outputs(imperative::apply(op, t.unwrap_inputs(inputs)), format);
489 }
490 ValueRefList unified_inputs(inputs.size());
491 for (size_t i = 0; i < inputs.size(); ++i) {
492 auto&& inp = inputs[i].cast(t.value_type());
493 if (inp.format() != FT::NHWC && inp.value().is_scalar()) {
494 unified_inputs[i] = t.value_type().make(inp.value(), FT::NHWC);
495 } else {
496 unified_inputs[i] = inputs[i];
497 }
498 }
499 unified_inputs = unify_inputs_format(unified_inputs, FT::NHWC, op.scope(), t);
500 // TODO: handle 5D NHWC Tensor from group conv
501 auto axis = op.axis;
502 if (axis == 2 || axis == 3) {
503 axis = axis - 1;
504 } else if (axis == 1) {
505 axis = 3;
506 }
507 return t.wrap_outputs(
508 imperative::apply(
509 *Concat::make(axis, op.comp_node, op.scope()),
510 t.unwrap_inputs(unified_inputs)),
511 format);
512}
513
514ValueRefList identity_rule_helper(
515 const OpDef& op, const Span<ValueRef>& inputs, const FormatTransformation& t) {

Callers

nothing calls this directly

Calls 13

get_inputs_formatFunction · 0.85
unify_inputs_formatFunction · 0.85
wrap_outputsMethod · 0.80
unwrap_inputsMethod · 0.80
scopeMethod · 0.80
applyFunction · 0.50
makeFunction · 0.50
sizeMethod · 0.45
castMethod · 0.45
formatMethod · 0.45
is_scalarMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected