Apply Swish, also called SiLU, to a vector of N float32 values on the GPU.
yi=1+e−xixiHere, x is the input vector, y is the output vector, and i is an element index from 0 to N minus 1. This is the standard Swish activation with a fixed sigmoid scale of one.
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 = [-2, -1, 0, 1, 2]
Output: [-0.2384, -0.2689, 0.0, 0.7311, 1.7616]
Explanation: Negative inputs retain a negative output, while positive inputs are scaled toward their original values.
Input: input = [-3, -1.5, 0.5, 2.5]
Output: [-0.1423, -0.2736, 0.3112, 2.3104]
CUDA provides expf for a single-precision exponential.
Keep a loaded input value in a local variable when reusing it.
Check the global element index before accessing the buffers.
Accepts: array
Submit a correct solution to see your kernel performance.
Apply Swish, also called SiLU, to a vector of N float32 values on the GPU.
yi=1+e−xixiHere, x is the input vector, y is the output vector, and i is an element index from 0 to N minus 1. This is the standard Swish activation with a fixed sigmoid scale of one.
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 = [-2, -1, 0, 1, 2]
Output: [-0.2384, -0.2689, 0.0, 0.7311, 1.7616]
Explanation: Negative inputs retain a negative output, while positive inputs are scaled toward their original values.
Input: input = [-3, -1.5, 0.5, 2.5]
Output: [-0.1423, -0.2736, 0.3112, 2.3104]
CUDA provides expf for a single-precision exponential.
Keep a loaded input value in a local variable when reusing it.
Check the global element index before accessing the buffers.
Accepts: array
Submit a correct solution to see your kernel performance.