interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

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 <cuda_runtime.h>
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
17void 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}