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

Function dimshuffle_rule

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

Source from the content-addressed store, hash-verified

180}
181
182ValueRefList 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
198ValueRef convert_nchw2nhwc_tensornd(const HostTensorND& shape) {
199 mgb_assert(shape.layout().total_nr_elems() == 4);

Callers

nothing calls this directly

Calls 9

wrap_outputsMethod · 0.80
scopeMethod · 0.80
unwrap_inputsMethod · 0.80
applyFunction · 0.50
makeFunction · 0.50
sizeMethod · 0.45
castMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected