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

Method emit

src/gopt/impl/global_layout_transform/reformat_emitter.cpp:68–100  ·  view source on GitHub ↗

=================== MakeShapeEmitter ====================*/

Source from the content-addressed store, hash-verified

66
67// =================== MakeShapeEmitter ====================*/
68MakeShapeEmitter::EmitResult MakeShapeEmitter::emit() const {
69 auto pattern = mixin_analyze();
70 auto builder = [pattern](const VarNodeArray& input) {
71 mgb_assert(
72 input.size() == 1,
73 "number of input of MakeShapeBuilder should be 1(got:%zu)",
74 input.size());
75 auto sym_var = SymbolVar(input.front());
76 auto shp = opr::GetVarShape::make(sym_var);
77 auto cv = [&sym_var](int c) { return sym_var.make_scalar(c); };
78 auto sub = [&shp, &cv](int ax) {
79 return opr::IndexAt::make(shp, {{0, cv(ax)}});
80 };
81 SymbolVarArray axs;
82 for (auto&& i : pattern) {
83 int axis, factor;
84 bool mul;
85 std::tie(axis, factor, mul) = i;
86 if (axis >= 0) {
87 if (mul)
88 axs.emplace_back(sub(axis) * factor);
89 else
90 axs.emplace_back(sub(axis) / factor);
91 } else {
92 axs.emplace_back(cv(factor));
93 }
94 }
95 auto tshp = opr::Concat::make(axs, 0);
96 return tshp.node();
97 };
98 auto checker = mixin_emit_checker(pattern);
99 return std::make_tuple(builder, checker);
100}
101
102// =================== ReshapeEmitter ====================*/
103ReshapeEmitter::EmitResult ReshapeEmitter::emit() const {

Callers 6

TESTFunction · 0.45
TESTFunction · 0.45
analyzeMethod · 0.45
getMethod · 0.45

Calls 15

SymbolVarClass · 0.85
subFunction · 0.85
frontMethod · 0.80
emplace_backMethod · 0.80
dimshuffleMethod · 0.80
is_low_bitMethod · 0.80
extentMethod · 0.80
resizeMethod · 0.80
dist_byteMethod · 0.80
spanMethod · 0.80
makeFunction · 0.50
sizeMethod · 0.45

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36