Implement a GPU program that converts an RGB image to grayscale on the GPU. Given an input RGB image represented as a 1D array of 32-bit floating point values, compute the corresponding grayscale image using the standard RGB to grayscale conversion formula.
The conversion formula is: gray = 0.299 × R + 0.587 × G + 0.114 × B
The input array input contains height × width × 3 elements,
where the RGB values for each pixel are stored consecutively (R, G, B, R, G, B, ...).
The output array output should contain height × width grayscale values.
solve function signature must remain unchangedoutputInput: input = [255.0, 0.0, 0.0, 0.0, 255.0, 0.0, 0.0, 0.0, 255.0, 128.0, 128.0, 128.0], width=2, height=2 Output: output = [76.245, 149.685, 29.07, 128.0]
Input: input = [100.0, 150.0, 200.0], width=1, height=1 Output: output = [140.75]
width ≤ 4096height ≤ 4096width × height ≤ 4,194,304height = 2,048, width = 2,048