(...args)
| 7439 | return no_mutation && !n.kind().startsWith('onnx::') && !torch._C.skip_list.has(n.kind()) && !n.isNondeterministic() && !n.hasSideEffects() && n.blocks().length === 0; |
| 7440 | } |
| 7441 | ConstantPropagation(...args) { |
| 7442 | if (args[0] instanceof torch.Graph) { |
| 7443 | throw new python.Error('Not implemented.'); |
| 7444 | } else if (args[0] instanceof torch.Block) { |
| 7445 | const [block] = args; |
| 7446 | for (const n of block.nodes()) { |
| 7447 | this.ConstantPropagation(n); |
| 7448 | } |
| 7449 | } else if (args[0] instanceof torch.Node) { |
| 7450 | const [n] = args; |
| 7451 | const constant_inputs = n.inputs().every((v) => v.node().kind() === 'prim::Constant'); |
| 7452 | if (n.kind() === 'prim::If') { |
| 7453 | if (constant_inputs) { |
| 7454 | this.inlineIf(n); |
| 7455 | } else { |
| 7456 | this.ConstantPropagation(n.blocks()); |
| 7457 | this.removeExtraIfOutputs(n); |
| 7458 | } |
| 7459 | } else if (n.kind() === 'prim::Loop') { |
| 7460 | if (this.loopWillNotRun(n)) { |
| 7461 | this.removeLoopNode(n); |
| 7462 | } else { |
| 7463 | this.ConstantPropagation(n.blocks()); |
| 7464 | this.removeExtraLoopOutputs(n); |
| 7465 | } |
| 7466 | } else if (constant_inputs && this.supportedNode(n)) { |
| 7467 | this.propagateNode(n); |
| 7468 | } else { |
| 7469 | this.ConstantPropagation(n.blocks()); // not implemented |
| 7470 | } |
| 7471 | } else if (args.length === 1 && Array.isArray(args[0]) && args[0].every((b) => b instanceof torch.Block)) { |
| 7472 | const [blocks] = args; |
| 7473 | for (const block of blocks) { |
| 7474 | this.ConstantPropagation(block); |
| 7475 | } |
| 7476 | } else { |
| 7477 | throw new python.Error('Not implemented.'); |
| 7478 | } |
| 7479 | } |
| 7480 | }); |
| 7481 | this.registerFunction('torch._C.ConstantPropagationImmutableTypes', (graph) => { |
| 7482 | const cp = torch._C.ConstantPropagator.NoAliasDb(graph); |
no test coverage detected