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/attn_scores/kernel.cu # 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 / attn_scores / kernel.cu` 27 lines ยท 776 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 #include 3 4 __global__ void attn_scores(const float *q, const float *k, float *s, int T, int D) 5 { 6 int j = blockIdx.x * blockDim.x + threadIdx.x; 7 int i = blockIdx.y * blockDim.y + threadIdx.y; 8 if (i >= T || j >= T) 9 return; 10 if (j > i) { 11 s[i * T + j] = -1e30f; 12 return; 13 } 14 float acc = 0.0f; 15 for (int c = 0; c < D; c++) 16 acc += q[i * D + c] * k[j * D + c]; 17 s[i * T + j] = acc * 0.125f; 18 } 19 20 void oal_launch(const long long *p, void *const *buf) 21 { 22 int T = (int)p[0]; 23 int D = (int)p[1]; 24 dim3 block(16, 16); 25 dim3 grid((T + 15) / 16, (T + 15) / 16); 26 attn_scores<<>>((const float *)buf[0], (const float *)buf[1], (float *)buf[2], T, D); 27 }