ggerganov commited on
Commit
1da9474
·
1 Parent(s): 9442640

files : remove old sources

Browse files
examples/whisper.android/lib/src/main/jni/whisper/CMakeLists.txt CHANGED
@@ -21,7 +21,6 @@ if (NOT GGML_HOME)
21
  SOURCE_FILES
22
  ${SOURCE_FILES}
23
  ${WHISPER_LIB_DIR}/ggml/src/ggml.c
24
- ${WHISPER_LIB_DIR}/ggml/src/ggml-aarch64.c
25
  ${WHISPER_LIB_DIR}/ggml/src/ggml-alloc.c
26
  ${WHISPER_LIB_DIR}/ggml/src/ggml-backend.cpp
27
  ${WHISPER_LIB_DIR}/ggml/src/ggml-backend-reg.cpp
@@ -29,7 +28,7 @@ if (NOT GGML_HOME)
29
  ${WHISPER_LIB_DIR}/ggml/src/ggml-threading.cpp
30
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.c
31
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.cpp
32
- ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-aarch64.c
33
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-quants.c
34
  )
35
  endif()
 
21
  SOURCE_FILES
22
  ${SOURCE_FILES}
23
  ${WHISPER_LIB_DIR}/ggml/src/ggml.c
 
24
  ${WHISPER_LIB_DIR}/ggml/src/ggml-alloc.c
25
  ${WHISPER_LIB_DIR}/ggml/src/ggml-backend.cpp
26
  ${WHISPER_LIB_DIR}/ggml/src/ggml-backend-reg.cpp
 
28
  ${WHISPER_LIB_DIR}/ggml/src/ggml-threading.cpp
29
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.c
30
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu.cpp
31
+ ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp
32
  ${WHISPER_LIB_DIR}/ggml/src/ggml-cpu/ggml-cpu-quants.c
33
  )
34
  endif()
