Skip to content
fn

vrelu_f32

void vrelu_f32(const float * in, float * out, int n)

Single-precision ReLU clamp.

Computes outi=max⁡(0,ini)\text{out}_i = \max(0, \text{in}_i) via vDSP_vthres with threshold 00 (values below zero are replaced by zero).

References

Branchless (x < 0) ? 0 : x rather than vDSP_vthres, which returns the threshold for NaN and so swallowed NaN on the CPU while Metal propagated it. Also faster.

Parameters

inconst float*
Input buffer.
outfloat*
Output buffer.
nstd::size_t
Element count.