| 130 | } |
| 131 | |
| 132 | HloInstruction* MultiOutputFusion::Fuse(HloInstruction* instr1, |
| 133 | HloInstruction* instr2) { |
| 134 | HloInstruction* remaining = instr1; |
| 135 | HloInstruction* fused = instr2; |
| 136 | // Make sure that if only one of the instructions is a fusion, or if only one |
| 137 | // of the instructions is a multi-output fusion, it's what will be fused into. |
| 138 | if (fused->opcode() == HloOpcode::kFusion) { |
| 139 | std::swap(remaining, fused); |
| 140 | } |
| 141 | if (fused->IsMultiOutputFusion()) { |
| 142 | std::swap(remaining, fused); |
| 143 | } |
| 144 | if (fused->opcode() == HloOpcode::kFusion) { |
| 145 | remaining->MergeFusionInstructionIntoMultiOutput(fused); |
| 146 | } else { |
| 147 | remaining->FuseInstructionIntoMultiOutput(fused); |
| 148 | CHECK_EQ(0, fused->user_count()); |
| 149 | TF_CHECK_OK(computation()->RemoveInstruction(fused)); |
| 150 | } |
| 151 | return remaining; |
| 152 | } |
| 153 | |
| 154 | HloInstruction* MultiOutputFusion::CreateFusion(HloInstruction* base, |
| 155 | HloInstruction* to_fuse) { |
nothing calls this directly
no test coverage detected