Is there a way to implement ReLU without if statements?
13:51 22 Feb 2021

I'm performing this operation a lot, and I want to avoid branch-prediction problems, so I'm asking here.

For signed integer values, using only integer or bitwise arithmetic, can I implement the following statement without an IF clause, or other control clauses? A preferable solution would be word-length independent.

if value < 0 {
    value = 0
}
math optimization boolean-operations branch-prediction