(block)
| 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 | } |
no test coverage detected