Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/openaccel-lab/blob/main/workloads/softmax/triton_kernel.py # openaccel-lab aien-dev/openaccel-lab Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `openaccel-lab / workloads / softmax / triton_kernel.py` 17 lines ยท 469 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 2 import triton 3 import triton.language as tl 4 5 6 @triton.jit 7 def _softmax(x, y, D, BLOCK: tl.constexpr): 8 r = tl.program_id(0) 9 k = tl.arange(0, BLOCK) 10 m = k < D 11 v = tl.load(x + r * D + k, mask=m, other=-float("inf")) 12 e = tl.exp(v - tl.max(v, axis=0)) 13 tl.store(y + r * D + k, e / tl.sum(e, axis=0), mask=m) 14 15 16 def launch(p, t): 17 _softmax[(p["R"],)](t["x"], t["y"], p["D"], BLOCK=triton.next_power_of_2(p["D"]))