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

Function elemwise_rule

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

Source from the content-addressed store, hash-verified

460}
461
462ValueRefList elemwise_rule(
463 const Elemwise& op, Span<ValueRef>& inputs, const bool& auto_convert,
464 const FormatTransformation& t) {
465 FT format = get_inputs_format(inputs, t);
466 if (format == FT::NHWC && auto_convert) {
467 ValueRefList unified_inputs(inputs.size());
468 for (size_t i = 0; i < inputs.size(); ++i) {
469 auto&& inp = inputs[i].cast(t.value_type());
470 if (inp.format() != FT::NHWC && inp.value().is_scalar()) {
471 unified_inputs[i] = t.value_type().make(inp.value(), FT::NHWC);
472 } else {
473 unified_inputs[i] = inputs[i];
474 }
475 }
476 unified_inputs = unify_inputs_format(unified_inputs, FT::NHWC, op.scope(), t);
477 return t.wrap_outputs(
478 imperative::apply(op, t.unwrap_inputs(unified_inputs)), format);
479 }
480 return t.wrap_outputs(imperative::apply(op, t.unwrap_inputs(inputs)), format);
481}
482
483ValueRefList concat_rule(
484 const Concat& op, Span<ValueRef>& inputs, const bool& auto_convert,

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected