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

Method translate_pass

src/gopt/impl/tensor_reformat.cpp:164–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164void TensorReformatPass::translate_pass(OptState& opt) const {
165 auto rewriter = opt.graph().make_rewriter();
166 auto on_opr = [&rewriter](OperatorNodeBase* opr) {
167 if (opr->same_type<RelayoutPlaceholder>()) {
168 auto ph = try_cast_as_op<RelayoutPlaceholder>(opr);
169 auto new_inp = rewriter.get_var(opr->input(0));
170 auto new_var = ReformatManager::instance().get(ph->key())({new_inp});
171 rewriter.replace_var(
172 opr->output(0), new_var,
173 mgb_cstr_log("replace relayout placeholder"));
174 return;
175 }
176 rewriter.auto_replace_outputs(opr);
177 };
178 opt.graph().iter(on_opr);
179 rewriter.apply_inplace();
180}
181
182void TensorReformatPass::apply(OptState& opt) const {
183 MIDOUT_B("TensorReformatPass::apply")

Callers

nothing calls this directly

Calls 11

make_rewriterMethod · 0.80
apply_inplaceMethod · 0.80
graphMethod · 0.45
get_varMethod · 0.45
inputMethod · 0.45
getMethod · 0.45
keyMethod · 0.45
replace_varMethod · 0.45
outputMethod · 0.45
auto_replace_outputsMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected