(n)
| 7364 | n.blocks().at(1).eraseOutput(i); |
| 7365 | } |
| 7366 | removeExtraIfOutputs(n) { |
| 7367 | torch._C.TORCH_CHECK(n.kind() === 'prim::If'); |
| 7368 | const [true_block, false_block] = n.blocks(); |
| 7369 | const graph = n.owningGraph(); |
| 7370 | const initial_outputs = true_block.outputs().length; |
| 7371 | const guard = new torch._C.WithInsertPoint(n); |
| 7372 | for (let i = 0; i < true_block.outputs().length;) { |
| 7373 | const t_out = true_block.outputs()[i]; |
| 7374 | const f_out = false_block.outputs()[i]; |
| 7375 | if (true_block.outputs()[i] === false_block.outputs()[i]) { |
| 7376 | this.replaceAndRemoveIfOutput(n, i, true_block.outputs()[i]); |
| 7377 | continue; |
| 7378 | } |
| 7379 | const maybe_const = torch._C.toIValue(t_out); |
| 7380 | if (maybe_const && torch._C.EqualNode(t_out.node(), f_out.node())) { |
| 7381 | const new_const = graph.insertConstant(maybe_const); |
| 7382 | this.replaceAndRemoveIfOutput(n, i, new_const); |
| 7383 | continue; |
| 7384 | } |
| 7385 | i++; |
| 7386 | } |
| 7387 | this._made_change = this._made_change || (initial_outputs !== true_block.outputs().length); |
| 7388 | guard.dispose(); |
| 7389 | } |
| 7390 | removeExtraLoopOutputs(node) { |
| 7391 | const initial_outputs = node.outputs().length; |
| 7392 | const [loop_body] = node.blocks(); |
no test coverage detected