openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / workloads / dequant_int8 / 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 _dequant_int8(q, s, y, C, BC: tl.constexpr): |
| 8 | r = tl.program_id(0) |
| 9 | c = tl.arange(0, BC) |
| 10 | live = c < C |
| 11 | qv = tl.load(q + r * C + c, mask=live, other=0).to(tl.float32) |
| 12 | tl.store(y + r * C + c, qv * tl.load(s + r), mask=live) |
| 13 | |
| 14 | |
| 15 | def launch(p, t): |
| 16 | _dequant_int8[(p["R"],)](t["q"], t["s"], t["y"], p["C"], BC=triton.next_power_of_2(p["C"])) |