interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / rope / triton_kernel.py

23 lines · 730 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0
2import triton
3import triton.language as tl
4
5
6@triton.jit
7def _rope(x, cs, sn, y, H, h, BLOCK: tl.constexpr):
8 th = tl.program_id(0) # t*H + j
9 t = th // H
10 i = tl.arange(0, BLOCK)
11 m = i < h
12 o = th * 2 * h + i
13 c = tl.load(cs + t * h + i, mask=m, other=0.0)
14 s = tl.load(sn + t * h + i, mask=m, other=0.0)
15 x1 = tl.load(x + o, mask=m, other=0.0)
16 x2 = tl.load(x + o + h, mask=m, other=0.0)
17 tl.store(y + o, x1 * c - x2 * s, mask=m)
18 tl.store(y + o + h, x1 * s + x2 * c, mask=m)
19
20
21def launch(p, t):
22 _rope[(p["T"] * p["H"],)](t["x"], t["cos"], t["sin"], t["y"], p["H"], p["h"],
23 BLOCK=triton.next_power_of_2(p["h"]))