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/tsoftmax16/kernel.cl # 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 / tsoftmax16 / kernel.cl` 21 lines ยท 633 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // One work-item per 32-column row: max, exp(x - max) with its sum, then divide. 3 __kernel void tsoftmax16(__global const float *x, __global float *y, const int tiles) 4 { 5 int r = get_global_id(0); 6 if (r >= tiles * 16) 7 return; 8 __global const float *xr = x + r * 32; 9 __global float *yr = y + r * 32; 10 float m = xr[0]; 11 for (int j = 1; j < 32; j++) 12 m = fmax(m, xr[j]); 13 float s = 0.0f; 14 for (int j = 0; j < 32; j++) { 15 float e = exp(xr[j] - m); 16 yr[j] = e; 17 s += e; 18 } 19 for (int j = 0; j < 32; j++) 20 yr[j] = yr[j] / s; 21 }