char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Titaniumtownsycl: fix thread/block count in quantized cpy kernel launches (#27160)f275595dd

char/aliceai-t5-moe
87.6 KiB1433 linesraw
1#include "cpy.hpp"
2
3#include <float.h>
4#include <vector>
5
6#include "dequantize.hpp"
7#include "ggml-sycl/common.hpp"
8#include "ggml-sycl/presets.hpp"
9#include "ggml.h"
10
11static void cpy_1_f32_f32(const char * cxi, char * cdsti) {
12    const float * xi   = (const float *) cxi;
13    float *       dsti = (float *) cdsti;
14
15    *dsti = *xi;
16}
17
18static void cpy_1_f32_f16(const char * cxi, char * cdsti) {
19    const float * xi   = (const float *) cxi;
20    sycl::half *  dsti = (sycl::half *) cdsti;
21
22    *dsti = sycl::vec<float, 1>(*xi).convert<sycl::half, sycl::rounding_mode::automatic>()[0];
23}
24
25static void cpy_1_f16_f16(const char * cxi, char * cdsti) {
26    const sycl::half * xi   = (const sycl::half *) cxi;
27    sycl::half *       dsti = (sycl::half *) cdsti;
28
29    *dsti = *xi;
30}
31
32static void cpy_1_f16_f32(const char * cxi, char * cdsti) {
33    const sycl::half * xi   = (const sycl::half *) cxi;
34    float *            dsti = (float *) cdsti;
35
36    *dsti = *xi;
37}
38
39static void cpy_1_i16_i16(const char * cxi, char * cdsti) {
40    const int16_t * xi   = (const int16_t *) cxi;
41    int16_t *       dsti = (int16_t *) cdsti;
42
43    *dsti = *xi;
44}
45
46static void cpy_1_i32_i32(const char * cxi, char * cdsti) {
47    const int32_t * xi   = (const int32_t *) cxi;
48    int32_t *       dsti = (int32_t *) cdsti;
49
50    *dsti = *xi;
51}
52
53static void cpy_1_f32_i32(const char * cxi, char * cdsti) {
54    const float * xi     = (const float *) cxi;
55    int32_t *     dsti   = (int32_t *) cdsti;
56
57    *dsti = (int32_t) *xi;
58}
59
60static void cpy_1_i32_f32(const char * cxi, char * cdsti) {
61    const int32_t * xi   = (const int32_t *) cxi;
62    float *         dsti = (float *) cdsti;
63
64    *dsti = (float) *xi;
65}
66
67#ifdef GGML_SYCL_HAS_BF16
68static void cpy_1_f32_bf16(const char * cxi, char * cdsti) {
69    const float * xi   = (const float *) cxi;
70    sycl::ext::oneapi::bfloat16 *  dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
71
72    *dsti = sycl::ext::oneapi::bfloat16(*xi);
73}
74
75static void cpy_1_bf16_f32(const char * cxi, char * cdsti) {
76    const sycl::ext::oneapi::bfloat16 * xi   = (const sycl::ext::oneapi::bfloat16 *) cxi;
77    float *            dsti = (float *) cdsti;
78
79    *dsti = static_cast<float>(*xi);
80}
81
82static void cpy_1_bf16_bf16(const char * cxi, char * cdsti) {
83    const sycl::ext::oneapi::bfloat16 * xi   = (const sycl::ext::oneapi::bfloat16 *) cxi;
84    sycl::ext::oneapi::bfloat16 *       dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
85
86    *dsti = *xi;
87}
88
89static void cpy_1_f16_bf16(const char * cxi, char * cdsti) {
90    const sycl::half * xi   = (const sycl::half *) cxi;
91    sycl::ext::oneapi::bfloat16 *  dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
92
93    *dsti = sycl::ext::oneapi::bfloat16(static_cast<float>(*xi));
94}
95
96static void cpy_1_bf16_f16(const char * cxi, char * cdsti) {
97    const sycl::ext::oneapi::bfloat16 * xi   = (const sycl::ext::oneapi::bfloat16 *) cxi;
98    sycl::half *            dsti = (sycl::half *) cdsti;
99
100    *dsti = sycl::half(static_cast<float>(*xi));
101}
102#endif
103
104template <cpy_kernel_t cpy_1>
105static void cpy_f32_f16(const char * cx, char * cdst, const int ne, const int ne00, const int ne01, const int ne02,
106                        const int nb00, const int nb01, const int nb02, const int nb03, const int ne10, const int ne11,
107                        const int ne12, const int nb10, const int nb11, const int nb12, const int nb13,
108                        const sycl::nd_item<3> & item_ct1) {
109    const int i = item_ct1.get_local_range(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2);
110
111    if (i >= ne) {
112        return;
113    }
114
115    // determine indices i02/i12, i01/i11, i00/i10 as a function of index i of flattened tensor
116    // then combine those indices with the corresponding byte offsets to get the total offsets
117    const int i03      = i / (ne00 * ne01 * ne02);
118    const int i02      = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
119    const int i01      = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
120    const int i00      = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
121    const int x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
122
123    const int i13        = i / (ne10 * ne11 * ne12);
124    const int i12        = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
125    const int i11        = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
126    const int i10        = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
127    const int dst_offset = i10 * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
128
129    cpy_1(cx + x_offset, cdst + dst_offset);
130}
131
132
133/* quantized type same copy */
134template<typename T>
135static void cpy_blck_q_q(const char * cxi, char * cdsti) {
136    const T * xi = (const T *) cxi;
137    T * dsti = (T *) cdsti;
138    *dsti = *xi;
139}
140
141
142static void cpy_blck_q8_0_f32(const char * cxi, char * cdsti) {
143    float * cdstf = (float *) (cdsti);
144
145    for (int j = 0; j < QK8_0; j += 2) {
146        dfloat2 dq;
147        dequantize_q8_0(cxi, 0, j, dq);
148        *(cdstf + j)     = dq.x();
149        *(cdstf + j + 1) = dq.y();
150    }
151}
152
153static void cpy_blck_q2_0_f32(const char * cxi, char * cdsti) {
154    const block_q2_0 * xi = (const block_q2_0 *) cxi;
155    float * cdstf = (float *) cdsti;
156
157    const float d = xi->d;
158
159    for (int j = 0; j < QK2_0; ++j) {
160        const int byte_index = j / 4;
161        const int bit_offset = (j % 4) * 2;
162        const int q = (xi->qs[byte_index] >> bit_offset) & 0x3;
163        cdstf[j] = (float) (q - 1) * d;
164    }
165}
166
167
168
169template <dequantize_kernel_t dequant, int qk> static void cpy_blck_q_f32(const char * cxi, char * cdsti) {
170    float * cdstf = (float *) (cdsti);
171
172    for (int j = 0; j < qk / 2; j++) {
173        dfloat2 dq;
174        dequant(cxi, 0, j, dq);
175        *(cdstf + j)          = dq.x();
176        *(cdstf + j + qk / 2) = dq.y();
177    }
178}
179
180
181template <typename T, int qk>
182static void cpy_q_q(const char * cx, char * cdst, const int ne, const int ne00, const int ne01, const int ne02,
183                      const int nb00, const int nb01, const int nb02, const int nb03, const int ne10, const int ne11,
184                      const int ne12, const int nb10, const int nb11, const int nb12, const int nb13,
185                      const sycl::nd_item<3> & item_ct1) {
186    const int i = (item_ct1.get_local_range(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2)) * qk;
187
188    if (i >= ne) {
189        return;
190    }
191
192    const int i03      = i / (ne00 * ne01 * ne02);
193    const int i02      = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
194    const int i01      = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
195    const int i00      = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
196    const int x_offset = (i00 / qk) * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
197
198
199    const int i13        = i / (ne10 * ne11 * ne12);
200    const int i12        = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
201    const int i11        = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
202    const int i10        = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
203    const int dst_offset = (i10 / qk) * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
204
205    cpy_blck_q_q<T>(cx + x_offset, cdst + dst_offset);
206}
207
208template <cpy_kernel_t cpy_blck, int qk>
209static void cpy_f32_q(const char * cx, char * cdst, const int ne, const int ne00, const int ne01, const int ne02,
210                      const int nb00, const int nb01, const int nb02, const int nb03, const int ne10, const int ne11,
211                      const int ne12, const int nb10, const int nb11, const int nb12, const int nb13,
212                      const sycl::nd_item<3> & item_ct1) {
213    const int i = (item_ct1.get_local_range(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2)) * qk;
214
215    if (i >= ne) {
216        return;
217    }
218
219
220    const int i03      = i / (ne00 * ne01 * ne02);
221    const int i02      = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
222    const int i01      = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
223    const int i00      = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
224    const int x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
225
226    const int i13        = i / (ne10 * ne11 * ne12);
227    const int i12        = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
228    const int i11        = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
229    const int i10        = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
230    const int dst_offset = (i10 / qk) * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
231
232    cpy_blck(cx + x_offset, cdst + dst_offset);
233}
234
235template <cpy_kernel_t cpy_blck, int qk>
236static void cpy_q_f32(const char * cx, char * cdst, const int ne, const int ne00, const int ne01, const int ne02,
237                      const int nb00, const int nb01, const int nb02, const int nb03, const int ne10, const int ne11,
238                      const int ne12, const int nb10, const int nb11, const int nb12, const int nb13,
239                      const sycl::nd_item<3> & item_ct1) {
240    const int i = (item_ct1.get_local_range(2) * item_ct1.get_group(2) + item_ct1.get_local_id(2)) * qk;
241
242    if (i >= ne) {
243        return;
244    }
245
246    const int i03      = i / (ne00 * ne01 * ne02);
247    const int i02      = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
248    const int i01      = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
249    const int i00      = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
250    const int x_offset = (i00 / qk) * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
251
252    const int i13        = i / (ne10 * ne11 * ne12);
253    const int i12        = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
254    const int i11        = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
255    const int i10        = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
256    const int dst_offset = i10 * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
257
258    cpy_blck(cx + x_offset, cdst + dst_offset);
259}
260
261static void ggml_cpy_f16_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
262                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
263                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
264                                  const int nb12, const int nb13, queue_ptr stream) {
265    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
266    {
267        dpct::has_capability_or_fail(stream->get_device(), { sycl::aspect::fp16 });
268
269        stream->parallel_for(
270            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
271                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
272            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
273                cpy_f32_f16<cpy_1_f16_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
274                                           nb10, nb11, nb12, nb13, item_ct1);
275            });
276    }
277}
278
279static void ggml_cpy_f32_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
280                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
281                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
282                                  const int nb12, const int nb13, queue_ptr stream) {
283    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
284    {
285        dpct::has_capability_or_fail(stream->get_device(), { sycl::aspect::fp16 });
286
287        stream->parallel_for(
288            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
289                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
290            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
291                cpy_f32_f16<cpy_1_f32_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
292                                           nb10, nb11, nb12, nb13, item_ct1);
293            });
294    }
295}
296
297static void ggml_cpy_f32_f16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
298                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
299                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
300                                  const int nb12, const int nb13, queue_ptr stream) {
301    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
302    {
303        dpct::has_capability_or_fail(stream->get_device(), { sycl::aspect::fp16 });
304
305        stream->parallel_for(
306            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
307                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
308            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
309                cpy_f32_f16<cpy_1_f32_f16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
310                                           nb10, nb11, nb12, nb13, item_ct1);
311            });
312    }
313}
314
315static void ggml_cpy_f32_i32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
316                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
317                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
318                                  const int nb12, const int nb13, queue_ptr stream) {
319    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
320    {
321        stream->parallel_for(
322            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
323                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
324            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
325                cpy_f32_f16<cpy_1_f32_i32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
326                                           nb10, nb11, nb12, nb13, item_ct1);
327            });
328    }
329}
330
331static void ggml_cpy_i32_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
332                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
333                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
334                                  const int nb12, const int nb13, queue_ptr stream) {
335    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
336    {
337        stream->parallel_for(
338            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
339                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
340            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
341                cpy_f32_f16<cpy_1_i32_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
342                                           nb10, nb11, nb12, nb13, item_ct1);
343            });
344    }
345}
346
347static void ggml_cpy_f32_q8_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
348                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
349                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
350                                   const int nb12, const int nb13, queue_ptr stream) {
351    GGML_ASSERT(ne % QK8_0 == 0);
352    const int num_blocks = ceil_div(ne / QK8_0, SYCL_CPY_BLOCK_SIZE);
353    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
354                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
355                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
356                             cpy_f32_q<cpy_blck_f32_q8_0, QK8_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
357                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
358                         });
359}
360
361static void ggml_cpy_q8_0_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
362                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
363                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
364                                   const int nb12, const int nb13, queue_ptr stream) {
365    GGML_ASSERT(ne % QK8_0 == 0);
366    const int num_blocks = ceil_div(ne / QK8_0, SYCL_CPY_BLOCK_SIZE);
367    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
368                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
369                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
370                             cpy_q_f32<cpy_blck_q8_0_f32, QK8_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
371                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
372                         });
373}
374
375static void ggml_cpy_q2_0_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
376                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
377                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
378                                   const int nb12, const int nb13, queue_ptr stream) {
379    GGML_ASSERT(ne % QK2_0 == 0);
380    const int num_blocks = ceil_div(ne / QK2_0, SYCL_CPY_BLOCK_SIZE);
381    stream->parallel_for(
382        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
383                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
384        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
385            cpy_q_f32<cpy_blck_q2_0_f32, QK2_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11,
386                                                ne12, nb10, nb11, nb12, nb13, item_ct1);
387        });
388}
389
390static void ggml_cpy_f32_q4_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
391                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
392                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
393                                   const int nb12, const int nb13, queue_ptr stream) {
394    GGML_ASSERT(ne % QK4_0 == 0);
395    const int num_blocks = ceil_div(ne / QK4_0, SYCL_CPY_BLOCK_SIZE);
396    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
397                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
398                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
399                             cpy_f32_q<cpy_blck_f32_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
400                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
401                         });
402}
403
404static void ggml_cpy_q4_0_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
405                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
406                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
407                                   const int nb12, const int nb13, queue_ptr stream) {
408    GGML_ASSERT(ne % QK4_0 == 0);
409    const int num_blocks = ceil_div(ne / QK4_0, SYCL_CPY_BLOCK_SIZE);
410    stream->parallel_for(
411        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
412                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
413        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
414            cpy_q_f32<cpy_blck_q_f32<dequantize_q4_0, QK4_0>, QK4_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02,
415                                                                     nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
416                                                                     item_ct1);
417        });
418}
419
420static void ggml_cpy_f32_q4_1_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
421                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
422                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
423                                   const int nb12, const int nb13, queue_ptr stream) {
424    GGML_ASSERT(ne % QK4_1 == 0);
425    const int num_blocks = ceil_div(ne / QK4_1, SYCL_CPY_BLOCK_SIZE);
426    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
427                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
428                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
429                             cpy_f32_q<cpy_blck_f32_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
430                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
431                         });
432}
433
434static void ggml_cpy_q4_1_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
435                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
436                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
437                                   const int nb12, const int nb13, queue_ptr stream) {
438    GGML_ASSERT(ne % QK4_1 == 0);
439    const int num_blocks = ceil_div(ne / QK4_1, SYCL_CPY_BLOCK_SIZE);
440    stream->parallel_for(
441        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
442                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
443        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
444            cpy_q_f32<cpy_blck_q_f32<dequantize_q4_1, QK4_1>, QK4_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02,
445                                                                     nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
446                                                                     item_ct1);
447        });
448}
449
450static void ggml_cpy_f32_q5_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
451                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
452                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
453                                   const int nb12, const int nb13, queue_ptr stream) {
454    GGML_ASSERT(ne % QK5_0 == 0);
455    const int num_blocks = ceil_div(ne / QK5_0, SYCL_CPY_BLOCK_SIZE);
456    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
457                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
458                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
459                             cpy_f32_q<cpy_blck_f32_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
460                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
461                         });
462}
463
464static void ggml_cpy_q5_0_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
465                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
466                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
467                                   const int nb12, const int nb13, queue_ptr stream) {
468    GGML_ASSERT(ne % QK5_0 == 0);
469    const int num_blocks = ceil_div(ne / QK5_0, SYCL_CPY_BLOCK_SIZE);
470    stream->parallel_for(
471        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
472                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
473        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
474            cpy_q_f32<cpy_blck_q_f32<dequantize_q5_0, QK5_0>, QK5_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02,
475                                                                     nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
476                                                                     item_ct1);
477        });
478}
479
480static void ggml_cpy_f32_q5_1_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
481                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
482                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
483                                   const int nb12, const int nb13, queue_ptr stream) {
484    GGML_ASSERT(ne % QK5_1 == 0);
485    const int num_blocks = ceil_div(ne / QK5_1, SYCL_CPY_BLOCK_SIZE);
486    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
487                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
488                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
489                             cpy_f32_q<cpy_blck_f32_q5_1, QK5_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03,
490                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
491                         });
492}
493
494static void ggml_cpy_q5_1_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
495                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
496                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
497                                   const int nb12, const int nb13, queue_ptr stream) {
498    GGML_ASSERT(ne % QK5_1 == 0);
499    const int num_blocks = ceil_div(ne / QK5_1, SYCL_CPY_BLOCK_SIZE);
500    stream->parallel_for(
501        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
502                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
503        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
504            cpy_q_f32<cpy_blck_q_f32<dequantize_q5_1, QK5_1>, QK5_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02,
505                                                                     nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
506                                                                     item_ct1);
507        });
508}
509
510static void ggml_cpy_mxfp4_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
511                                    const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
512                                    const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
513                                    const int nb12, const int nb13, queue_ptr stream) {
514    GGML_ASSERT(ne % QK_MXFP4 == 0);
515    const int num_blocks = ceil_div(ne / QK_MXFP4, SYCL_CPY_BLOCK_SIZE);
516    stream->parallel_for(
517        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
518                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
519        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
520            cpy_q_f32<cpy_blck_q_f32<dequantize_mxfp4, QK_MXFP4>, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
521                                                                             nb01, nb02, nb03, ne10, ne11, ne12,
522                                                                             nb10, nb11, nb12, nb13, item_ct1);
523        });
524}
525
526static void ggml_cpy_f32_iq4_nl_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
527                                     const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
528                                     const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
529                                     const int nb12, const int nb13, queue_ptr stream) {
530    GGML_ASSERT(ne % QK4_NL == 0);
531    const int num_blocks = ceil_div(ne / QK4_NL, SYCL_CPY_BLOCK_SIZE);
532    stream->parallel_for(
533        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
534                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
535        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
536            cpy_f32_q<cpy_blck_f32_iq4_nl, QK4_NL>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11,
537                                                   ne12, nb10, nb11, nb12, nb13, item_ct1);
538        });
539}
540
541static void cpy_blck_f16_q4_0(const char * cxi, char * cdsti) {
542    const sycl::half * xi = (const sycl::half *) cxi;
543    float xf[QK4_0];
544
545    for (int j = 0; j < QK4_0; ++j) {
546        xf[j] = (float) xi[j];
547    }
548
549    cpy_blck_f32_q4_0((const char *) xf, cdsti);
550}
551
552static void cpy_blck_f16_q4_1(const char * cxi, char * cdsti) {
553    const sycl::half * xi = (const sycl::half *) cxi;
554    float xf[QK4_1];
555
556    for (int j = 0; j < QK4_1; ++j) {
557        xf[j] = (float) xi[j];
558    }
559
560    cpy_blck_f32_q4_1((const char *) xf, cdsti);
561}
562
563static void cpy_blck_f16_q5_0(const char * cxi, char * cdsti) {
564    const sycl::half * xi = (const sycl::half *) cxi;
565    float xf[QK5_0];
566
567    for (int j = 0; j < QK5_0; ++j) {
568        xf[j] = (float) xi[j];
569    }
570
571    cpy_blck_f32_q5_0((const char *) xf, cdsti);
572}
573
574static void ggml_cpy_f16_q4_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
575                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
576                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
577                                   const int nb12, const int nb13, queue_ptr stream) {
578    GGML_ASSERT(ne % QK4_0 == 0);
579    const int num_blocks = ceil_div(ne / QK4_0, SYCL_CPY_BLOCK_SIZE);
580    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
581                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
582                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
583                             cpy_f32_q<cpy_blck_f16_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02,
584                                                                 nb00, nb01, nb02, nb03,
585                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
586                         });
587}
588
589static void ggml_cpy_f16_q4_1_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
590                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
591                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
592                                   const int nb12, const int nb13, queue_ptr stream) {
593    GGML_ASSERT(ne % QK4_1 == 0);
594    const int num_blocks = ceil_div(ne / QK4_1, SYCL_CPY_BLOCK_SIZE);
595    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
596                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
597                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
598                             cpy_f32_q<cpy_blck_f16_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02,
599                                                                 nb00, nb01, nb02, nb03,
600                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
601                         });
602}
603
604static void ggml_cpy_f16_q5_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
605                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
606                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
607                                   const int nb12, const int nb13, queue_ptr stream) {
608    GGML_ASSERT(ne % QK5_0 == 0);
609    const int num_blocks = ceil_div(ne / QK5_0, SYCL_CPY_BLOCK_SIZE);
610    stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
611                                           sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
612                         [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
613                             cpy_f32_q<cpy_blck_f16_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02,
614                                                                 nb00, nb01, nb02, nb03,
615                                                                 ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
616                         });
617}
618
619static bool ggml_sycl_is_quantized_type(enum ggml_type type) {
620    switch (type) {
621        case GGML_TYPE_Q1_0:
622        case GGML_TYPE_Q2_0:
623        case GGML_TYPE_Q4_0:
624        case GGML_TYPE_Q4_1:
625        case GGML_TYPE_Q5_0:
626        case GGML_TYPE_Q5_1:
627        case GGML_TYPE_Q8_0:
628        case GGML_TYPE_MXFP4:
629        case GGML_TYPE_NVFP4:
630        case GGML_TYPE_Q2_K:
631        case GGML_TYPE_Q3_K:
632        case GGML_TYPE_Q4_K:
633        case GGML_TYPE_Q5_K:
634        case GGML_TYPE_Q6_K:
635        case GGML_TYPE_IQ2_XXS:
636        case GGML_TYPE_IQ2_XS:
637        case GGML_TYPE_IQ2_S:
638        case GGML_TYPE_IQ3_XXS:
639        case GGML_TYPE_IQ3_S:
640        case GGML_TYPE_IQ1_S:
641        case GGML_TYPE_IQ1_M:
642        case GGML_TYPE_IQ4_NL:
643        case GGML_TYPE_IQ4_XS:
644            return true;
645        default:
646            return false;
647    }
648}
649
650static bool ggml_sycl_can_quantize_rows_sycl(enum ggml_type type) {
651    switch (type) {
652        case GGML_TYPE_Q1_0:
653        case GGML_TYPE_Q2_0:
654        case GGML_TYPE_Q4_0:
655        case GGML_TYPE_Q4_1:
656        case GGML_TYPE_Q5_0:
657        case GGML_TYPE_Q5_1:
658        case GGML_TYPE_Q8_0:
659        case GGML_TYPE_MXFP4:
660        case GGML_TYPE_NVFP4:
661        case GGML_TYPE_Q2_K:
662        case GGML_TYPE_Q3_K:
663        case GGML_TYPE_Q4_K:
664        case GGML_TYPE_Q5_K:
665        case GGML_TYPE_Q6_K:
666        case GGML_TYPE_IQ4_NL:
667        case GGML_TYPE_IQ4_XS:
668            return true;
669        default:
670            return false;
671    }
672}
673
674template <typename SrcScalar>
675static inline float ggml_sycl_src_to_f32(const SrcScalar & x) {
676    return (float) x;
677}
678
679#ifdef GGML_SYCL_HAS_BF16
680template <>
681inline float ggml_sycl_src_to_f32<sycl::ext::oneapi::bfloat16>(const sycl::ext::oneapi::bfloat16 & x) {
682    return static_cast<float>(x);
683}
684
685template <>
686inline float ggml_sycl_src_to_f32<ggml_bf16_t>(const ggml_bf16_t & x) {
687    union {
688        uint32_t u32;
689        float f32;
690    } value;
691
692    value.u32 = (uint32_t) x.bits << 16;
693    return value.f32;
694}
695#endif
696
697template <typename SrcScalar, cpy_kernel_t quantize_block, int qk>
698static void ggml_sycl_quantize_rows_q(const char * cx, char * cdst, const int64_t ne,
699                                      const int64_t ne00, const int64_t ne01, const int64_t ne02,
700                                      const size_t nb00, const size_t nb01, const size_t nb02, const size_t nb03,
701                                      const int64_t ne10, const int64_t ne11, const int64_t ne12,
702                                      const size_t nb10, const size_t nb11, const size_t nb12, const size_t nb13,
703                                      queue_ptr stream) {
704    GGML_ASSERT(ne % qk == 0);
705    GGML_ASSERT(ne00 % qk == 0);
706
707    const int64_t total_blocks = ne / qk;
708    constexpr int block_size = 256;
709    const int64_t grid_size = ceil_div(total_blocks, (int64_t) block_size);
710
711    stream->parallel_for(sycl::nd_range<1>(grid_size * block_size, block_size),
712                        [=](sycl::nd_item<1> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
713        const int64_t block_idx = item_ct1.get_global_linear_id();
714        if (block_idx >= total_blocks) {
715            return;
716        }
717
718        const int64_t i = block_idx * qk;
719
720        const int64_t i03 = i / (ne00 * ne01 * ne02);
721        const int64_t i02 = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
722        const int64_t i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
723        const int64_t i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
724        const size_t x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
725
726        const int64_t i13 = i / (ne10 * ne11 * ne12);
727        const int64_t i12 = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
728        const int64_t i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
729        const int64_t i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
730        const size_t dst_offset = (i10 / qk) * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
731
732        float xf[qk];
733        if (nb00 == sizeof(SrcScalar)) {
734            const SrcScalar * src_row = (const SrcScalar *) (cx + x_offset);
735            for (int j = 0; j < qk; ++j) {
736                xf[j] = ggml_sycl_src_to_f32(src_row[j]);
737            }
738        } else {
739            for (int j = 0; j < qk; ++j) {
740                const SrcScalar * src_val = (const SrcScalar *) (cx + x_offset + j * nb00);
741                xf[j] = ggml_sycl_src_to_f32(*src_val);
742            }
743        }
744
745        quantize_block((const char *) xf, cdst + dst_offset);
746    });
747}
748
749template <typename SrcScalar>
750static void ggml_sycl_quantize_rows_sycl(const char * cx, char * cdst, const ggml_tensor * src0, const ggml_tensor * src1,
751                                         const int64_t ne, const int64_t ne00, const int64_t ne01, const int64_t ne02,
752                                         const size_t nb00, const size_t nb01, const size_t nb02, const size_t nb03,
753                                         const int64_t ne10, const int64_t ne11, const int64_t ne12, const size_t nb10,
754                                         const size_t nb11, const size_t nb12, const size_t nb13, queue_ptr stream) {
755    GGML_UNUSED(src0);
756    GGML_UNUSED(src1);
757
758    switch (src1->type) {
759        case GGML_TYPE_Q8_0:
760            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q8_0, QK8_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
761                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
762                                                                            nb12, nb13, stream);
763            break;
764        case GGML_TYPE_Q1_0:
765            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q1_0, QK1_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
766                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
767                                                                            nb12, nb13, stream);
768            break;
769        case GGML_TYPE_Q2_0:
770            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q2_0, QK2_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
771                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
772                                                                            nb12, nb13, stream);
773            break;
774        case GGML_TYPE_Q5_1:
775            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q5_1, QK5_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
776                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
777                                                                            nb12, nb13, stream);
778            break;
779        case GGML_TYPE_Q5_0:
780            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
781                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
782                                                                            nb12, nb13, stream);
783            break;
784        case GGML_TYPE_Q4_1:
785            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
786                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
787                                                                            nb12, nb13, stream);
788            break;
789        case GGML_TYPE_Q4_0:
790            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
791                                                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11,
792                                                                            nb12, nb13, stream);
793            break;
794        case GGML_TYPE_IQ4_NL:
795            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_iq4_nl, QK4_NL>(cx, cdst, ne, ne00, ne01, ne02, nb00,
796                                                                               nb01, nb02, nb03, ne10, ne11, ne12,
797                                                                               nb10, nb11, nb12, nb13, stream);
798            break;
799        case GGML_TYPE_MXFP4:
800            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_mxfp4, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
801                                                                                nb01, nb02, nb03, ne10, ne11, ne12,
802                                                                                nb10, nb11, nb12, nb13, stream);
803            break;
804        case GGML_TYPE_NVFP4:
805            ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_nvfp4, QK_NVFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
806                                                                                nb01, nb02, nb03, ne10, ne11, ne12,
807                                                                                nb10, nb11, nb12, nb13, stream);
808            break;
809        default:
810            GGML_ABORT("unsupported quantized target type in sycl quantizer src1->type=%s\n",
811                       ggml_type_name(src1->type));
812    }
813}
814
815static void ggml_cpy_f16_f16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
816                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
817                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
818                                  const int nb12, const int nb13, queue_ptr stream) {
819    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
820    {
821        dpct::has_capability_or_fail(stream->get_device(), { sycl::aspect::fp16 });
822
823        stream->parallel_for(
824            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
825                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
826            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
827                cpy_f32_f16<cpy_1_f16_f16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
828                                           nb10, nb11, nb12, nb13, item_ct1);
829            });
830    }
831}
832
833static void ggml_cpy_i16_i16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
834                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
835                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
836                                  const int nb12, const int nb13, queue_ptr stream) {
837    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
838    {
839        // dpct::has_capability_or_fail(stream->get_device(),
840        //                              {sycl::aspect::fp16});
841
842        stream->parallel_for(
843            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
844                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
845            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
846                cpy_f32_f16<cpy_1_i16_i16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
847                                           nb10, nb11, nb12, nb13, item_ct1);
848            });
849    }
850}
851
852static void ggml_cpy_i32_i32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
853                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
854                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
855                                  const int nb12, const int nb13, queue_ptr stream) {
856    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
857    {
858        // dpct::has_capability_or_fail(stream->get_device(),
859        //                              {sycl::aspect::fp16});
860
861        stream->parallel_for(
862            sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
863                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
864            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
865                cpy_f32_f16<cpy_1_i32_i32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
866                                           nb10, nb11, nb12, nb13, item_ct1);
867            });
868    }
869}
870
871static void ggml_cpy_q8_0_q8_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
872                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
873                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
874                                   const int nb12, const int nb13, queue_ptr stream) {
875    GGML_ASSERT(ne % QK8_0 == 0);
876    const int num_blocks = ceil_div(ne / QK8_0, SYCL_CPY_BLOCK_SIZE);
877    stream->parallel_for(
878        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
879                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
880                              [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
881            cpy_q_q<block_q8_0, QK8_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
882        });
883}
884
885
886static void ggml_cpy_q5_0_q5_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
887                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
888                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
889                                   const int nb12, const int nb13, queue_ptr stream) {
890    GGML_ASSERT(ne % QK5_0 == 0);
891    const int num_blocks = ceil_div(ne / QK5_0, SYCL_CPY_BLOCK_SIZE);
892    stream->parallel_for(
893        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
894                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
895                              [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
896            cpy_q_q<block_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
897        });
898}
899
900
901static void ggml_cpy_q5_1_q5_1(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
902                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
903                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
904                                   const int nb12, const int nb13, queue_ptr stream) {
905    GGML_ASSERT(ne % QK5_1 == 0);
906    const int num_blocks = ceil_div(ne / QK5_1, SYCL_CPY_BLOCK_SIZE);
907
908    stream->parallel_for(
909        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
910                              sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
911                              [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
912            cpy_q_q<block_q5_1, QK5_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
913        });
914}
915
916
917static void ggml_cpy_q4_0_q4_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
918                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
919                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
920                                   const int nb12, const int nb13, queue_ptr stream) {
921    GGML_ASSERT(ne % QK4_0 == 0);
922    const int num_blocks = ceil_div(ne / QK4_0, SYCL_CPY_BLOCK_SIZE);
923    stream->parallel_for(
924        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
925        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
926            cpy_q_q<block_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
927        });
928}
929
930
931static void ggml_cpy_q4_1_q4_1(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
932                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
933                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
934                                   const int nb12, const int nb13, queue_ptr stream) {
935
936    GGML_ASSERT(ne % QK4_1 == 0);
937    const int num_blocks = ceil_div(ne / QK4_1, SYCL_CPY_BLOCK_SIZE);
938    stream->parallel_for(
939        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
940        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
941            cpy_q_q<block_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
942        });
943}
944
945static void ggml_cpy_q1_0_q1_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
946                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
947                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
948                                   const int nb12, const int nb13, queue_ptr stream) {
949    GGML_ASSERT(ne % QK1_0 == 0);
950    const int num_blocks = ceil_div(ne / QK1_0, SYCL_CPY_BLOCK_SIZE);
951    stream->parallel_for(
952        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
953        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
954            cpy_q_q<block_q1_0, QK1_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
955        });
956}
957
958static void ggml_cpy_q2_0_q2_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
959                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
960                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
961                                   const int nb12, const int nb13, queue_ptr stream) {
962    GGML_ASSERT(ne % QK2_0 == 0);
963    const int num_blocks = ceil_div(ne / QK2_0, SYCL_CPY_BLOCK_SIZE);
964    stream->parallel_for(
965        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
966        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
967            cpy_q_q<block_q2_0, QK2_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
968        });
969}
970
971static void ggml_cpy_mxfp4_mxfp4(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
972                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
973                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
974                                   const int nb12, const int nb13, queue_ptr stream) {
975    GGML_ASSERT(ne % QK_MXFP4 == 0);
976    const int num_blocks = ceil_div(ne / QK_MXFP4, SYCL_CPY_BLOCK_SIZE);
977    stream->parallel_for(
978        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
979        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
980            cpy_q_q<block_mxfp4, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
981        });
982}
983
984static void ggml_cpy_nvfp4_nvfp4(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
985                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
986                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
987                                   const int nb12, const int nb13, queue_ptr stream) {
988    GGML_ASSERT(ne % QK_NVFP4 == 0);
989    const int num_blocks = ceil_div(ne / QK_NVFP4, SYCL_CPY_BLOCK_SIZE);
990    stream->parallel_for(
991        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
992        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
993            cpy_q_q<block_nvfp4, QK_NVFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
994        });
995}
996
997static void ggml_cpy_q2_K_q2_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
998                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
999                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1000                                   const int nb12, const int nb13, queue_ptr stream) {
1001    GGML_ASSERT(ne % QK_K == 0);
1002    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1003    stream->parallel_for(
1004        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1005        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1006            cpy_q_q<block_q2_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1007        });
1008}
1009
1010static void ggml_cpy_q3_K_q3_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1011                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1012                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1013                                   const int nb12, const int nb13, queue_ptr stream) {
1014    GGML_ASSERT(ne % QK_K == 0);
1015    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1016    stream->parallel_for(
1017        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1018        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1019            cpy_q_q<block_q3_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1020        });
1021}
1022
1023static void ggml_cpy_q4_K_q4_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1024                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1025                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1026                                   const int nb12, const int nb13, queue_ptr stream) {
1027    GGML_ASSERT(ne % QK_K == 0);
1028    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1029    stream->parallel_for(
1030        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1031        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1032            cpy_q_q<block_q4_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1033        });
1034}
1035
1036static void ggml_cpy_q5_K_q5_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1037                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1038                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1039                                   const int nb12, const int nb13, queue_ptr stream) {
1040    GGML_ASSERT(ne % QK_K == 0);
1041    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1042    stream->parallel_for(
1043        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1044        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1045            cpy_q_q<block_q5_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1046        });
1047}
1048
1049static void ggml_cpy_q6_K_q6_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1050                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1051                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1052                                   const int nb12, const int nb13, queue_ptr stream) {
1053    GGML_ASSERT(ne % QK_K == 0);
1054    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1055    stream->parallel_for(
1056        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1057        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1058            cpy_q_q<block_q6_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1059        });
1060}
1061
1062static void ggml_cpy_iq2_xxs_iq2_xxs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1063                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1064                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1065                                   const int nb12, const int nb13, queue_ptr stream) {
1066    GGML_ASSERT(ne % QK_K == 0);
1067    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1068    stream->parallel_for(
1069        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1070        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1071            cpy_q_q<block_iq2_xxs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1072        });
1073}
1074
1075static void ggml_cpy_iq2_xs_iq2_xs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1076                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1077                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1078                                   const int nb12, const int nb13, queue_ptr stream) {
1079    GGML_ASSERT(ne % QK_K == 0);
1080    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1081    stream->parallel_for(
1082        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1083        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1084            cpy_q_q<block_iq2_xs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1085        });
1086}
1087
1088static void ggml_cpy_iq2_s_iq2_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1089                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1090                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1091                                   const int nb12, const int nb13, queue_ptr stream) {
1092    GGML_ASSERT(ne % QK_K == 0);
1093    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1094    stream->parallel_for(
1095        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1096        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1097            cpy_q_q<block_iq2_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1098        });
1099}
1100
1101static void ggml_cpy_iq3_xxs_iq3_xxs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1102                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1103                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1104                                   const int nb12, const int nb13, queue_ptr stream) {
1105    GGML_ASSERT(ne % QK_K == 0);
1106    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1107    stream->parallel_for(
1108        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1109        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1110            cpy_q_q<block_iq3_xxs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1111        });
1112}
1113
1114static void ggml_cpy_iq1_s_iq1_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1115                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1116                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1117                                   const int nb12, const int nb13, queue_ptr stream) {
1118    GGML_ASSERT(ne % QK_K == 0);
1119    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1120    stream->parallel_for(
1121        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1122        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1123            cpy_q_q<block_iq1_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1124        });
1125}
1126
1127static void ggml_cpy_iq1_m_iq1_m(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1128                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1129                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1130                                   const int nb12, const int nb13, queue_ptr stream) {
1131    GGML_ASSERT(ne % QK_K == 0);
1132    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1133    stream->parallel_for(
1134        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1135        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1136            cpy_q_q<block_iq1_m, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1137        });
1138}
1139
1140static void ggml_cpy_iq4_nl_iq4_nl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1141                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1142                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1143                                   const int nb12, const int nb13, queue_ptr stream) {
1144    GGML_ASSERT(ne % QK4_NL == 0);
1145    const int num_blocks = ceil_div(ne / QK4_NL, SYCL_CPY_BLOCK_SIZE);
1146    stream->parallel_for(
1147        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1148        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1149            cpy_q_q<block_iq4_nl, QK4_NL>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1150        });
1151}
1152
1153static void ggml_cpy_iq3_s_iq3_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1154                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1155                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1156                                   const int nb12, const int nb13, queue_ptr stream) {
1157    GGML_ASSERT(ne % QK_K == 0);
1158    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1159    stream->parallel_for(
1160        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1161        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1162            cpy_q_q<block_iq3_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1163        });
1164}
1165
1166static void ggml_cpy_iq4_xs_iq4_xs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1167                                   const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1168                                   const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1169                                   const int nb12, const int nb13, queue_ptr stream) {
1170    GGML_ASSERT(ne % QK_K == 0);
1171    const int num_blocks = ceil_div(ne / QK_K, SYCL_CPY_BLOCK_SIZE);
1172    stream->parallel_for(
1173        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1174        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1175            cpy_q_q<block_iq4_xs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1176        });
1177}
1178
1179#ifdef GGML_SYCL_HAS_BF16
1180static void ggml_cpy_f32_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1181                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1182                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1183                                  const int nb12, const int nb13, queue_ptr stream) {
1184    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1185    stream->parallel_for(
1186        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1187                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1188        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1189            cpy_f32_f16<cpy_1_f32_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1190                                           nb10, nb11, nb12, nb13, item_ct1);
1191        });
1192}
1193
1194static void ggml_cpy_bf16_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1195                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1196                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1197                                  const int nb12, const int nb13, queue_ptr stream) {
1198    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1199    stream->parallel_for(
1200        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1201                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1202        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1203            cpy_f32_f16<cpy_1_bf16_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1204                                           nb10, nb11, nb12, nb13, item_ct1);
1205        });
1206}
1207
1208static void ggml_cpy_bf16_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1209                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1210                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1211                                  const int nb12, const int nb13, queue_ptr stream) {
1212    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1213    stream->parallel_for(
1214        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1215                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1216        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1217            cpy_f32_f16<cpy_1_bf16_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1218                                            nb10, nb11, nb12, nb13, item_ct1);
1219        });
1220}
1221
1222static void ggml_cpy_f16_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1223                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1224                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1225                                  const int nb12, const int nb13, queue_ptr stream) {
1226    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1227    stream->parallel_for(
1228        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1229                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1230        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1231            cpy_f32_f16<cpy_1_f16_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1232                                           nb10, nb11, nb12, nb13, item_ct1);
1233        });
1234}
1235
1236static void ggml_cpy_bf16_f16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1237                                  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1238                                  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1239                                  const int nb12, const int nb13, queue_ptr stream) {
1240    const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1241    stream->parallel_for(
1242        sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1243                          sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1244        [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]]{
1245            cpy_f32_f16<cpy_1_bf16_f16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1246                                           nb10, nb11, nb12, nb13, item_ct1);
1247        });
1248}
1249#endif
1250
1251void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, const ggml_tensor * src1) try {
1252    // Unlike other operators ggml_sycl_cpy takes 2 distinct tensors instead of a dst ggml_tensor and rely on its src field
1253    GGML_SYCL_DEBUG("ggml_sycl_cpy: src0->type=%s, src1->type=%s\n",
1254        ggml_type_name(src0->type), ggml_type_name(src1->type));
1255    scope_op_debug_print scope_dbg_print(__func__, src1, /*num_src=*/0, debug_get_tensor_str("\tsrc0", src0));
1256    const int64_t ne = ggml_nelements(src0);
1257    GGML_ASSERT(ne == ggml_nelements(src1));
1258
1259    GGML_TENSOR_BINARY_OP_LOCALS01;
1260
1261    SYCL_CHECK(ggml_sycl_set_device(ctx.device));
1262    queue_ptr main_stream = ctx.stream();
1263
1264    char * src0_ddc = (char *) src0->data;
1265    char * src1_ddc = (char *) src1->data;
1266    if ((src0->type == src1->type) && (ggml_is_contiguous(src0) && ggml_is_contiguous(src1))) {
1267        GGML_SYCL_DEBUG("%s: memcpy path\n", __func__);
1268        main_stream->memcpy(src1_ddc, src0_ddc, ggml_nbytes(src0));
1269    } else if (src0->type == GGML_TYPE_F32 && ggml_sycl_is_quantized_type(src1->type)) {
1270        GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1271        ggml_sycl_quantize_rows_sycl<float>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02, nb00, nb01,
1272                                            nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1273    } else if (src0->type == GGML_TYPE_F16 && ggml_sycl_is_quantized_type(src1->type)) {
1274        GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1275        ggml_sycl_quantize_rows_sycl<sycl::half>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02, nb00,
1276                                                 nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
1277                                                 main_stream);
1278#ifdef GGML_SYCL_HAS_BF16
1279    } else if (src0->type == GGML_TYPE_BF16 && ggml_sycl_is_quantized_type(src1->type)) {
1280        GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1281        ggml_sycl_quantize_rows_sycl<ggml_bf16_t>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02,
1282                                                  nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11,
1283                                                  nb12, nb13, main_stream);
1284#endif
1285    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F32) {
1286        ggml_cpy_f32_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1287                              nb11, nb12, nb13, main_stream);
1288    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F16) {
1289        ggml_cpy_f32_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1290                              nb11, nb12, nb13, main_stream);
1291    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_I32) {
1292        ggml_cpy_f32_i32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1293                              nb11, nb12, nb13, main_stream);
1294    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q8_0) {
1295        ggml_cpy_f32_q8_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1296                               nb11, nb12, nb13, main_stream);
1297    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q4_0) {
1298        ggml_cpy_f32_q4_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1299                               nb11, nb12, nb13, main_stream);
1300    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q4_1) {
1301        ggml_cpy_f32_q4_1_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1302                               nb11, nb12, nb13, main_stream);
1303    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F32) {
1304        ggml_cpy_f16_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1305                              nb11, nb12, nb13, main_stream);
1306    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F16) {
1307        ggml_cpy_f16_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1308                              nb11, nb12, nb13, main_stream);
1309    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q4_0) {
1310        ggml_cpy_f16_q4_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1311                               nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1312    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q4_1) {
1313        ggml_cpy_f16_q4_1_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1314                               nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1315    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q5_0) {
1316        ggml_cpy_f16_q5_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1317                               nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1318    } else if (src0->type == GGML_TYPE_I16 && src1->type == GGML_TYPE_I16) {
1319        ggml_cpy_i16_i16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1320                              nb11, nb12, nb13, main_stream);
1321    } else if (src0->type == GGML_TYPE_I32 && src1->type == GGML_TYPE_I32) {
1322        ggml_cpy_i32_i32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1323                              nb11, nb12, nb13, main_stream);
1324    } else if (src0->type == GGML_TYPE_I32 && src1->type == GGML_TYPE_F32) {
1325        ggml_cpy_i32_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1326                              nb11, nb12, nb13, main_stream);
1327    } else if (src0->type == GGML_TYPE_Q4_0 && src1->type == GGML_TYPE_F32) {
1328        ggml_cpy_q4_0_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1329                               nb11, nb12, nb13, main_stream);
1330    } else if (src0->type == GGML_TYPE_Q4_1 && src1->type == GGML_TYPE_F32) {
1331        ggml_cpy_q4_1_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1332                               nb11, nb12, nb13, main_stream);
1333    } else if (src0->type == GGML_TYPE_Q8_0 && src1->type == GGML_TYPE_F32) {
1334        ggml_cpy_q8_0_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1335                               nb11, nb12, nb13, main_stream);
1336    } else if (src0->type == GGML_TYPE_Q2_0 && src1->type == GGML_TYPE_F32) {
1337        ggml_cpy_q2_0_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1338                               nb10, nb11, nb12, nb13, main_stream);
1339    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q5_0) {
1340        ggml_cpy_f32_q5_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1341                               nb11, nb12, nb13, main_stream);
1342    } else if (src0->type == GGML_TYPE_Q5_0 && src1->type == GGML_TYPE_F32) {
1343        ggml_cpy_q5_0_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1344                               nb11, nb12, nb13, main_stream);
1345    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q5_1) {
1346        ggml_cpy_f32_q5_1_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1347                               nb11, nb12, nb13, main_stream);
1348    } else if (src0->type == GGML_TYPE_Q5_1 && src1->type == GGML_TYPE_F32) {
1349        ggml_cpy_q5_1_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1350                               nb11, nb12, nb13, main_stream);
1351    } else if (src0->type == GGML_TYPE_MXFP4 && src1->type == GGML_TYPE_F32) {
1352        ggml_cpy_mxfp4_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1353                                nb10, nb11, nb12, nb13, main_stream);
1354    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_IQ4_NL) {
1355        ggml_cpy_f32_iq4_nl_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1356                                 nb10, nb11, nb12, nb13, main_stream);
1357    } else if (src0->type == GGML_TYPE_Q8_0 && src1->type == GGML_TYPE_Q8_0) {
1358        ggml_cpy_q8_0_q8_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1359    } else if (src0->type == GGML_TYPE_Q5_0 && src1->type == GGML_TYPE_Q5_0) {
1360        ggml_cpy_q5_0_q5_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1361    } else if (src0->type == GGML_TYPE_Q5_1 && src1->type == GGML_TYPE_Q5_1) {
1362        ggml_cpy_q5_1_q5_1(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1363    } else if (src0->type == GGML_TYPE_Q4_0 && src1->type == GGML_TYPE_Q4_0) {
1364        ggml_cpy_q4_0_q4_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1365    } else if (src0->type == GGML_TYPE_Q4_1 && src1->type == GGML_TYPE_Q4_1) {
1366        ggml_cpy_q4_1_q4_1(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1367    } else if (src0->type == GGML_TYPE_Q1_0 && src1->type == GGML_TYPE_Q1_0) {
1368        ggml_cpy_q1_0_q1_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1369    } else if (src0->type == GGML_TYPE_Q2_0 && src1->type == GGML_TYPE_Q2_0) {
1370        ggml_cpy_q2_0_q2_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1371    } else if (src0->type == GGML_TYPE_MXFP4 && src1->type == GGML_TYPE_MXFP4) {
1372        ggml_cpy_mxfp4_mxfp4(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1373    } else if (src0->type == GGML_TYPE_NVFP4 && src1->type == GGML_TYPE_NVFP4) {
1374        ggml_cpy_nvfp4_nvfp4(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1375    } else if (src0->type == GGML_TYPE_Q2_K && src1->type == GGML_TYPE_Q2_K) {
1376        ggml_cpy_q2_K_q2_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1377    } else if (src0->type == GGML_TYPE_Q3_K && src1->type == GGML_TYPE_Q3_K) {
1378        ggml_cpy_q3_K_q3_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1379    } else if (src0->type == GGML_TYPE_Q4_K && src1->type == GGML_TYPE_Q4_K) {
1380        ggml_cpy_q4_K_q4_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1381    } else if (src0->type == GGML_TYPE_Q5_K && src1->type == GGML_TYPE_Q5_K) {
1382        ggml_cpy_q5_K_q5_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1383    } else if (src0->type == GGML_TYPE_Q6_K && src1->type == GGML_TYPE_Q6_K) {
1384        ggml_cpy_q6_K_q6_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1385    } else if (src0->type == GGML_TYPE_IQ2_XXS && src1->type == GGML_TYPE_IQ2_XXS) {
1386        ggml_cpy_iq2_xxs_iq2_xxs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1387    } else if (src0->type == GGML_TYPE_IQ2_XS && src1->type == GGML_TYPE_IQ2_XS) {
1388        ggml_cpy_iq2_xs_iq2_xs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1389    } else if (src0->type == GGML_TYPE_IQ2_S && src1->type == GGML_TYPE_IQ2_S) {
1390        ggml_cpy_iq2_s_iq2_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1391    } else if (src0->type == GGML_TYPE_IQ3_XXS && src1->type == GGML_TYPE_IQ3_XXS) {
1392        ggml_cpy_iq3_xxs_iq3_xxs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1393    } else if (src0->type == GGML_TYPE_IQ1_S && src1->type == GGML_TYPE_IQ1_S) {
1394        ggml_cpy_iq1_s_iq1_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1395    } else if (src0->type == GGML_TYPE_IQ1_M && src1->type == GGML_TYPE_IQ1_M) {
1396        ggml_cpy_iq1_m_iq1_m(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1397    } else if (src0->type == GGML_TYPE_IQ4_NL && src1->type == GGML_TYPE_IQ4_NL) {
1398        ggml_cpy_iq4_nl_iq4_nl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1399    } else if (src0->type == GGML_TYPE_IQ3_S && src1->type == GGML_TYPE_IQ3_S) {
1400        ggml_cpy_iq3_s_iq3_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1401    } else if (src0->type == GGML_TYPE_IQ4_XS && src1->type == GGML_TYPE_IQ4_XS) {
1402        ggml_cpy_iq4_xs_iq4_xs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1403#ifdef GGML_SYCL_HAS_BF16
1404    } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_BF16) {
1405        ggml_cpy_f32_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1406                              nb11, nb12, nb13, main_stream);
1407    } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F32) {
1408        ggml_cpy_bf16_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1409                              nb11, nb12, nb13, main_stream);
1410    } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_BF16) {
1411        ggml_cpy_bf16_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1412                               nb11, nb12, nb13, main_stream);
1413    } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_BF16) {
1414        ggml_cpy_f16_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1415                              nb11, nb12, nb13, main_stream);
1416    } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F16) {
1417        ggml_cpy_bf16_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1418                              nb11, nb12, nb13, main_stream);
1419#endif
1420    } else {
1421        GGML_LOG_ERROR("%s: unsupported type combination (%s to %s)\n", __func__, ggml_type_name(src0->type),
1422                       ggml_type_name(src1->type));
1423        GGML_ABORT("fatal error");
1424    }
1425} catch (const sycl::exception & exc) {
1426    std::cerr << exc.what() << "Exception caught at file:" << __FILE__ << ", line:" << __LINE__ << std::endl;
1427    std::exit(1);
1428}
1429
1430void ggml_sycl_dup(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
1431    scope_op_debug_print scope_dbg_print(__func__, dst, /*num_src=*/1);
1432    ggml_sycl_cpy(ctx, dst->src[0], dst);
1433}