Small optimization for the calculation of element reuse.

We can break a loop early if we have already found an element reuse.

PiperOrigin-RevId: 329466838
Change-Id: I5f3f4940a694755c2194a11d479be23e11741efb
This commit is contained in:
Adrian Kuegel 2020-09-01 02:12:41 -07:00 committed by TensorFlower Gardener
parent ab772da384
commit 6293abccc7

View File

@ -3370,6 +3370,11 @@ class HloInstruction::FusionReusesParamElements {
// that.
value_it = cache->find(&hlo);
value_it->second = new_val;
// Fold() minimizes the UseKind value. If it is already minimum, we can
// break the loop early.
if (new_val == UseKind::kReuse) {
break;
}
}
}
return value_it->second;