Implement the sigmoid (logistic) activation element-wise with a CUDA kernel.
y=1+e−x1Here x is an input element, y is its sigmoid activation, and e is the base of the natural logarithm. N is the number of elements in each buffer.
The mathematical result lies strictly between zero and one; single-precision rounding can produce either endpoint for sufficiently large input magnitudes.
The buffers are contiguous arrays of 32-bit floats in device memory. Write all N results into the preallocated output buffer; the solve function returns no value.
Input: input = [0,2,-2]
Output: [0.5,0.8808,0.1192]
Explanation: Zero maps to 0.5; the positive and negative inputs map above and below 0.5, respectively.
Input: input = [-1,0,1,2]
Output: [0.2689,0.5,0.7311,0.8808]
CUDA provides expf for a single-precision exponential.
The exponential uses the negative input; negation does not limit its magnitude.
The final block can contain threads whose indices are outside the vector.
Accepts: array
Submit a correct solution to see your kernel performance.
Implement the sigmoid (logistic) activation element-wise with a CUDA kernel.
y=1+e−x1Here x is an input element, y is its sigmoid activation, and e is the base of the natural logarithm. N is the number of elements in each buffer.
The mathematical result lies strictly between zero and one; single-precision rounding can produce either endpoint for sufficiently large input magnitudes.
The buffers are contiguous arrays of 32-bit floats in device memory. Write all N results into the preallocated output buffer; the solve function returns no value.
Input: input = [0,2,-2]
Output: [0.5,0.8808,0.1192]
Explanation: Zero maps to 0.5; the positive and negative inputs map above and below 0.5, respectively.
Input: input = [-1,0,1,2]
Output: [0.2689,0.5,0.7311,0.8808]
CUDA provides expf for a single-precision exponential.
The exponential uses the negative input; negation does not limit its magnitude.
The final block can contain threads whose indices are outside the vector.
Accepts: array
Submit a correct solution to see your kernel performance.