ggml/src/ggml-aarch64.c DELETED
@@ -1,129 +0,0 @@
1
- #define GGML_COMMON_DECL_C
2
- #include "ggml-common.h"
3
-
4
- #include "ggml-aarch64.h"
5
- #include "ggml-impl.h"
6
- #include "ggml-quants.h"
7
- #include <assert.h>
8
-
9
- #define UNUSED GGML_UNUSED
10
-
11
- static block_q4_0x4 make_block_q4_0x4(block_q4_0 * in, unsigned int blck_size_interleave) {
12
- block_q4_0x4 out;
13
-
14
- for (int i = 0; i < 4; i++) {
15
- out.d[i] = in[i].d;
16
- }
17
-
18
- const int end = QK4_0 * 2 / blck_size_interleave;
19
-
20
- if (blck_size_interleave == 8) {
21
- const uint64_t xor_mask = 0x8888888888888888ULL;
22
- for (int i = 0; i < end; ++i) {
23
- int src_id = i % 4;
24
- int src_offset = (i / 4) * blck_size_interleave;
25
- int dst_offset = i * blck_size_interleave;
26
-
27
- uint64_t elems;
28
- // Using memcpy to avoid unaligned memory accesses
29
- memcpy(&elems, &in[src_id].qs[src_offset], sizeof(uint64_t));
30
- elems ^= xor_mask;
31
- memcpy(&out.qs[dst_offset], &elems, sizeof(uint64_t));
32
- }
33
- } else if (blck_size_interleave == 4) {
34
- const uint32_t xor_mask = 0x88888888;
35
- for (int i = 0; i < end; ++i) {
36
- int src_id = i % 4;
37
- int src_offset = (i / 4) * blck_size_interleave;
38
- int dst_offset = i * blck_size_interleave;
39
-
40
- uint32_t elems;
41
- memcpy(&elems, &in[src_id].qs[src_offset], sizeof(uint32_t));
42
- elems ^= xor_mask;
43
- memcpy(&out.qs[dst_offset], &elems, sizeof(uint32_t));
44
- }
45
- } else {
46
- GGML_ASSERT(false);
47
- }
48
-
49
- return out;
50
- }
51
-
52
- // interleave 8 block_q4_0s in blocks of blck_size_interleave
53
- // returns an interleaved block_q4_0x8
54
- // in the interleaved block_q4_0x8, place deltas for 8 block_q4_0 blocks
55
- // first, then interleave quants from 8 block_q4_0s in blocks of blck_size_interleave
56
- static block_q4_0x8 make_block_q4_0x8(block_q4_0 * in, unsigned int blck_size_interleave) {
57
- block_q4_0x8 out;
58
-
59
- for (int i = 0; i < 8; i++) {
60
- out.d[i] = in[i].d;
61
- }
62
-
63
- const int end = QK4_0 * 4 / blck_size_interleave;
64
- const uint64_t xor_mask = 0x8888888888888888ULL;
65
-
66
- for (int i = 0; i < end; ++i) {
67
- int src_id = i % 8;
68
- int src_offset = (i / 8) * blck_size_interleave;
69
- int dst_offset = i * blck_size_interleave;
70
-
71
- uint64_t elems;
72
- memcpy(&elems, &in[src_id].qs[src_offset], sizeof(uint64_t));
73
- elems ^= xor_mask;
74
- memcpy(&out.qs[dst_offset], &elems, sizeof(uint64_t));
75
- }
76
-
77
- return out;
78
- }
79
-
80
- static size_t quantize_q4_0_nr_bl(const float * restrict src, void * restrict dst, int64_t nrow, int64_t n_per_row, int nrows_interleaved, int blck_size_interleave) {
81
- assert(n_per_row % QK4_0 == 0);
82
- const int nb = n_per_row / QK4_0;
83
-
84
- void * out_ptr = NULL;
85
- if (nrows_interleaved == 8) {
86
- out_ptr = (block_q4_0x8 *) dst;
87
- }
88
- else if (nrows_interleaved == 4) {
89
- out_ptr = (block_q4_0x4 *) dst;
90
- }
91
- assert(nrows_interleaved <= 8);
92
- block_q4_0 dst_tmp[8];
93
-
94
- for (int b = 0; b < (nrow * n_per_row); b += nrows_interleaved * n_per_row) {
95
-
96
- for (int64_t x = 0; x < nb; x++) {
97
-
98
- for (int i = 0; i < nrows_interleaved; i++ ) {
99
- quantize_row_q4_0_ref(src + b + i * n_per_row + x * QK4_0, (block_q4_0 *) dst_tmp + i, QK4_0);
100
- }
101
-
102
- if (nrows_interleaved == 8) {
103
- *(block_q4_0x8 *) out_ptr = make_block_q4_0x8(dst_tmp, blck_size_interleave);
104
- out_ptr = (block_q4_0x8 *) out_ptr + 1;
105
- }
106
- else if (nrows_interleaved == 4) {
107
- *(block_q4_0x4 *) out_ptr = make_block_q4_0x4(dst_tmp, blck_size_interleave);
108
- out_ptr = (block_q4_0x4 *) out_ptr + 1;
109
- }
110
- }
111
- }
112
-
113
- return ((nrow * n_per_row) / QK4_0 * sizeof(block_q4_0));
114
- }
115
-
116
- size_t quantize_q4_0_4x4(const float * restrict src, void * restrict dst, int64_t nrow, int64_t n_per_row, const float * quant_weights) {
117
- UNUSED(quant_weights);
118
- return quantize_q4_0_nr_bl(src, dst, nrow, n_per_row, 4, 4);
119
- }
120
-
121
- size_t quantize_q4_0_4x8(const float * restrict src, void * restrict dst, int64_t nrow, int64_t n_per_row, const float * quant_weights) {
122
- UNUSED(quant_weights);
123
- return quantize_q4_0_nr_bl(src, dst, nrow, n_per_row, 4, 8);
124
- }
125
-
126
- size_t quantize_q4_0_8x8(const float * restrict src, void * restrict dst, int64_t nrow, int64_t n_per_row, const float * quant_weights) {
127
- UNUSED(quant_weights);
128
- return quantize_q4_0_nr_bl(src, dst, nrow, n_per_row, 8, 8);
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ggml/src/ggml-aarch64.h DELETED
@@ -1,19 +0,0 @@
1
- #pragma once
2
-
3
- #include "ggml.h"
4
-
5
- // GGML internal header
6
-
7
- #ifdef __cplusplus
8
- extern "C" {
9
- #endif
10
-
11
- // Quantization utilizing an importance matrix (a.k.a. "Activation aWare Quantization")
12
- size_t quantize_q4_0_4x4(const float * GGML_RESTRICT src, void * GGML_RESTRICT dst, int64_t nrows, int64_t n_per_row, const float * imatrix);
13
- size_t quantize_q4_0_4x8(const float * GGML_RESTRICT src, void * GGML_RESTRICT dst, int64_t nrows, int64_t n_per_row, const float * imatrix);
14
- size_t quantize_q4_0_8x8(const float * GGML_RESTRICT src, void * GGML_RESTRICT dst, int64_t nrows, int64_t n_per_row, const float * imatrix);
15
-
16
- #ifdef __cplusplus
17
- }
18
- #endif
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ggml/src/ggml-cpu/ggml-cpu-aarch64.c DELETED
The diff for this file is too large to render. See raw diff
 
ggml/src/ggml-cuda/dmmv.cu DELETED
@@ -1,699 +0,0 @@
1
- #include "dmmv.cuh"
2
- #include "dequantize.cuh"
3
- #include "convert.cuh"
4
-
5
- #ifndef K_QUANTS_PER_ITERATION
6
- #define K_QUANTS_PER_ITERATION 2
7
- #else
8
- static_assert(K_QUANTS_PER_ITERATION == 1 || K_QUANTS_PER_ITERATION == 2, "K_QUANTS_PER_ITERATION must be 1 or 2");
9
- #endif
10
-
11
- static __global__ void dequantize_mul_mat_vec_q2_k(const void * __restrict__ vx, const float * __restrict__ yy, float * __restrict__ dst, const int ncols, int nrows) {
12
-
13
- static_assert(16%K_QUANTS_PER_ITERATION == 0, "16 must be divisible by K_QUANTS_PER_ITERATION");
14
-
15
- const int row = blockIdx.x*blockDim.y + threadIdx.y;
16
- if (row > nrows) return;
17
-
18
- const int num_blocks_per_row = ncols / QK_K;
19
- const int ib0 = row*num_blocks_per_row;
20
-
21
- const block_q2_K * x = (const block_q2_K *)vx + ib0;
22
-
23
- float tmp = 0; // partial sum for thread in warp
24
-
25
- const int tid = threadIdx.x/K_QUANTS_PER_ITERATION; // 0...31 or 0...15
26
- const int ix = threadIdx.x%K_QUANTS_PER_ITERATION; // 0 or 0,1
27
-
28
- const int step = 16/K_QUANTS_PER_ITERATION;
29
-
30
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
31
- const int in = tid - step*im; // 0...15 or 0...7
32
-
33
- const int l0 = K_QUANTS_PER_ITERATION*in; // 0...15 or 0...14 in steps of 2
34
- const int q_offset = 32*im + l0;
35
- const int s_offset = 8*im;
36
- const int y_offset = 128*im + l0;
37
-
38
- uint32_t aux[4];
39
- const uint8_t * d = (const uint8_t *)aux;
40
- const uint8_t * m = (const uint8_t *)(aux + 2);
41
-
42
- for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
43
-
44
- const float * y = yy + i * QK_K + y_offset;
45
- const uint8_t * q = x[i].qs + q_offset;
46
-
47
- const float dall = __low2half(x[i].dm);
48
- const float dmin = __high2half(x[i].dm);
49
-
50
- const uint32_t * a = (const uint32_t *)(x[i].scales + s_offset);
51
- aux[0] = a[0] & 0x0f0f0f0f;
52
- aux[1] = a[1] & 0x0f0f0f0f;
53
- aux[2] = (a[0] >> 4) & 0x0f0f0f0f;
54
- aux[3] = (a[1] >> 4) & 0x0f0f0f0f;
55
-
56
- float sum1 = 0, sum2 = 0;
57
- for (int l = 0; l < K_QUANTS_PER_ITERATION; ++l) {
58
- sum1 += y[l+ 0] * d[0] * ((q[l+ 0] >> 0) & 3)
59
- + y[l+32] * d[2] * ((q[l+ 0] >> 2) & 3)
60
- + y[l+64] * d[4] * ((q[l+ 0] >> 4) & 3)
61
- + y[l+96] * d[6] * ((q[l+ 0] >> 6) & 3)
62
- + y[l+16] * d[1] * ((q[l+16] >> 0) & 3)
63
- + y[l+48] * d[3] * ((q[l+16] >> 2) & 3)
64
- + y[l+80] * d[5] * ((q[l+16] >> 4) & 3)
65
- +y[l+112] * d[7] * ((q[l+16] >> 6) & 3);
66
- sum2 += y[l+ 0] * m[0] + y[l+32] * m[2] + y[l+64] * m[4] + y[ l+96] * m[6]
67
- + y[l+16] * m[1] + y[l+48] * m[3] + y[l+80] * m[5] + y[l+112] * m[7];
68
-
69
- }
70
- tmp += dall * sum1 - dmin * sum2;
71
-
72
- }
73
-
74
- // sum up partial sums and write back result
75
- tmp = warp_reduce_sum(tmp);
76
-
77
- if (threadIdx.x == 0) {
78
- dst[row] = tmp;
79
- }
80
- }
81
-
82
- static __global__ void dequantize_mul_mat_vec_q3_k(const void * __restrict__ vx, const float * __restrict__ yy, float * __restrict__ dst, const int ncols, int nrows) {
83
-
84
- const int row = blockIdx.x*blockDim.y + threadIdx.y;
85
- if (row > nrows) return;
86
-
87
- const int num_blocks_per_row = ncols / QK_K;
88
- const int ib0 = row*num_blocks_per_row;
89
-
90
- const block_q3_K * x = (const block_q3_K *)vx + ib0;
91
-
92
- float tmp = 0; // partial sum for thread in warp
93
-
94
- const uint16_t kmask1 = 0x0303;
95
- const uint16_t kmask2 = 0x0f0f;
96
-
97
- const int tid = threadIdx.x/K_QUANTS_PER_ITERATION; // 0...31 or 0...16
98
- const int ix = threadIdx.x%K_QUANTS_PER_ITERATION; // 0 or 0,1
99
-
100
- const int n = K_QUANTS_PER_ITERATION; // iterations in the inner loop
101
- const int step = 16/K_QUANTS_PER_ITERATION;
102
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
103
- const int in = tid - step*im; // 0....15 or 0...7
104
-
105
- const uint8_t m = 1 << (4*im);
106
-
107
- const int l0 = n*in; // 0...15 or 0...14 in steps of 2
108
- const int q_offset = 32*im + l0;
109
- const int y_offset = 128*im + l0;
110
-
111
- uint16_t utmp[4];
112
- const int8_t * s = (const int8_t *)utmp;
113
-
114
- const uint16_t s_shift = 4*im;
115
-
116
- for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
117
-
118
- const float * y = yy + i * QK_K + y_offset;
119
- const uint8_t * q = x[i].qs + q_offset;
120
- const uint8_t * h = x[i].hmask + l0;
121
-
122
- const uint16_t * a = (const uint16_t *)x[i].scales;
123
- utmp[0] = ((a[0] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 0)) & kmask1) << 4);
124
- utmp[1] = ((a[1] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 0)) & kmask1) << 4);
125
- utmp[2] = ((a[2] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 2)) & kmask1) << 4);
126
- utmp[3] = ((a[3] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 2)) & kmask1) << 4);
127
-
128
- const float d = x[i].d;
129
-
130
- float sum = 0;
131
- for (int l = 0; l < n; ++l) {
132
- sum += y[l+ 0] * (s[0] - 32) * (((q[l] >> 0) & 3) - (h[l] & (m << 0) ? 0 : 4))
133
- + y[l+32] * (s[2] - 32) * (((q[l] >> 2) & 3) - (h[l] & (m << 1) ? 0 : 4))
134
- + y[l+64] * (s[4] - 32) * (((q[l] >> 4) & 3) - (h[l] & (m << 2) ? 0 : 4))
135
- + y[l+96] * (s[6] - 32) * (((q[l] >> 6) & 3) - (h[l] & (m << 3) ? 0 : 4));
136
- sum += y[l+16] * (s[1] - 32) * (((q[l+16] >> 0) & 3) - (h[l+16] & (m << 0) ? 0 : 4))
137
- + y[l+48] * (s[3] - 32) * (((q[l+16] >> 2) & 3) - (h[l+16] & (m << 1) ? 0 : 4))
138
- + y[l+80] * (s[5] - 32) * (((q[l+16] >> 4) & 3) - (h[l+16] & (m << 2) ? 0 : 4))
139
- + y[l+112] * (s[7] - 32) * (((q[l+16] >> 6) & 3) - (h[l+16] & (m << 3) ? 0 : 4));
140
- }
141
- tmp += d * sum;
142
-
143
- }
144
-
145
- // sum up partial sums and write back result
146
- tmp = warp_reduce_sum(tmp);
147
-
148
- if (threadIdx.x == 0) {
149
- dst[row] = tmp;
150
- }
151
- }
152
-
153
- static __global__ void dequantize_mul_mat_vec_q4_k(const void * __restrict__ vx, const float * __restrict__ yy, float * __restrict__ dst, const int ncols, int nrows) {
154
-
155
- const int row = blockIdx.x*blockDim.y + threadIdx.y;
156
- if (row > nrows) return;
157
- const int num_blocks_per_row = ncols / QK_K;
158
- const int ib0 = row*num_blocks_per_row;
159
-
160
- const block_q4_K * x = (const block_q4_K *)vx + ib0;
161
-
162
- const uint16_t kmask1 = 0x3f3f;
163
- const uint16_t kmask2 = 0x0f0f;
164
- const uint16_t kmask3 = 0xc0c0;
165
-
166
- const int tid = threadIdx.x/K_QUANTS_PER_ITERATION; // 0...31 or 0...16
167
- const int ix = threadIdx.x%K_QUANTS_PER_ITERATION; // 0 or 0,1
168
-
169
- const int step = 8/K_QUANTS_PER_ITERATION; // 8 or 4
170
-
171
- const int il = tid/step; // 0...3
172
- const int ir = tid - step*il; // 0...7 or 0...3
173
- const int n = 2 * K_QUANTS_PER_ITERATION; // 2 or 4
174
-
175
- const int im = il/2; // 0 or 1. 0 computes 0,32 + 128,160, 1 computes 64,96 + 192,224
176
- const int in = il%2;
177
-
178
- const int l0 = n*(2*ir + in);
179
- const int q_offset = 32*im + l0;
180
- const int y_offset = 64*im + l0;
181
-
182
- uint16_t aux[4];
183
- const uint8_t * sc = (const uint8_t *)aux;
184
-
185
- #if K_QUANTS_PER_ITERATION == 2
186
- uint32_t q32[4];
187
- const uint8_t * q4 = (const uint8_t *)q32;
188
- #else
189
- uint16_t q16[4];
190
- const uint8_t * q4 = (const uint8_t *)q16;
191
- #endif
192
-
193
- float tmp = 0; // partial sum for thread in warp
194
-
195
- for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
196
-
197
- const float * y1 = yy + i*QK_K + y_offset;
198
- const float * y2 = y1 + 128;
199
-
200
- const float dall = __low2half(x[i].dm);
201
- const float dmin = __high2half(x[i].dm);
202
-
203
- const uint16_t * a = (const uint16_t *)x[i].scales;
204
- aux[0] = a[im+0] & kmask1;
205
- aux[1] = a[im+2] & kmask1;
206
- aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
207
- aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
208
-
209
- #if K_QUANTS_PER_ITERATION == 2
210
- const uint32_t * q1 = (const uint32_t *)(x[i].qs + q_offset);
211
- const uint32_t * q2 = q1 + 16;
212
-
213
- q32[0] = q1[0] & 0x0f0f0f0f;
214
- q32[1] = q1[0] & 0xf0f0f0f0;
215
- q32[2] = q2[0] & 0x0f0f0f0f;
216
- q32[3] = q2[0] & 0xf0f0f0f0;
217
-
218
- float4 s = {0.f, 0.f, 0.f, 0.f};
219
- float smin = 0;
220
- for (int l = 0; l < 4; ++l) {
221
- s.x += y1[l] * q4[l+0]; s.y += y1[l+32] * q4[l+ 4];
222
- s.z += y2[l] * q4[l+8]; s.w += y2[l+32] * q4[l+12];
223
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
224
- }
225
- tmp += dall * (s.x * sc[0] + s.y * sc[1] * 1.f/16.f + s.z * sc[4] + s.w * sc[5] * 1.f/16.f) - dmin * smin;
226
- #else
227
- const uint16_t * q1 = (const uint16_t *)(x[i].qs + q_offset);
228
- const uint16_t * q2 = q1 + 32;
229
-
230
- q16[0] = q1[0] & 0x0f0f;
231
- q16[1] = q1[0] & 0xf0f0;
232
- q16[2] = q2[0] & 0x0f0f;
233
- q16[3] = q2[0] & 0xf0f0;
234
-
235
- float4 s = {0.f, 0.f, 0.f, 0.f};
236
- float smin = 0;
237
- for (int l = 0; l < 2; ++l) {
238
- s.x += y1[l] * q4[l+0]; s.y += y1[l+32] * q4[l+2];
239
- s.z += y2[l] * q4[l+4]; s.w += y2[l+32] * q4[l+6];
240
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
241
- }
242
- tmp += dall * (s.x * sc[0] + s.y * sc[1] * 1.f/16.f + s.z * sc[4] + s.w * sc[5] * 1.f/16.f) - dmin * smin;
243
- #endif
244
-
245
- }
246
-
247
- // sum up partial sums and write back result
248
- tmp = warp_reduce_sum(tmp);
249
-
250
- if (tid == 0) {
251
- dst[row] = tmp;
252
- }
253
- }
254
-
255
- static __global__ void dequantize_mul_mat_vec_q5_k(const void * __restrict__ vx, const float * __restrict__ yy, float * __restrict__ dst, const int ncols) {
256
-
257
- const int row = blockIdx.x;
258
- const int num_blocks_per_row = ncols / QK_K;
259
- const int ib0 = row*num_blocks_per_row;
260
-
261
- const block_q5_K * x = (const block_q5_K *)vx + ib0;
262
-
263
- float tmp = 0; // partial sum for thread in warp
264
-
265
- const uint16_t kmask1 = 0x3f3f;
266
- const uint16_t kmask2 = 0x0f0f;
267
- const uint16_t kmask3 = 0xc0c0;
268
-
269
- const int tid = threadIdx.x/2; // 0...15
270
- const int ix = threadIdx.x%2;
271
-
272
- const int il = tid/4; // 0...3
273
- const int ir = tid - 4*il;// 0...3
274
- const int n = 2;
275
-
276
- const int im = il/2; // 0 or 1. 0 computes 0,32 + 128,160, 1 computes 64,96 + 192,224
277
- const int in = il%2;
278
-
279
- const int l0 = n*(2*ir + in);
280
- const int q_offset = 32*im + l0;
281
- const int y_offset = 64*im + l0;
282
-
283
- const uint8_t hm1 = 1 << (2*im);
284
- const uint8_t hm2 = hm1 << 4;
285
-
286
- uint16_t aux[4];
287
- const uint8_t * sc = (const uint8_t *)aux;
288
-
289
- uint16_t q16[8];
290
- const uint8_t * q4 = (const uint8_t *)q16;
291
-
292
- for (int i = ix; i < num_blocks_per_row; i += 2) {
293
-
294
- const uint8_t * ql1 = x[i].qs + q_offset;
295
- const uint8_t * qh = x[i].qh + l0;
296
- const float * y1 = yy + i*QK_K + y_offset;
297
- const float * y2 = y1 + 128;
298
-
299
- const float dall = __low2half(x[i].dm);
300
- const float dmin = __high2half(x[i].dm);
301
-
302
- const uint16_t * a = (const uint16_t *)x[i].scales;
303
- aux[0] = a[im+0] & kmask1;
304
- aux[1] = a[im+2] & kmask1;
305
- aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
306
- aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
307
-
308
- float4 sum = {0.f, 0.f, 0.f, 0.f};
309
- float smin = 0;
310
- const uint16_t * q1 = (const uint16_t *)ql1;
311
- const uint16_t * q2 = q1 + 32;
312
- q16[0] = q1[0] & 0x0f0f;
313
- q16[1] = q1[8] & 0x0f0f;
314
- q16[2] = (q1[0] >> 4) & 0x0f0f;
315
- q16[3] = (q1[8] >> 4) & 0x0f0f;
316
- q16[4] = q2[0] & 0x0f0f;
317
- q16[5] = q2[8] & 0x0f0f;
318
- q16[6] = (q2[0] >> 4) & 0x0f0f;
319
- q16[7] = (q2[8] >> 4) & 0x0f0f;
320
- for (int l = 0; l < n; ++l) {
321
- sum.x += y1[l+ 0] * (q4[l +0] + (qh[l+ 0] & (hm1 << 0) ? 16 : 0))
322
- + y1[l+16] * (q4[l +2] + (qh[l+16] & (hm1 << 0) ? 16 : 0));
323
- sum.y += y1[l+32] * (q4[l +4] + (qh[l+ 0] & (hm1 << 1) ? 16 : 0))
324
- + y1[l+48] * (q4[l +6] + (qh[l+16] & (hm1 << 1) ? 16 : 0));
325
- sum.z += y2[l+ 0] * (q4[l +8] + (qh[l+ 0] & (hm2 << 0) ? 16 : 0))
326
- + y2[l+16] * (q4[l+10] + (qh[l+16] & (hm2 << 0) ? 16 : 0));
327
- sum.w += y2[l+32] * (q4[l+12] + (qh[l+ 0] & (hm2 << 1) ? 16 : 0))
328
- + y2[l+48] * (q4[l+14] + (qh[l+16] & (hm2 << 1) ? 16 : 0));
329
- smin += (y1[l] + y1[l+16]) * sc[2] + (y1[l+32] + y1[l+48]) * sc[3]
330
- + (y2[l] + y2[l+16]) * sc[6] + (y2[l+32] + y2[l+48]) * sc[7];
331
- }
332
- tmp += dall * (sum.x * sc[0] + sum.y * sc[1] + sum.z * sc[4] + sum.w * sc[5]) - dmin * smin;
333
- }
334
-
335
- // sum up partial sums and write back result
336
- tmp = warp_reduce_sum(tmp);
337
-
338
- if (threadIdx.x == 0) {
339
- dst[row] = tmp;
340
- }
341
- }
342
-
343
- static __global__ void dequantize_mul_mat_vec_q6_k(const void * __restrict__ vx, const float * __restrict__ yy, float * __restrict__ dst, const int ncols, int nrows) {
344
-
345
- static_assert(16%K_QUANTS_PER_ITERATION == 0, "16 must be divisible by K_QUANTS_PER_ITERATION");
346
-
347
- const int row = blockIdx.x*blockDim.y + threadIdx.y;
348
- if (row > nrows) return;
349
-
350
- const int num_blocks_per_row = ncols / QK_K;
351
- const int ib0 = row*num_blocks_per_row;
352
-
353
- const block_q6_K * x = (const block_q6_K *)vx + ib0;
354
-
355
- const int tid = threadIdx.x/K_QUANTS_PER_ITERATION; // 0...31 or 0...16
356
- const int ix = threadIdx.x%K_QUANTS_PER_ITERATION; // 0 or 0, 1
357
-
358
- const int step = 16/K_QUANTS_PER_ITERATION; // 16 or 8
359
-
360
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
361
- const int in = tid - step*im; // 0...15 or 0...7
362
-
363
- #if K_QUANTS_PER_ITERATION == 1
364
- const int l0 = K_QUANTS_PER_ITERATION*in; // 0...15
365
- const int is = 0;
366
- #else
367
- const int l0 = 4 * in; // 0, 4, 8, ..., 28
368
- const int is = in / 4;
369
- #endif
370
- const int ql_offset = 64*im + l0;
371
- const int qh_offset = 32*im + l0;
372
- const int s_offset = 8*im + is;
373
- const int y_offset = 128*im + l0;
374
-
375
- float tmp = 0; // partial sum for thread in warp
376
-
377
- for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
378
-
379
- const float * y = yy + i * QK_K + y_offset;
380
- const uint8_t * ql = x[i].ql + ql_offset;
381
- const uint8_t * qh = x[i].qh + qh_offset;
382
- const int8_t * s = x[i].scales + s_offset;
383
-
384
- const float d = x[i].d;
385
-
386
- #if K_QUANTS_PER_ITERATION == 1
387
- float sum = y[ 0] * s[0] * d * ((int8_t)((ql[ 0] & 0xF) | ((qh[ 0] & 0x03) << 4)) - 32)
388
- + y[16] * s[1] * d * ((int8_t)((ql[16] & 0xF) | ((qh[16] & 0x03) << 4)) - 32)
389
- + y[32] * s[2] * d * ((int8_t)((ql[32] & 0xF) | ((qh[ 0] & 0x0c) << 2)) - 32)
390
- + y[48] * s[3] * d * ((int8_t)((ql[48] & 0xF) | ((qh[16] & 0x0c) << 2)) - 32)
391
- + y[64] * s[4] * d * ((int8_t)((ql[ 0] >> 4) | ((qh[ 0] & 0x30) >> 0)) - 32)
392
- + y[80] * s[5] * d * ((int8_t)((ql[16] >> 4) | ((qh[16] & 0x30) >> 0)) - 32)
393
- + y[96] * s[6] * d * ((int8_t)((ql[32] >> 4) | ((qh[ 0] & 0xc0) >> 2)) - 32)
394
- +y[112] * s[7] * d * ((int8_t)((ql[48] >> 4) | ((qh[16] & 0xc0) >> 2)) - 32);
395
- tmp += sum;
396
- #else
397
- float sum = 0;
398
- for (int l = 0; l < 4; ++l) {
399
- sum += y[l+ 0] * s[0] * d * ((int8_t)((ql[l+ 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32)
400
- + y[l+32] * s[2] * d * ((int8_t)((ql[l+32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32)
401
- + y[l+64] * s[4] * d * ((int8_t)((ql[l+ 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32)
402
- + y[l+96] * s[6] * d * ((int8_t)((ql[l+32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32);
403
- }
404
- tmp += sum;
405
- #endif
406
-
407
- }
408
-
409
- // sum up partial sums and write back result
410
- tmp = warp_reduce_sum(tmp);
411
-
412
- if (tid == 0) {
413
- dst[row] = tmp;
414
- }
415
- }
416
-
417
- static __device__ void convert_f16(const void * vx, const int64_t ib, const int iqs, dfloat2 & v){
418
- const half * x = (const half *) vx;
419
- // load 2 halfs into register in a single instruction
420
- const half2 x_reg = *((half2 *) &(x[ib + iqs]));
421
- // automatic half -> float type cast if dfloat == float
422
- v.x = __low2float(x_reg);
423
- v.y = __high2float(x_reg);
424
- }
425
-
426
- static constexpr __device__ dequantize_kernel_t get_dequantize_kernel(ggml_type type) {
427
- return type == GGML_TYPE_Q4_0 ? dequantize_q4_0 :
428
- type == GGML_TYPE_Q4_1 ? dequantize_q4_1 :
429
- type == GGML_TYPE_Q5_0 ? dequantize_q5_0 :
430
- type == GGML_TYPE_Q5_1 ? dequantize_q5_1 :
431
- type == GGML_TYPE_Q8_0 ? dequantize_q8_0 :
432
- type == GGML_TYPE_F16 ? convert_f16 :
433
- nullptr;
434
- }
435
-
436
- template <ggml_type type>
437
- static __global__ void dequantize_mul_mat_vec(const void * __restrict__ vx, const dfloat * __restrict__ y, float * __restrict__ dst, const int ncols, const int nrows) {
438
- constexpr int qk = ggml_cuda_type_traits<type>::qk; // quantized weights per x block
439
- constexpr int qr = ggml_cuda_type_traits<type>::qr; // number of quantized weights per data value in x block
440
- constexpr dequantize_kernel_t dequantize_kernel = get_dequantize_kernel(type);
441
-
442
- const int64_t row = (int64_t)blockIdx.x*blockDim.y + threadIdx.y;
443
-
444
- if (row >= nrows) {
445
- return;
446
- }
447
-
448
- const int tid = threadIdx.x;
449
-
450
- const int iter_stride = 2*GGML_CUDA_DMMV_X;
451
- const int vals_per_iter = iter_stride / WARP_SIZE; // num quantized vals per thread and i iter
452
- const int y_offset = qr == 1 ? 1 : qk/2;
453
-
454
- // partial sum for each thread
455
- #ifdef GGML_CUDA_F16
456
- half2 tmp = {0.0f, 0.0f}; // two sums for f16 to take advantage of half2 intrinsics
457
- #else
458
- float tmp = 0.0f;
459
- #endif // GGML_CUDA_F16
460
-
461
- for (int i = 0; i < ncols; i += iter_stride) {
462
- const int col = i + vals_per_iter*tid;
463
- const int64_t ib = ((int64_t)row*ncols + col)/qk; // x block index
464
- const int iqs = (col%qk)/qr; // x quant index
465
- const int iybs = col - col%qk; // y block start index
466
-
467
- // processing >2 values per i iter is faster for fast GPUs
468
- #pragma unroll
469
- for (int j = 0; j < vals_per_iter; j += 2) {
470
- // process 2 vals per j iter
471
-
472
- // dequantize
473
- // for qr = 2 the iqs needs to increase by 1 per j iter because 2 weights per data val
474
- dfloat2 v;
475
- dequantize_kernel(vx, ib, iqs + j/qr, v);
476
-
477
- // matrix multiplication
478
- // for qr = 2 the y index needs to increase by 1 per j iter because of y_offset = qk/2
479
- #ifdef GGML_CUDA_F16
480
- if ( y_offset == 1 ) {
481
- // load 2 dfloats into register in a single instruction
482
- const dfloat2 y_reg = *((dfloat2 *) &(y[iybs + iqs + j/qr]));
483
- tmp += __hmul2(v, y_reg);
484
- }
485
- else {
486
- tmp += __hmul2(v, {
487
- y[iybs + iqs + j/qr + 0],
488
- y[iybs + iqs + j/qr + y_offset]
489
- });
490
- }
491
- #else
492
- if ( y_offset == 1 ) {
493
- // load 2 dfloats into register in a single instruction
494
- const dfloat2 y_reg = *((dfloat2 *) &(y[iybs + iqs + j/qr]));
495
- tmp += v.x * y_reg.x;
496
- tmp += v.y * y_reg.y;
497
- }
498
- else {
499
- tmp += v.x * y[iybs + iqs + j/qr + 0];
500
- tmp += v.y * y[iybs + iqs + j/qr + y_offset];
501
- }
502
- #endif // GGML_CUDA_F16
503
- }
504
- }
505
-
506
- // sum up partial sums and write back result
507
- tmp = warp_reduce_sum(tmp);
508
-
509
- if (tid == 0) {
510
- #ifdef GGML_CUDA_F16
511
- dst[row] = tmp.x + tmp.y;
512
- #else
513
- dst[row] = tmp;
514
- #endif // GGML_CUDA_F16
515
- }
516
- }
517
-
518
- static void dequantize_mul_mat_vec_q4_0_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
519
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
520
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
521
- // the number of rows may exceed maximum grid size in the y or z dimensions, use the x dimension instead
522
- const dim3 block_nums(block_num_y, 1, 1);
523
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
524
- dequantize_mul_mat_vec<GGML_TYPE_Q4_0>
525
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
526
- }
527
-
528
- static void dequantize_mul_mat_vec_q4_1_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
529
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
530
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
531
- const dim3 block_nums(block_num_y, 1, 1);
532
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
533
- dequantize_mul_mat_vec<GGML_TYPE_Q4_1>
534
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
535
- }
536
-
537
- static void dequantize_mul_mat_vec_q5_0_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
538
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
539
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
540
- const dim3 block_nums(block_num_y, 1, 1);
541
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
542
- dequantize_mul_mat_vec<GGML_TYPE_Q5_0>
543
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
544
- }
545
-
546
- static void dequantize_mul_mat_vec_q5_1_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
547
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
548
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
549
- const dim3 block_nums(block_num_y, 1, 1);
550
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
551
- dequantize_mul_mat_vec<GGML_TYPE_Q5_1>
552
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
553
- }
554
-
555
- static void dequantize_mul_mat_vec_q8_0_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
556
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
557
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
558
- const dim3 block_nums(block_num_y, 1, 1);
559
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
560
- dequantize_mul_mat_vec<GGML_TYPE_Q8_0>
561
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
562
- }
563
-
564
- static void dequantize_mul_mat_vec_q2_K_cuda(const void * vx, const float * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
565
- GGML_ASSERT(ncols % QK_K == 0);
566
- const int ny = 2; // very slightly faster than 1 even when K_QUANTS_PER_ITERATION = 2
567
- const int block_num_y = (nrows + ny - 1) / ny;
568
- const dim3 block_nums(block_num_y, 1, 1);
569
- const dim3 block_dims(32, ny, 1);
570
- dequantize_mul_mat_vec_q2_k<<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
571
- }
572
-
573
- static void dequantize_mul_mat_vec_q3_K_cuda(const void * vx, const float * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
574
- GGML_ASSERT(ncols % QK_K == 0);
575
- const int ny = 2 / K_QUANTS_PER_ITERATION;
576
- const int block_num_y = (nrows + ny - 1) / ny;
577
- const dim3 block_nums(block_num_y, 1, 1);
578
- const dim3 block_dims(32, ny, 1);
579
- dequantize_mul_mat_vec_q3_k<<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
580
- }
581
-
582
- static void dequantize_mul_mat_vec_q4_K_cuda(const void * vx, const float * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
583
- GGML_ASSERT(ncols % QK_K == 0);
584
- const int ny = 2 / K_QUANTS_PER_ITERATION;
585
- const int block_num_y = (nrows + ny - 1) / ny;
586
- const dim3 block_nums(block_num_y, 1, 1);
587
- const dim3 block_dims(32, ny, 1);
588
- dequantize_mul_mat_vec_q4_k<<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
589
- }
590
-
591
- static void dequantize_mul_mat_vec_q5_K_cuda(const void * vx, const float * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
592
- GGML_ASSERT(ncols % QK_K == 0);
593
- const dim3 block_dims(32, 1, 1);
594
- dequantize_mul_mat_vec_q5_k<<<nrows, block_dims, 0, stream>>>(vx, y, dst, ncols);
595
- }
596
-
597
- static void dequantize_mul_mat_vec_q6_K_cuda(const void * vx, const float * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
598
- GGML_ASSERT(ncols % QK_K == 0);
599
- const int ny = 2 / K_QUANTS_PER_ITERATION;
600
- const int block_num_y = (nrows + ny - 1) / ny;
601
- const dim3 block_nums(block_num_y, 1, 1);
602
- const dim3 block_dims(32, ny, 1);
603
- dequantize_mul_mat_vec_q6_k<<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
604
- }
605
-
606
- static void convert_mul_mat_vec_f16_cuda(const void * vx, const dfloat * y, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
607
- GGML_ASSERT(ncols % (GGML_CUDA_DMMV_X*2) == 0);
608
- const int block_num_y = (nrows + GGML_CUDA_MMV_Y - 1) / GGML_CUDA_MMV_Y;
609
- const dim3 block_nums(block_num_y, 1, 1);
610
- const dim3 block_dims(WARP_SIZE, GGML_CUDA_MMV_Y, 1);
611
- dequantize_mul_mat_vec<GGML_TYPE_F16>
612
- <<<block_nums, block_dims, 0, stream>>>(vx, y, dst, ncols, nrows);
613
- }
614
-
615
- void ggml_cuda_op_dequantize_mul_mat_vec(
616
- ggml_backend_cuda_context & ctx,
617
- const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst, const char * src0_dd_i, const float * src1_ddf_i,
618
- const char * src1_ddq_i, float * dst_dd_i, const int64_t row_low, const int64_t row_high, const int64_t src1_ncols,
619
- const int64_t src1_padded_row_size, cudaStream_t stream) {
620
- GGML_UNUSED(ctx);
621
- const int64_t ne00 = src0->ne[0];
622
- const int64_t row_diff = row_high - row_low;
623
-
624
- GGML_ASSERT(src1->type == GGML_TYPE_F32);
625
-
626
- // on some GPUs it is faster to convert src1 to half and to use half precision intrinsics
627
- #ifdef GGML_CUDA_F16
628
- ggml_cuda_pool_alloc<half> src1_dfloat_a(ctx.pool());
629
- half * src1_dfloat = nullptr; // dfloat == half
630
-
631
- bool src1_convert_f16 =
632
- src0->type == GGML_TYPE_Q4_0 || src0->type == GGML_TYPE_Q4_1 ||
633
- src0->type == GGML_TYPE_Q5_0 || src0->type == GGML_TYPE_Q5_1 ||
634
- src0->type == GGML_TYPE_Q8_0 || src0->type == GGML_TYPE_F16;
635
-
636
- if (src1_convert_f16) {
637
- src1_dfloat = src1_dfloat_a.alloc(ne00);
638
- const to_fp16_cuda_t to_fp16_cuda = ggml_get_to_fp16_cuda(src1->type);
639
- GGML_ASSERT(to_fp16_cuda != nullptr);
640
- to_fp16_cuda(src1_ddf_i, src1_dfloat, ne00, stream);
641
- }
642
- #else
643
- const dfloat * src1_dfloat = (const dfloat *) src1_ddf_i; // dfloat == float, no conversion
644
- #endif // GGML_CUDA_F16
645
-
646
- switch (src0->type) {
647
- case GGML_TYPE_Q4_0:
648
- dequantize_mul_mat_vec_q4_0_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
649
- break;
650
- case GGML_TYPE_Q4_1:
651
- dequantize_mul_mat_vec_q4_1_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
652
- break;
653
- case GGML_TYPE_Q5_0:
654
- dequantize_mul_mat_vec_q5_0_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
655
- break;
656
- case GGML_TYPE_Q5_1:
657
- dequantize_mul_mat_vec_q5_1_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
658
- break;
659
- case GGML_TYPE_Q8_0:
660
- dequantize_mul_mat_vec_q8_0_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
661
- break;
662
- case GGML_TYPE_Q2_K:
663
- dequantize_mul_mat_vec_q2_K_cuda(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
664
- break;
665
- case GGML_TYPE_Q3_K:
666
- dequantize_mul_mat_vec_q3_K_cuda(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
667
- break;
668
- case GGML_TYPE_Q4_K:
669
- dequantize_mul_mat_vec_q4_K_cuda(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
670
- break;
671
- case GGML_TYPE_Q5_K:
672
- dequantize_mul_mat_vec_q5_K_cuda(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
673
- break;
674
- case GGML_TYPE_Q6_K:
675
- dequantize_mul_mat_vec_q6_K_cuda(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
676
- break;
677
- case GGML_TYPE_F16:
678
- convert_mul_mat_vec_f16_cuda(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
679
- break;
680
- default:
681
- GGML_ABORT("fatal error");
682
- break;
683
- }
684
-
685
- GGML_UNUSED(src1);
686
- GGML_UNUSED(dst);
687
- GGML_UNUSED(src1_ddq_i);
688
- GGML_UNUSED(src1_ncols);
689
- GGML_UNUSED(src1_padded_row_size);
690
- }
691
-
692
- bool ggml_cuda_dmmv_type_supported(ggml_type src0_type) {
693
- return src0_type == GGML_TYPE_Q4_0 || src0_type == GGML_TYPE_Q4_1 ||
694
- src0_type == GGML_TYPE_Q5_0 || src0_type == GGML_TYPE_Q5_1 ||
695
- src0_type == GGML_TYPE_Q8_0 || src0_type == GGML_TYPE_Q2_K ||
696
- src0_type == GGML_TYPE_Q3_K || src0_type == GGML_TYPE_Q4_K ||
697
- src0_type == GGML_TYPE_Q5_K || src0_type == GGML_TYPE_Q6_K ||
698
- src0_type == GGML_TYPE_F16;
699
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ggml/src/ggml-cuda/dmmv.cuh DELETED
@@ -1,20 +0,0 @@
1
- #include "common.cuh"
2
-
3
- // dmmv = dequantize_mul_mat_vec
4
-
5
- // TODO: remove this?
6
- #ifndef GGML_CUDA_DMMV_X
7
- #define GGML_CUDA_DMMV_X 32
8
- #endif
9
-
10
- #ifndef GGML_CUDA_MMV_Y
11
- #define GGML_CUDA_MMV_Y 1
12
- #endif
13
-
14
- void ggml_cuda_op_dequantize_mul_mat_vec(
15
- ggml_backend_cuda_context & ctx,
16
- const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst, const char * src0_dd_i, const float * src1_ddf_i,
17
- const char * src1_ddq_i, float * dst_dd_i, const int64_t row_low, const int64_t row_high, const int64_t src1_ncols,
18
- const int64_t src1_padded_row_size, cudaStream_t stream);
19
-
20
- bool ggml_cuda_dmmv_type_supported(ggml_type src0_type);