Optimization to select(pred, 1, 0) -> convert(pred). Is it beneficial? #9482
Closed
apivovarov
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Sorry for forgetting to answer here. If you can provide microbenchmarks for GPU so that we can see how much this optimization is worth, that would be helpful. In case it is not a good optimization for all backends, we could add an AlgebraicSimplifier option to enable/disable it based on backend. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to check if adding the following optimization to HLO algebraic_simplifier.cc would be beneficial?
Optimization:
If
on_true
arrayisAll(1)
andon_false
arrayisAll(0)
then we can:select(pred, 1, 0)
withconvert(pred)
(if pred.shape == on_true.shape)select(pred, 1, 0)
withbroadcast(convert(pred))
otherwiseAssumption is that
convert
(orconvert
+broadcast
) computation(s) is cheaper than (or equal to)select
computation on most of CPU/GPU/TPU performance models.Operation semantics
Select op semantic:
select(pred, on_true, on_false)
Desc: Constructs an output array from elements of two input arrays, based on the values of a predicate array.
@akuegel @lipracer @ddunl What you think?
Beta Was this translation helpful? Give feedback.
All reactions