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/controls/dequant_int4_nosign/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 / controls / dequant_int4_nosign / kernel.cu` 22 lines ยท 845 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // CONTROL dequant_int4_nosign: the nibble is not sign-extended. 3 #include 4 5 __global__ void dequant_int4(const unsigned char *w, const float *s, float *y, int R, int C, int G, int NB) 6 { 7 long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x; 8 if (i >= (long long)R * C) 9 return; 10 int r = (int)(i / C); 11 int c = (int)(i % C); 12 int b = w[r * NB + c / 2]; 13 int nib = (c & 1) ? (b >> 4) : (b & 15); 14 y[i] = (float)nib * s[r * G + c / 32]; 15 } 16 17 void oal_launch(const long long *p, void *const *buf) 18 { 19 long long n = p[0] * p[1]; 20 dequant_int4<<<(unsigned)((n + 255) / 256), 256>>>((const unsigned char *)buf[0], (const float *)buf[1], 21 (float *)buf[2], (int)p[0], (int)p[1], (int)p[2], (int)p[3]); 22 }