Given two arrays a and b of N floats, compute their element-wise sum into c:
c[i] = a[i] + b[i]
solve in the starter of the framework you choose; keep its signature.
extern "C" void solve(const float* a, const float* b, float* c, int N)def solve(a: torch.Tensor, b: torch.Tensor, c: torch.Tensor, N: int)a, b and c are already on the GPU. Do not modify a or b.c in place; its contents on entry are undefined. In Python, c = a + b only
rebinds the local name and leaves c unwritten.Input: a = [1.0, 2.0, 3.0, 4.0], b = [10.0, 20.0, 30.0, 40.0], N = 4
Output: c = [11.0, 22.0, 33.0, 44.0]
Input: a = [0.5, -1.5, 2.0], b = [-0.5, 1.0, 0.25], N = 3
Output: c = [0.0, -0.5, 2.25]
N = 25,000,000TODO
CUDA · T4
Loading…
CUDA · T4
Loading…
CUDA · T4
Loading…