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/quant_int8/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 / quant_int8 / kernel.cl` 19 lines ยท 674 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // One work-item per row: absmax, scale = absmax / 127, q = clamp(rint(x / scale), -127, 127). 3 __kernel void quant_int8(__global const float *x, __global char *q, __global float *s, 4 const int R, const int C) 5 { 6 int r = get_global_id(0); 7 if (r >= R) 8 return; 9 float amax = 0.0f; 10 for (int c = 0; c < C; c++) 11 amax = fmax(amax, fabs(x[r * C + c])); 12 float sc = amax / 127.0f; 13 s[r] = sc; 14 for (int c = 0; c < C; c++) { 15 float y = sc > 0.0f ? x[r * C + c] / sc : 0.0f; 16 float v = fmin(fmax(rint(y), -127.0f), 127.0f); 17 q[r * C + c] = (char)(int)v; 18 } 19 }