FlashX
FlashX copied to clipboard
[FlashMatrix]: avoid computation in ifelse
X1 = -fp.log(1 + fp.exp(-X))
X2 = X - fp.log(1 + fp.exp(X))
return fp.where(X > 0, X1, X2)
The code above has redundant computation. log and exp can be expensive. We should avoid unnecessary computation here.