| 481 | } |
| 482 | |
| 483 | ValueRefList 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 | |
| 514 | ValueRefList identity_rule_helper( |
| 515 | const OpDef& op, const Span<ValueRef>& inputs, const FormatTransformation& t) { |
nothing calls this directly
no test coverage detected