MCPcopy Create free account
hub / github.com/alibaba/MNN / FuseListStack

Function FuseListStack

tools/converter/source/torch/torchOptimize.cpp:239–263  ·  view source on GitHub ↗

We rewrite something like: x = ListConstruct(v1, v2, v3) y = stack(y, axis) to: y = stack(v1, v2, v3, axis) */

Source from the content-addressed store, hash-verified

237 y = stack(v1, v2, v3, axis)
238*/
239void FuseListStack(Block* block) {
240 for (auto it = block->nodes().begin(); it != block->nodes().end();) {
241 auto* node = *it;
242 it++;
243
244 for (Block* sub_block : node->blocks()) {
245 FuseListUnpack(sub_block);
246 }
247 std::set<NodeKind> fusekind = {
248 aten::stack
249 };
250 if (it->kind() == aten::stack) {
251 auto input = it->input(0)->node();
252 if (input->kind() == prim::ListConstruct) {
253 auto axis = it->input(1);
254 it->removeAllInputs();
255 for (int i = 0; i < input->inputs().size(); i++) {
256 it->addInput(input->input(i));
257 }
258 it->addInput(axis);
259 input->destroy();
260 }
261 }
262 }
263}
264/*
265 We rewrite something like:
266 %y : int, %z : int = prim::Loop(%6, %2, %y.1, %z.1) # <ipython-input-14-d0a2ead71c2a>:6:4

Callers 1

torchOptPassFunction · 0.85

Calls 8

FuseListUnpackFunction · 0.85
kindMethod · 0.80
addInputMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
inputMethod · 0.45
sizeMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected