| 324 | } |
| 325 | |
| 326 | void 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 | |
| 342 | void residual_forward(Context& ctx, float* out, float* inp1, float* inp2, int N){ |
| 343 | unsigned long n = static_cast<unsigned long>(N); |
no test coverage detected