Implement the rectified linear unit (ReLU) activation element-wise with a CUDA kernel.
y=max(x,0)Here x is an input element, y is its output value, and max selects the larger of its arguments. N is the number of elements in each buffer.
Negative inputs become zero, while non-negative inputs remain unchanged.
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 = [-2,-1,0,3]
Output: [0,0,0,3]
Explanation: The two negative values become zero, while zero and three remain unchanged.
Input: input = [1,-1,2.5,-0.5]
Output: [1,0,2.5,0]
CUDA provides fmaxf for a single-precision maximum.
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 rectified linear unit (ReLU) activation element-wise with a CUDA kernel.
y=max(x,0)Here x is an input element, y is its output value, and max selects the larger of its arguments. N is the number of elements in each buffer.
Negative inputs become zero, while non-negative inputs remain unchanged.
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 = [-2,-1,0,3]
Output: [0,0,0,3]
Explanation: The two negative values become zero, while zero and three remain unchanged.
Input: input = [1,-1,2.5,-0.5]
Output: [1,0,2.5,0]
CUDA provides fmaxf for a single-precision maximum.
The final block can contain threads whose indices are outside the vector.
Accepts: array
Submit a correct solution to see your kernel performance.