openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / workloads / silu / kernel.cu
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | #include <cuda_runtime.h> |
| 3 | |
| 4 | __global__ void silu(const float *x, float *y, long long n) |
| 5 | { |
| 6 | long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; |
| 7 | if (i < n) { |
| 8 | float v = x[i]; |
| 9 | y[i] = v / (1.0f + expf(-v)); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | void oal_launch(const long long *p, void *const *buf) |
| 14 | { |
| 15 | long long n = p[0]; |
| 16 | silu<<<(unsigned)((n + 255) / 256), 256>>>((const float *)buf[0], (float *)buf[1], n); |
| 17 | } |