interplane.Get Omega
Read in your language

openaccel-lab

aien-dev/openaccel-lab

Brought by drakestapleton

branch main Branches Tags History

openaccel-lab / workloads / dequant_int4 / kernel.cu

22 lines · 817 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2#include <cuda_runtime.h>
3
4__global__ void dequant_int4(const unsigned char *w, const float *s, float *y, int R, int C, int G, int NB)
5{
6 long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x;
7 if (i >= (long long)R * C)
8 return;
9 int r = (int)(i / C);
10 int c = (int)(i % C);
11 int b = w[r * NB + c / 2];
12 int nib = (c & 1) ? (b >> 4) : (b & 15);
13 nib = nib >= 8 ? nib - 16 : nib;
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}