MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / gelu_backward

Function gelu_backward

experimental/kernels/ops.cpp:326–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326void gelu_backward(Context& ctx, float* dinp, float* inp, float* dout, int N){
327 unsigned long n = static_cast<unsigned long>(N);
328 setLogLevel(kError);
329 Tensor inp_i = createTensor(ctx, Shape{n}, kf32, inp);
330 Tensor dout_i = createTensor(ctx, Shape{n}, kf32, dout);
331 Tensor dinp_o = createTensor(ctx, Shape{n}, kf32, dinp);
332 std::promise<void> promise;
333 std::future<void> future = promise.get_future();
334 Kernel op = createKernel(ctx, {kShaderGeluBackward, 256, kf32},
335 Bindings{inp_i, dout_i, dinp_o},
336 /* nWorkgroups */ {cdiv(n, 256), 1, 1});
337 dispatchKernel(ctx, op, promise);
338 wait(ctx, future);
339 toCPU(ctx, dinp_o, dinp, n * sizeof(float));
340}
341
342void residual_forward(Context& ctx, float* out, float* inp1, float* inp2, int N){
343 unsigned long n = static_cast<unsigned long>(N);

Callers 1

gpt2_backwardFunction · 0.85

Calls 7

setLogLevelFunction · 0.85
createTensorFunction · 0.85
createKernelFunction · 0.85
cdivFunction · 0.85
dispatchKernelFunction · 0.85
waitFunction · 0.85
toCPUFunction · 0.85

Tested by

no test coverage detected