[XLA:CPU] Fusion: Only check for reuse on expensive instructions
The reuse condition walks over all instructions in the fusion, the fusion pass walks over all instructions, making this essentially quadratic. Moving the is_expensive check up doesn't completely avoid this behavior, but makes it much more unlikely. PiperOrigin-RevId: 317063582 Change-Id: I22459aa922e6d65c6c639ed81208d1d441a132bc
This commit is contained in:
parent
d230ccaa55
commit
dd49e65c5b
@ -94,9 +94,8 @@ bool CpuInstructionFusion::ShouldFuse(HloInstruction* consumer,
|
||||
|
||||
// Cost condition: not fuse (simple, expensive producers) and (consumers who
|
||||
// reuse operand elements).
|
||||
if (producer->opcode() != HloOpcode::kFusion &&
|
||||
consumer->ReusesOperandElements(operand_index) &&
|
||||
is_expensive(*producer)) {
|
||||
if (producer->opcode() != HloOpcode::kFusion && is_expensive(*producer) &&
|
||||
consumer->ReusesOperandElements(operand_index)) {
|
||||
VLOG(2) << "Fusion is not profitable.";
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user