MCPcopy
hub / github.com/lutzroeder/netron / eraseBlockLoadStores

Method eraseBlockLoadStores

source/python.js:18448–18483  ·  view source on GitHub ↗
(block)

Source from the content-addressed store, hash-verified

18446 return old_frame;
18447 }
18448 eraseBlockLoadStores(block) {
18449 this.pushFrame(block);
18450 for (const n of block.nodes()) {
18451 switch (n.kind()) {
18452 case 'prim::Store': {
18453 this.environment_stack.setVar(n.s('name'), n.input());
18454 n.destroy();
18455 break;
18456 }
18457 case 'prim::Load': {
18458 const name = n.s('name');
18459 const value = this.environment_stack.findInAnyFrame(name);
18460 torch._C.TORCH_INTERNAL_ASSERT(value);
18461 n.output().replaceAllUsesWith(value);
18462 n.destroy();
18463 break;
18464 }
18465 case 'prim::ComprehensionScope': {
18466 const [body] = n.blocks();
18467 this.eraseBlockLoadStores(body);
18468 for (const body_node of body.nodes()) {
18469 body_node.moveBefore(n);
18470 }
18471 n.destroy();
18472 break;
18473 }
18474 default: {
18475 for (const b of n.blocks()) {
18476 this.eraseBlockLoadStores(b);
18477 }
18478 break;
18479 }
18480 }
18481 }
18482 this.popFrame();
18483 }
18484 run(graph) {
18485 this.eraseBlockLoadStores(graph.block());
18486 }

Callers 1

runMethod · 0.80

Calls 13

pushFrameMethod · 0.80
setVarMethod · 0.80
sMethod · 0.80
destroyMethod · 0.80
findInAnyFrameMethod · 0.80
replaceAllUsesWithMethod · 0.80
blocksMethod · 0.80
moveBeforeMethod · 0.80
popFrameMethod · 0.80
nodesMethod · 0.45
kindMethod · 0.45
inputMethod · 0.45

Tested by

no test coverage detected