Apply the error-function form of GELU to a vector of N float32 values on the GPU.
yi=2xi(1+erf(2xi))Here, x is the input vector, y is the output vector, i is an element index from 0 to N minus 1, and erf is the Gaussian error function. Use this definition rather than the tanh approximation.
Write all N results into the preallocated float32 output device buffer, preserving their order and leaving the input unchanged. The function returns no value.
Input: input = [-1, 0, 1, 2]
Output: [-0.1587, 0.0, 0.8413, 1.9545]
Explanation: GELU retains a small negative output at -1 and smoothly scales the positive values.
Input: input = [-2.5, -0.5, 0.5, 2.5]
Output: [-0.0155, -0.1543, 0.3457, 2.4845]
CUDA provides erff for a single-precision error function.
A precomputed reciprocal square root of two avoids repeated division.
Check the global element index before accessing the buffers.
Accepts: array
Submit a correct solution to see your kernel performance.
Apply the error-function form of GELU to a vector of N float32 values on the GPU.
yi=2xi(1+erf(2xi))Here, x is the input vector, y is the output vector, i is an element index from 0 to N minus 1, and erf is the Gaussian error function. Use this definition rather than the tanh approximation.
Write all N results into the preallocated float32 output device buffer, preserving their order and leaving the input unchanged. The function returns no value.
Input: input = [-1, 0, 1, 2]
Output: [-0.1587, 0.0, 0.8413, 1.9545]
Explanation: GELU retains a small negative output at -1 and smoothly scales the positive values.
Input: input = [-2.5, -0.5, 0.5, 2.5]
Output: [-0.0155, -0.1543, 0.3457, 2.4845]
CUDA provides erff for a single-precision error function.
A precomputed reciprocal square root of two avoids repeated division.
Check the global element index before accessing the buffers.
Accepts: array
Submit a correct solution to see your kernel performance.