| 180 | } |
| 181 | |
| 182 | ValueRefList dimshuffle_rule( |
| 183 | const Dimshuffle& op, Span<ValueRef>& inputs, const bool& auto_convert, |
| 184 | const FormatTransformation& t) { |
| 185 | mgb_assert(inputs.size() == 1); |
| 186 | auto& src = inputs[0].cast(t.value_type()); |
| 187 | // Only support converting pattern from NCHW to NHWC currently. |
| 188 | if (auto_convert && src.format() == FT::NHWC) { |
| 189 | auto pattern = convert_nchw2nhwc_pattern(op.pattern); |
| 190 | // dimshuffle will not maintain NHWC Format |
| 191 | return t.wrap_outputs(imperative::apply( |
| 192 | *Dimshuffle::make(std::move(pattern), op.scope()), |
| 193 | t.unwrap_inputs(inputs))); |
| 194 | } |
| 195 | return t.wrap_outputs(imperative::apply(op, t.unwrap_inputs(inputs))); |
| 196 | } |
| 197 | |
| 198 | ValueRef convert_nchw2nhwc_tensornd(const HostTensorND& shape) { |
| 199 | mgb_assert(shape.layout().total_nr_elems() == 4); |
nothing calls this directly
no test coverage detected