openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / workloads / silu / triton_kernel.py
| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | import triton |
| 3 | import triton.language as tl |
| 4 | |
| 5 | |
| 6 | @triton.jit |
| 7 | def _silu(x, y, n, BLOCK: tl.constexpr): |
| 8 | i = tl.program_id(0) * BLOCK + tl.arange(0, BLOCK) |
| 9 | m = i < n |
| 10 | v = tl.load(x + i, mask=m, other=0.0) |
| 11 | tl.store(y + i, v / (1.0 + tl.exp(-v)), mask=m) |
| 12 | |
| 13 | |
| 14 | def launch(p, t): |
| 15 | n = p["n"] |
| 16 | _silu[(triton.cdiv(n, 1024),)](t["x"], t["y"], n, BLOCK=1024) |