char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
f275595dd
char/aliceai-t5-moe
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 ) { 12const float * xi = (const float * )cxi ; 13float * dsti = (float * )cdsti ; 14 15* dsti = * xi ; 16} 17 18static void cpy_1_f32_f16 (const char * cxi ,char * cdsti ) { 19const 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 ) { 26const 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 ) { 33const sycl::half * xi = (const sycl::half * )cxi ; 34float * dsti = (float * )cdsti ; 35 36* dsti = * xi ; 37} 38 39static void cpy_1_i16_i16 (const char * cxi ,char * cdsti ) { 40const int16_t * xi = (const int16_t * )cxi ; 41int16_t * dsti = (int16_t * )cdsti ; 42 43* dsti = * xi ; 44} 45 46static void cpy_1_i32_i32 (const char * cxi ,char * cdsti ) { 47const int32_t * xi = (const int32_t * )cxi ; 48int32_t * dsti = (int32_t * )cdsti ; 49 50* dsti = * xi ; 51} 52 53static void cpy_1_f32_i32 (const char * cxi ,char * cdsti ) { 54const float * xi = (const float * )cxi ; 55int32_t * dsti = (int32_t * )cdsti ; 56 57* dsti = (int32_t )* xi ; 58} 59 60static void cpy_1_i32_f32 (const char * cxi ,char * cdsti ) { 61const int32_t * xi = (const int32_t * )cxi ; 62float * 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 ) { 69const 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 ) { 76const sycl::ext::oneapi::bfloat16 * xi = (const sycl::ext::oneapi::bfloat16 * )cxi ; 77float * dsti = (float * )cdsti ; 78 79* dsti = static_cast < float > (* xi ); 80} 81 82static void cpy_1_bf16_bf16 (const char * cxi ,char * cdsti ) { 83const 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 ) { 90const 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 ) { 97const 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 , 106const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 ,const int ne10 ,const int ne11 , 107const int ne12 ,const int nb10 ,const int nb11 ,const int nb12 ,const int nb13 , 108const sycl::nd_item < 3 > & item_ct1 ) { 109const int i = item_ct1 .get_local_range (2 )* item_ct1 .get_group (2 )+ item_ct1 .get_local_id (2 ); 110 111if (i >=ne ) { 112return ; 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 117const int i03 = i / (ne00 * ne01 * ne02 ); 118const int i02 = (i - i03 * ne00 * ne01 * ne02 ) / (ne00 * ne01 ); 119const int i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 ) /ne00 ; 120const int i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00 ; 121const int x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03 ; 122 123const int i13 = i / (ne10 * ne11 * ne12 ); 124const int i12 = (i - i13 * ne10 * ne11 * ne12 ) / (ne10 * ne11 ); 125const int i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 ) /ne10 ; 126const int i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10 ; 127const int dst_offset = i10 * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13 ; 128 129cpy_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 ) { 136const T * xi = (const T * )cxi ; 137T * dsti = (T * )cdsti ; 138* dsti = * xi ; 139} 140 141 142static void cpy_blck_q8_0_f32 (const char * cxi ,char * cdsti ) { 143float * cdstf = (float * ) (cdsti ); 144 145for (int j = 0 ;j < QK8_0 ;j += 2 ) { 146dfloat2 dq ; 147dequantize_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 ) { 154const block_q2_0 * xi = (const block_q2_0 * )cxi ; 155float * cdstf = (float * )cdsti ; 156 157const float d = xi -> d ; 158 159for (int j = 0 ;j < QK2_0 ;++ j ) { 160const int byte_index = j /4 ; 161const int bit_offset = (j %4 )* 2 ; 162const int q = (xi -> qs [byte_index ] >>bit_offset )& 0x3 ; 163cdstf [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 ) { 170float * cdstf = (float * ) (cdsti ); 171 172for (int j = 0 ;j < qk /2 ;j ++ ) { 173dfloat2 dq ; 174dequant (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 , 183const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 ,const int ne10 ,const int ne11 , 184const int ne12 ,const int nb10 ,const int nb11 ,const int nb12 ,const int nb13 , 185const sycl::nd_item < 3 > & item_ct1 ) { 186const int i = (item_ct1 .get_local_range (2 )* item_ct1 .get_group (2 )+ item_ct1 .get_local_id (2 ))* qk ; 187 188if (i >=ne ) { 189return ; 190 } 191 192const int i03 = i / (ne00 * ne01 * ne02 ); 193const int i02 = (i - i03 * ne00 * ne01 * ne02 ) / (ne00 * ne01 ); 194const int i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 ) /ne00 ; 195const int i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00 ; 196const int x_offset = (i00 /qk )* nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03 ; 197 198 199const int i13 = i / (ne10 * ne11 * ne12 ); 200const int i12 = (i - i13 * ne10 * ne11 * ne12 ) / (ne10 * ne11 ); 201const int i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 ) /ne10 ; 202const int i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10 ; 203const int dst_offset = (i10 /qk )* nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13 ; 204 205cpy_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 , 210const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 ,const int ne10 ,const int ne11 , 211const int ne12 ,const int nb10 ,const int nb11 ,const int nb12 ,const int nb13 , 212const sycl::nd_item < 3 > & item_ct1 ) { 213const int i = (item_ct1 .get_local_range (2 )* item_ct1 .get_group (2 )+ item_ct1 .get_local_id (2 ))* qk ; 214 215if (i >=ne ) { 216return ; 217 } 218 219 220const int i03 = i / (ne00 * ne01 * ne02 ); 221const int i02 = (i - i03 * ne00 * ne01 * ne02 ) / (ne00 * ne01 ); 222const int i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 ) /ne00 ; 223const int i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00 ; 224const int x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03 ; 225 226const int i13 = i / (ne10 * ne11 * ne12 ); 227const int i12 = (i - i13 * ne10 * ne11 * ne12 ) / (ne10 * ne11 ); 228const int i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 ) /ne10 ; 229const int i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10 ; 230const int dst_offset = (i10 /qk )* nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13 ; 231 232cpy_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 , 237const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 ,const int ne10 ,const int ne11 , 238const int ne12 ,const int nb10 ,const int nb11 ,const int nb12 ,const int nb13 , 239const sycl::nd_item < 3 > & item_ct1 ) { 240const int i = (item_ct1 .get_local_range (2 )* item_ct1 .get_group (2 )+ item_ct1 .get_local_id (2 ))* qk ; 241 242if (i >=ne ) { 243return ; 244 } 245 246const int i03 = i / (ne00 * ne01 * ne02 ); 247const int i02 = (i - i03 * ne00 * ne01 * ne02 ) / (ne00 * ne01 ); 248const int i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 ) /ne00 ; 249const int i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00 ; 250const int x_offset = (i00 /qk )* nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03 ; 251 252const int i13 = i / (ne10 * ne11 * ne12 ); 253const int i12 = (i - i13 * ne10 * ne11 * ne12 ) / (ne10 * ne11 ); 254const int i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 ) /ne10 ; 255const int i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10 ; 256const int dst_offset = i10 * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13 ; 257 258cpy_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 , 262const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 263const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 264const int nb12 ,const int nb13 ,queue_ptr stream ) { 265const 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 269stream -> 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 )]]{ 273cpy_f32_f16 < cpy_1_f16_f32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 274nb10 ,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 , 280const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 281const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 282const int nb12 ,const int nb13 ,queue_ptr stream ) { 283const 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 287stream -> 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 )]]{ 291cpy_f32_f16 < cpy_1_f32_f32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 292nb10 ,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 , 298const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 299const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 300const int nb12 ,const int nb13 ,queue_ptr stream ) { 301const 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 305stream -> 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 )]]{ 309cpy_f32_f16 < cpy_1_f32_f16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 310nb10 ,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 , 316const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 317const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 318const int nb12 ,const int nb13 ,queue_ptr stream ) { 319const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 320 { 321stream -> 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 )]]{ 325cpy_f32_f16 < cpy_1_f32_i32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 326nb10 ,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 , 332const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 333const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 334const int nb12 ,const int nb13 ,queue_ptr stream ) { 335const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 336 { 337stream -> 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 )]]{ 341cpy_f32_f16 < cpy_1_i32_f32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 342nb10 ,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 , 348const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 349const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 350const int nb12 ,const int nb13 ,queue_ptr stream ) { 351GGML_ASSERT (ne %QK8_0 == 0 ); 352const int num_blocks = ceil_div (ne /QK8_0 ,SYCL_CPY_BLOCK_SIZE ); 353stream -> 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 )]]{ 356cpy_f32_q < cpy_blck_f32_q8_0 ,QK8_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 357ne10 ,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 , 362const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 363const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 364const int nb12 ,const int nb13 ,queue_ptr stream ) { 365GGML_ASSERT (ne %QK8_0 == 0 ); 366const int num_blocks = ceil_div (ne /QK8_0 ,SYCL_CPY_BLOCK_SIZE ); 367stream -> 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 )]]{ 370cpy_q_f32 < cpy_blck_q8_0_f32 ,QK8_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 371ne10 ,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 , 376const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 377const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 378const int nb12 ,const int nb13 ,queue_ptr stream ) { 379GGML_ASSERT (ne %QK2_0 == 0 ); 380const int num_blocks = ceil_div (ne /QK2_0 ,SYCL_CPY_BLOCK_SIZE ); 381stream -> 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 )]] { 385cpy_q_f32 < cpy_blck_q2_0_f32 ,QK2_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 , 386ne12 ,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 , 391const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 392const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 393const int nb12 ,const int nb13 ,queue_ptr stream ) { 394GGML_ASSERT (ne %QK4_0 == 0 ); 395const int num_blocks = ceil_div (ne /QK4_0 ,SYCL_CPY_BLOCK_SIZE ); 396stream -> 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 )]]{ 399cpy_f32_q < cpy_blck_f32_q4_0 ,QK4_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 400ne10 ,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 , 405const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 406const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 407const int nb12 ,const int nb13 ,queue_ptr stream ) { 408GGML_ASSERT (ne %QK4_0 == 0 ); 409const int num_blocks = ceil_div (ne /QK4_0 ,SYCL_CPY_BLOCK_SIZE ); 410stream -> 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 )]]{ 414cpy_q_f32 < cpy_blck_q_f32 < dequantize_q4_0 ,QK4_0 > ,QK4_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 , 415nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 , 416item_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 , 421const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 422const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 423const int nb12 ,const int nb13 ,queue_ptr stream ) { 424GGML_ASSERT (ne %QK4_1 == 0 ); 425const int num_blocks = ceil_div (ne /QK4_1 ,SYCL_CPY_BLOCK_SIZE ); 426stream -> 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 )]]{ 429cpy_f32_q < cpy_blck_f32_q4_1 ,QK4_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 430ne10 ,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 , 435const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 436const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 437const int nb12 ,const int nb13 ,queue_ptr stream ) { 438GGML_ASSERT (ne %QK4_1 == 0 ); 439const int num_blocks = ceil_div (ne /QK4_1 ,SYCL_CPY_BLOCK_SIZE ); 440stream -> 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 )]]{ 444cpy_q_f32 < cpy_blck_q_f32 < dequantize_q4_1 ,QK4_1 > ,QK4_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 , 445nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 , 446item_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 , 451const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 452const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 453const int nb12 ,const int nb13 ,queue_ptr stream ) { 454GGML_ASSERT (ne %QK5_0 == 0 ); 455const int num_blocks = ceil_div (ne /QK5_0 ,SYCL_CPY_BLOCK_SIZE ); 456stream -> 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 )]] { 459cpy_f32_q < cpy_blck_f32_q5_0 ,QK5_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 460ne10 ,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 , 465const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 466const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 467const int nb12 ,const int nb13 ,queue_ptr stream ) { 468GGML_ASSERT (ne %QK5_0 == 0 ); 469const int num_blocks = ceil_div (ne /QK5_0 ,SYCL_CPY_BLOCK_SIZE ); 470stream -> 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 )]]{ 474cpy_q_f32 < cpy_blck_q_f32 < dequantize_q5_0 ,QK5_0 > ,QK5_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 , 475nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 , 476item_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 , 481const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 482const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 483const int nb12 ,const int nb13 ,queue_ptr stream ) { 484GGML_ASSERT (ne %QK5_1 == 0 ); 485const int num_blocks = ceil_div (ne /QK5_1 ,SYCL_CPY_BLOCK_SIZE ); 486stream -> 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 )]]{ 489cpy_f32_q < cpy_blck_f32_q5_1 ,QK5_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 , 490ne10 ,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 , 495const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 496const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 497const int nb12 ,const int nb13 ,queue_ptr stream ) { 498GGML_ASSERT (ne %QK5_1 == 0 ); 499const int num_blocks = ceil_div (ne /QK5_1 ,SYCL_CPY_BLOCK_SIZE ); 500stream -> 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 )]]{ 504cpy_q_f32 < cpy_blck_q_f32 < dequantize_q5_1 ,QK5_1 > ,QK5_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 , 505nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 , 506item_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 , 511const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 512const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 513const int nb12 ,const int nb13 ,queue_ptr stream ) { 514GGML_ASSERT (ne %QK_MXFP4 == 0 ); 515const int num_blocks = ceil_div (ne /QK_MXFP4 ,SYCL_CPY_BLOCK_SIZE ); 516stream -> 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 )]] { 520cpy_q_f32 < cpy_blck_q_f32 < dequantize_mxfp4 ,QK_MXFP4 > ,QK_MXFP4 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 , 521nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 522nb10 ,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 , 527const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 528const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 529const int nb12 ,const int nb13 ,queue_ptr stream ) { 530GGML_ASSERT (ne %QK4_NL == 0 ); 531const int num_blocks = ceil_div (ne /QK4_NL ,SYCL_CPY_BLOCK_SIZE ); 532stream -> 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 )]] { 536cpy_f32_q < cpy_blck_f32_iq4_nl ,QK4_NL > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 , 537ne12 ,nb10 ,nb11 ,nb12 ,nb13 ,item_ct1 ); 538 }); 539} 540 541static void cpy_blck_f16_q4_0 (const char * cxi ,char * cdsti ) { 542const sycl::half * xi = (const sycl::half * )cxi ; 543float xf [QK4_0 ]; 544 545for (int j = 0 ;j < QK4_0 ;++ j ) { 546xf [j ]= (float )xi [j ]; 547 } 548 549cpy_blck_f32_q4_0 ((const char * )xf ,cdsti ); 550} 551 552static void cpy_blck_f16_q4_1 (const char * cxi ,char * cdsti ) { 553const sycl::half * xi = (const sycl::half * )cxi ; 554float xf [QK4_1 ]; 555 556for (int j = 0 ;j < QK4_1 ;++ j ) { 557xf [j ]= (float )xi [j ]; 558 } 559 560cpy_blck_f32_q4_1 ((const char * )xf ,cdsti ); 561} 562 563static void cpy_blck_f16_q5_0 (const char * cxi ,char * cdsti ) { 564const sycl::half * xi = (const sycl::half * )cxi ; 565float xf [QK5_0 ]; 566 567for (int j = 0 ;j < QK5_0 ;++ j ) { 568xf [j ]= (float )xi [j ]; 569 } 570 571cpy_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 , 575const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 576const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 577const int nb12 ,const int nb13 ,queue_ptr stream ) { 578GGML_ASSERT (ne %QK4_0 == 0 ); 579const int num_blocks = ceil_div (ne /QK4_0 ,SYCL_CPY_BLOCK_SIZE ); 580stream -> 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 )]]{ 583cpy_f32_q < cpy_blck_f16_q4_0 ,QK4_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 , 584nb00 ,nb01 ,nb02 ,nb03 , 585ne10 ,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 , 590const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 591const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 592const int nb12 ,const int nb13 ,queue_ptr stream ) { 593GGML_ASSERT (ne %QK4_1 == 0 ); 594const int num_blocks = ceil_div (ne /QK4_1 ,SYCL_CPY_BLOCK_SIZE ); 595stream -> 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 )]]{ 598cpy_f32_q < cpy_blck_f16_q4_1 ,QK4_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 , 599nb00 ,nb01 ,nb02 ,nb03 , 600ne10 ,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 , 605const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 606const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 607const int nb12 ,const int nb13 ,queue_ptr stream ) { 608GGML_ASSERT (ne %QK5_0 == 0 ); 609const int num_blocks = ceil_div (ne /QK5_0 ,SYCL_CPY_BLOCK_SIZE ); 610stream -> 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 )]]{ 613cpy_f32_q < cpy_blck_f16_q5_0 ,QK5_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 , 614nb00 ,nb01 ,nb02 ,nb03 , 615ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 ,item_ct1 ); 616 }); 617} 618 619static bool ggml_sycl_is_quantized_type (enum ggml_type type ) { 620switch (type ) { 621case GGML_TYPE_Q1_0 : 622case GGML_TYPE_Q2_0 : 623case GGML_TYPE_Q4_0 : 624case GGML_TYPE_Q4_1 : 625case GGML_TYPE_Q5_0 : 626case GGML_TYPE_Q5_1 : 627case GGML_TYPE_Q8_0 : 628case GGML_TYPE_MXFP4 : 629case GGML_TYPE_NVFP4 : 630case GGML_TYPE_Q2_K : 631case GGML_TYPE_Q3_K : 632case GGML_TYPE_Q4_K : 633case GGML_TYPE_Q5_K : 634case GGML_TYPE_Q6_K : 635case GGML_TYPE_IQ2_XXS : 636case GGML_TYPE_IQ2_XS : 637case GGML_TYPE_IQ2_S : 638case GGML_TYPE_IQ3_XXS : 639case GGML_TYPE_IQ3_S : 640case GGML_TYPE_IQ1_S : 641case GGML_TYPE_IQ1_M : 642case GGML_TYPE_IQ4_NL : 643case GGML_TYPE_IQ4_XS : 644return true; 645default : 646return false; 647 } 648} 649 650static bool ggml_sycl_can_quantize_rows_sycl (enum ggml_type type ) { 651switch (type ) { 652case GGML_TYPE_Q1_0 : 653case GGML_TYPE_Q2_0 : 654case GGML_TYPE_Q4_0 : 655case GGML_TYPE_Q4_1 : 656case GGML_TYPE_Q5_0 : 657case GGML_TYPE_Q5_1 : 658case GGML_TYPE_Q8_0 : 659case GGML_TYPE_MXFP4 : 660case GGML_TYPE_NVFP4 : 661case GGML_TYPE_Q2_K : 662case GGML_TYPE_Q3_K : 663case GGML_TYPE_Q4_K : 664case GGML_TYPE_Q5_K : 665case GGML_TYPE_Q6_K : 666case GGML_TYPE_IQ4_NL : 667case GGML_TYPE_IQ4_XS : 668return true; 669default : 670return false; 671 } 672} 673 674template < typename SrcScalar > 675static inline float ggml_sycl_src_to_f32 (const SrcScalar & x ) { 676return (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 ) { 682return static_cast < float > (x ); 683} 684 685template <> 686inline float ggml_sycl_src_to_f32 < ggml_bf16_t > (const ggml_bf16_t & x ) { 687union { 688uint32_t u32 ; 689float f32 ; 690 }value ; 691 692value .u32 = (uint32_t )x .bits <<16 ; 693return 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 , 699const int64_t ne00 ,const int64_t ne01 ,const int64_t ne02 , 700const size_t nb00 ,const size_t nb01 ,const size_t nb02 ,const size_t nb03 , 701const int64_t ne10 ,const int64_t ne11 ,const int64_t ne12 , 702const size_t nb10 ,const size_t nb11 ,const size_t nb12 ,const size_t nb13 , 703queue_ptr stream ) { 704GGML_ASSERT (ne %qk == 0 ); 705GGML_ASSERT (ne00 %qk == 0 ); 706 707const int64_t total_blocks = ne /qk ; 708constexpr int block_size = 256 ; 709const int64_t grid_size = ceil_div (total_blocks , (int64_t )block_size ); 710 711stream -> 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 )]] { 713const int64_t block_idx = item_ct1 .get_global_linear_id (); 714if (block_idx >=total_blocks ) { 715return ; 716 } 717 718const int64_t i = block_idx * qk ; 719 720const int64_t i03 = i / (ne00 * ne01 * ne02 ); 721const int64_t i02 = (i - i03 * ne00 * ne01 * ne02 ) / (ne00 * ne01 ); 722const int64_t i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 ) /ne00 ; 723const int64_t i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00 ; 724const size_t x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03 ; 725 726const int64_t i13 = i / (ne10 * ne11 * ne12 ); 727const int64_t i12 = (i - i13 * ne10 * ne11 * ne12 ) / (ne10 * ne11 ); 728const int64_t i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 ) /ne10 ; 729const int64_t i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10 ; 730const size_t dst_offset = (i10 /qk )* nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13 ; 731 732float xf [qk ]; 733if (nb00 == sizeof (SrcScalar )) { 734const SrcScalar * src_row = (const SrcScalar * ) (cx + x_offset ); 735for (int j = 0 ;j < qk ;++ j ) { 736xf [j ]= ggml_sycl_src_to_f32 (src_row [j ]); 737 } 738 }else { 739for (int j = 0 ;j < qk ;++ j ) { 740const SrcScalar * src_val = (const SrcScalar * ) (cx + x_offset + j * nb00 ); 741xf [j ]= ggml_sycl_src_to_f32 (* src_val ); 742 } 743 } 744 745quantize_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 , 751const int64_t ne ,const int64_t ne00 ,const int64_t ne01 ,const int64_t ne02 , 752const size_t nb00 ,const size_t nb01 ,const size_t nb02 ,const size_t nb03 , 753const int64_t ne10 ,const int64_t ne11 ,const int64_t ne12 ,const size_t nb10 , 754const size_t nb11 ,const size_t nb12 ,const size_t nb13 ,queue_ptr stream ) { 755GGML_UNUSED (src0 ); 756GGML_UNUSED (src1 ); 757 758switch (src1 -> type ) { 759case GGML_TYPE_Q8_0 : 760ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q8_0 ,QK8_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 761nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 762nb12 ,nb13 ,stream ); 763break ; 764case GGML_TYPE_Q1_0 : 765ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q1_0 ,QK1_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 766nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 767nb12 ,nb13 ,stream ); 768break ; 769case GGML_TYPE_Q2_0 : 770ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q2_0 ,QK2_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 771nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 772nb12 ,nb13 ,stream ); 773break ; 774case GGML_TYPE_Q5_1 : 775ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q5_1 ,QK5_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 776nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 777nb12 ,nb13 ,stream ); 778break ; 779case GGML_TYPE_Q5_0 : 780ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q5_0 ,QK5_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 781nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 782nb12 ,nb13 ,stream ); 783break ; 784case GGML_TYPE_Q4_1 : 785ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q4_1 ,QK4_1 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 786nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 787nb12 ,nb13 ,stream ); 788break ; 789case GGML_TYPE_Q4_0 : 790ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_q4_0 ,QK4_0 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 791nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 , 792nb12 ,nb13 ,stream ); 793break ; 794case GGML_TYPE_IQ4_NL : 795ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_iq4_nl ,QK4_NL > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 , 796nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 797nb10 ,nb11 ,nb12 ,nb13 ,stream ); 798break ; 799case GGML_TYPE_MXFP4 : 800ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_mxfp4 ,QK_MXFP4 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 , 801nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 802nb10 ,nb11 ,nb12 ,nb13 ,stream ); 803break ; 804case GGML_TYPE_NVFP4 : 805ggml_sycl_quantize_rows_q < SrcScalar ,cpy_blck_f32_nvfp4 ,QK_NVFP4 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 , 806nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 807nb10 ,nb11 ,nb12 ,nb13 ,stream ); 808break ; 809default : 810GGML_ABORT ("unsupported quantized target type in sycl quantizer src1->type=%s\n" , 811ggml_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 , 816const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 817const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 818const int nb12 ,const int nb13 ,queue_ptr stream ) { 819const 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 823stream -> 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 )]]{ 827cpy_f32_f16 < cpy_1_f16_f16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 828nb10 ,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 , 834const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 835const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 836const int nb12 ,const int nb13 ,queue_ptr stream ) { 837const 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 842stream -> 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 )]]{ 846cpy_f32_f16 < cpy_1_i16_i16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 847nb10 ,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 , 853const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 854const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 855const int nb12 ,const int nb13 ,queue_ptr stream ) { 856const 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 861stream -> 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 )]]{ 865cpy_f32_f16 < cpy_1_i32_i32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 866nb10 ,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 , 872const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 873const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 874const int nb12 ,const int nb13 ,queue_ptr stream ) { 875GGML_ASSERT (ne %QK8_0 == 0 ); 876const int num_blocks = ceil_div (ne /QK8_0 ,SYCL_CPY_BLOCK_SIZE ); 877stream -> 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 )]]{ 881cpy_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 , 887const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 888const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 889const int nb12 ,const int nb13 ,queue_ptr stream ) { 890GGML_ASSERT (ne %QK5_0 == 0 ); 891const int num_blocks = ceil_div (ne /QK5_0 ,SYCL_CPY_BLOCK_SIZE ); 892stream -> 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 )]]{ 896cpy_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 , 902const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 903const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 904const int nb12 ,const int nb13 ,queue_ptr stream ) { 905GGML_ASSERT (ne %QK5_1 == 0 ); 906const int num_blocks = ceil_div (ne /QK5_1 ,SYCL_CPY_BLOCK_SIZE ); 907 908stream -> 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 )]]{ 912cpy_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 , 918const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 919const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 920const int nb12 ,const int nb13 ,queue_ptr stream ) { 921GGML_ASSERT (ne %QK4_0 == 0 ); 922const int num_blocks = ceil_div (ne /QK4_0 ,SYCL_CPY_BLOCK_SIZE ); 923stream -> 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 )]]{ 926cpy_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 , 932const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 933const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 934const int nb12 ,const int nb13 ,queue_ptr stream ) { 935 936GGML_ASSERT (ne %QK4_1 == 0 ); 937const int num_blocks = ceil_div (ne /QK4_1 ,SYCL_CPY_BLOCK_SIZE ); 938stream -> 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 )]]{ 941cpy_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 , 946const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 947const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 948const int nb12 ,const int nb13 ,queue_ptr stream ) { 949GGML_ASSERT (ne %QK1_0 == 0 ); 950const int num_blocks = ceil_div (ne /QK1_0 ,SYCL_CPY_BLOCK_SIZE ); 951stream -> 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 )]] { 954cpy_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 , 959const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 960const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 961const int nb12 ,const int nb13 ,queue_ptr stream ) { 962GGML_ASSERT (ne %QK2_0 == 0 ); 963const int num_blocks = ceil_div (ne /QK2_0 ,SYCL_CPY_BLOCK_SIZE ); 964stream -> 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 )]]{ 967cpy_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 , 972const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 973const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 974const int nb12 ,const int nb13 ,queue_ptr stream ) { 975GGML_ASSERT (ne %QK_MXFP4 == 0 ); 976const int num_blocks = ceil_div (ne /QK_MXFP4 ,SYCL_CPY_BLOCK_SIZE ); 977stream -> 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 )]] { 980cpy_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 , 985const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 986const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 987const int nb12 ,const int nb13 ,queue_ptr stream ) { 988GGML_ASSERT (ne %QK_NVFP4 == 0 ); 989const int num_blocks = ceil_div (ne /QK_NVFP4 ,SYCL_CPY_BLOCK_SIZE ); 990stream -> 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 )]]{ 993cpy_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 , 998const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 999const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1000const int nb12 ,const int nb13 ,queue_ptr stream ) { 1001GGML_ASSERT (ne %QK_K == 0 ); 1002const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1003stream -> 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 )]]{ 1006cpy_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 , 1011const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1012const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1013const int nb12 ,const int nb13 ,queue_ptr stream ) { 1014GGML_ASSERT (ne %QK_K == 0 ); 1015const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1016stream -> 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 )]]{ 1019cpy_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 , 1024const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1025const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1026const int nb12 ,const int nb13 ,queue_ptr stream ) { 1027GGML_ASSERT (ne %QK_K == 0 ); 1028const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1029stream -> 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 )]]{ 1032cpy_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 , 1037const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1038const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1039const int nb12 ,const int nb13 ,queue_ptr stream ) { 1040GGML_ASSERT (ne %QK_K == 0 ); 1041const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1042stream -> 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 )]]{ 1045cpy_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 , 1050const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1051const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1052const int nb12 ,const int nb13 ,queue_ptr stream ) { 1053GGML_ASSERT (ne %QK_K == 0 ); 1054const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1055stream -> 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 )]]{ 1058cpy_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 , 1063const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1064const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1065const int nb12 ,const int nb13 ,queue_ptr stream ) { 1066GGML_ASSERT (ne %QK_K == 0 ); 1067const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1068stream -> 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 )]]{ 1071cpy_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 , 1076const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1077const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1078const int nb12 ,const int nb13 ,queue_ptr stream ) { 1079GGML_ASSERT (ne %QK_K == 0 ); 1080const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1081stream -> 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 )]]{ 1084cpy_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 , 1089const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1090const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1091const int nb12 ,const int nb13 ,queue_ptr stream ) { 1092GGML_ASSERT (ne %QK_K == 0 ); 1093const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1094stream -> 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 )]]{ 1097cpy_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 , 1102const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1103const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1104const int nb12 ,const int nb13 ,queue_ptr stream ) { 1105GGML_ASSERT (ne %QK_K == 0 ); 1106const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1107stream -> 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 )]]{ 1110cpy_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 , 1115const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1116const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1117const int nb12 ,const int nb13 ,queue_ptr stream ) { 1118GGML_ASSERT (ne %QK_K == 0 ); 1119const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1120stream -> 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 )]]{ 1123cpy_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 , 1128const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1129const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1130const int nb12 ,const int nb13 ,queue_ptr stream ) { 1131GGML_ASSERT (ne %QK_K == 0 ); 1132const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1133stream -> 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 )]]{ 1136cpy_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 , 1141const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1142const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1143const int nb12 ,const int nb13 ,queue_ptr stream ) { 1144GGML_ASSERT (ne %QK4_NL == 0 ); 1145const int num_blocks = ceil_div (ne /QK4_NL ,SYCL_CPY_BLOCK_SIZE ); 1146stream -> 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 )]]{ 1149cpy_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 , 1154const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1155const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1156const int nb12 ,const int nb13 ,queue_ptr stream ) { 1157GGML_ASSERT (ne %QK_K == 0 ); 1158const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1159stream -> 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 )]]{ 1162cpy_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 , 1167const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1168const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1169const int nb12 ,const int nb13 ,queue_ptr stream ) { 1170GGML_ASSERT (ne %QK_K == 0 ); 1171const int num_blocks = ceil_div (ne /QK_K ,SYCL_CPY_BLOCK_SIZE ); 1172stream -> 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 )]]{ 1175cpy_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 , 1181const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1182const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1183const int nb12 ,const int nb13 ,queue_ptr stream ) { 1184const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 1185stream -> 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 )]]{ 1189cpy_f32_f16 < cpy_1_f32_bf16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 1190nb10 ,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 , 1195const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1196const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1197const int nb12 ,const int nb13 ,queue_ptr stream ) { 1198const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 1199stream -> 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 )]]{ 1203cpy_f32_f16 < cpy_1_bf16_f32 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 1204nb10 ,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 , 1209const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1210const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1211const int nb12 ,const int nb13 ,queue_ptr stream ) { 1212const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 1213stream -> 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 )]]{ 1217cpy_f32_f16 < cpy_1_bf16_bf16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 1218nb10 ,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 , 1223const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1224const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1225const int nb12 ,const int nb13 ,queue_ptr stream ) { 1226const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 1227stream -> 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 )]]{ 1231cpy_f32_f16 < cpy_1_f16_bf16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 1232nb10 ,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 , 1237const int ne02 ,const int nb00 ,const int nb01 ,const int nb02 ,const int nb03 , 1238const int ne10 ,const int ne11 ,const int ne12 ,const int nb10 ,const int nb11 , 1239const int nb12 ,const int nb13 ,queue_ptr stream ) { 1240const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1 ) /SYCL_CPY_BLOCK_SIZE ; 1241stream -> 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 )]]{ 1245cpy_f32_f16 < cpy_1_bf16_f16 > (cx ,cdst ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 , 1246nb10 ,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 1253GGML_SYCL_DEBUG ("ggml_sycl_cpy: src0->type=%s, src1->type=%s\n" , 1254ggml_type_name (src0 -> type ),ggml_type_name (src1 -> type )); 1255scope_op_debug_print scope_dbg_print (__func__ ,src1 ,/*num_src=*/ 0 ,debug_get_tensor_str ("\tsrc0" ,src0 )); 1256const int64_t ne = ggml_nelements (src0 ); 1257GGML_ASSERT (ne == ggml_nelements (src1 )); 1258 1259GGML_TENSOR_BINARY_OP_LOCALS01 ; 1260 1261SYCL_CHECK (ggml_sycl_set_device (ctx .device )); 1262queue_ptr main_stream = ctx .stream (); 1263 1264char * src0_ddc = (char * )src0 -> data ; 1265char * src1_ddc = (char * )src1 -> data ; 1266if ((src0 -> type == src1 -> type )&& (ggml_is_contiguous (src0 )&& ggml_is_contiguous (src1 ))) { 1267GGML_SYCL_DEBUG ("%s: memcpy path\n" ,__func__ ); 1268main_stream -> memcpy (src1_ddc ,src0_ddc ,ggml_nbytes (src0 )); 1269 }else if (src0 -> type == GGML_TYPE_F32 && ggml_sycl_is_quantized_type (src1 -> type )) { 1270GGML_ASSERT (ggml_sycl_can_quantize_rows_sycl (src1 -> type )); 1271ggml_sycl_quantize_rows_sycl < float > (src0_ddc ,src1_ddc ,src0 ,src1 ,ne ,ne00 ,ne01 ,ne02 ,nb00 ,nb01 , 1272nb02 ,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 )) { 1274GGML_ASSERT (ggml_sycl_can_quantize_rows_sycl (src1 -> type )); 1275ggml_sycl_quantize_rows_sycl < sycl::half > (src0_ddc ,src1_ddc ,src0 ,src1 ,ne ,ne00 ,ne01 ,ne02 ,nb00 , 1276nb01 ,nb02 ,nb03 ,ne10 ,ne11 ,ne12 ,nb10 ,nb11 ,nb12 ,nb13 , 1277main_stream ); 1278#ifdef GGML_SYCL_HAS_BF16 1279} else if ( src0 -> type == GGML_TYPE_BF16 && ggml_sycl_is_quantized_type ( src1 -> type )) { 1280GGML_ASSERT ( ggml_sycl_can_quantize_rows_sycl ( src1 -> type )); 1281ggml_sycl_quantize_rows_sycl < ggml_bf16_t > ( src0_ddc , src1_ddc , src0 , src1 , ne , ne00 , ne01 , ne02 , 1282nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , nb11 , 1283nb12 , nb13 , main_stream ); 1284#endif 1285} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_F32 ) { 1286ggml_cpy_f32_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1287nb11 , nb12 , nb13 , main_stream ); 1288} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_F16 ) { 1289ggml_cpy_f32_f16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1290nb11 , nb12 , nb13 , main_stream ); 1291} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_I32 ) { 1292ggml_cpy_f32_i32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1293nb11 , nb12 , nb13 , main_stream ); 1294} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_Q8_0 ) { 1295ggml_cpy_f32_q8_0_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1296nb11 , nb12 , nb13 , main_stream ); 1297} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_Q4_0 ) { 1298ggml_cpy_f32_q4_0_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1299nb11 , nb12 , nb13 , main_stream ); 1300} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_Q4_1 ) { 1301ggml_cpy_f32_q4_1_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1302nb11 , nb12 , nb13 , main_stream ); 1303} else if ( src0 -> type == GGML_TYPE_F16 && src1 -> type == GGML_TYPE_F32 ) { 1304ggml_cpy_f16_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1305nb11 , nb12 , nb13 , main_stream ); 1306} else if ( src0 -> type == GGML_TYPE_F16 && src1 -> type == GGML_TYPE_F16 ) { 1307ggml_cpy_f16_f16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1308nb11 , nb12 , nb13 , main_stream ); 1309} else if ( src0 -> type == GGML_TYPE_F16 && src1 -> type == GGML_TYPE_Q4_0 ) { 1310ggml_cpy_f16_q4_0_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , 1311nb00 , 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 ) { 1313ggml_cpy_f16_q4_1_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , 1314nb00 , 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 ) { 1316ggml_cpy_f16_q5_0_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , 1317nb00 , 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 ) { 1319ggml_cpy_i16_i16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1320nb11 , nb12 , nb13 , main_stream ); 1321} else if ( src0 -> type == GGML_TYPE_I32 && src1 -> type == GGML_TYPE_I32 ) { 1322ggml_cpy_i32_i32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1323nb11 , nb12 , nb13 , main_stream ); 1324} else if ( src0 -> type == GGML_TYPE_I32 && src1 -> type == GGML_TYPE_F32 ) { 1325ggml_cpy_i32_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1326nb11 , nb12 , nb13 , main_stream ); 1327} else if ( src0 -> type == GGML_TYPE_Q4_0 && src1 -> type == GGML_TYPE_F32 ) { 1328ggml_cpy_q4_0_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1329nb11 , nb12 , nb13 , main_stream ); 1330} else if ( src0 -> type == GGML_TYPE_Q4_1 && src1 -> type == GGML_TYPE_F32 ) { 1331ggml_cpy_q4_1_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1332nb11 , nb12 , nb13 , main_stream ); 1333} else if ( src0 -> type == GGML_TYPE_Q8_0 && src1 -> type == GGML_TYPE_F32 ) { 1334ggml_cpy_q8_0_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1335nb11 , nb12 , nb13 , main_stream ); 1336} else if ( src0 -> type == GGML_TYPE_Q2_0 && src1 -> type == GGML_TYPE_F32 ) { 1337ggml_cpy_q2_0_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , 1338nb10 , nb11 , nb12 , nb13 , main_stream ); 1339} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_Q5_0 ) { 1340ggml_cpy_f32_q5_0_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1341nb11 , nb12 , nb13 , main_stream ); 1342} else if ( src0 -> type == GGML_TYPE_Q5_0 && src1 -> type == GGML_TYPE_F32 ) { 1343ggml_cpy_q5_0_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1344nb11 , nb12 , nb13 , main_stream ); 1345} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_Q5_1 ) { 1346ggml_cpy_f32_q5_1_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1347nb11 , nb12 , nb13 , main_stream ); 1348} else if ( src0 -> type == GGML_TYPE_Q5_1 && src1 -> type == GGML_TYPE_F32 ) { 1349ggml_cpy_q5_1_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1350nb11 , nb12 , nb13 , main_stream ); 1351} else if ( src0 -> type == GGML_TYPE_MXFP4 && src1 -> type == GGML_TYPE_F32 ) { 1352ggml_cpy_mxfp4_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , 1353nb10 , nb11 , nb12 , nb13 , main_stream ); 1354} else if ( src0 -> type == GGML_TYPE_F32 && src1 -> type == GGML_TYPE_IQ4_NL ) { 1355ggml_cpy_f32_iq4_nl_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , 1356nb10 , nb11 , nb12 , nb13 , main_stream ); 1357} else if ( src0 -> type == GGML_TYPE_Q8_0 && src1 -> type == GGML_TYPE_Q8_0 ) { 1358ggml_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 ) { 1360ggml_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 ) { 1362ggml_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 ) { 1364ggml_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 ) { 1366ggml_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 ) { 1368ggml_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 ) { 1370ggml_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 ) { 1372ggml_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 ) { 1374ggml_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 ) { 1376ggml_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 ) { 1378ggml_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 ) { 1380ggml_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 ) { 1382ggml_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 ) { 1384ggml_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 ) { 1386ggml_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 ) { 1388ggml_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 ) { 1390ggml_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 ) { 1392ggml_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 ) { 1394ggml_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 ) { 1396ggml_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 ) { 1398ggml_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 ) { 1400ggml_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 ) { 1402ggml_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 ) { 1405ggml_cpy_f32_bf16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1406nb11 , nb12 , nb13 , main_stream ); 1407} else if ( src0 -> type == GGML_TYPE_BF16 && src1 -> type == GGML_TYPE_F32 ) { 1408ggml_cpy_bf16_f32_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1409nb11 , nb12 , nb13 , main_stream ); 1410} else if ( src0 -> type == GGML_TYPE_BF16 && src1 -> type == GGML_TYPE_BF16 ) { 1411ggml_cpy_bf16_bf16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1412nb11 , nb12 , nb13 , main_stream ); 1413} else if ( src0 -> type == GGML_TYPE_F16 && src1 -> type == GGML_TYPE_BF16 ) { 1414ggml_cpy_f16_bf16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1415nb11 , nb12 , nb13 , main_stream ); 1416} else if ( src0 -> type == GGML_TYPE_BF16 && src1 -> type == GGML_TYPE_F16 ) { 1417ggml_cpy_bf16_f16_sycl ( src0_ddc , src1_ddc , ne , ne00 , ne01 , ne02 , nb00 , nb01 , nb02 , nb03 , ne10 , ne11 , ne12 , nb10 , 1418nb11 , nb12 , nb13 , main_stream ); 1419#endif 1420} else { 1421GGML_LOG_ERROR ( "%s: unsupported type combination (%s to %s)\n" , __func__ , ggml_type_name ( src0 -> type ), 1422ggml_type_name ( src1 -> type )); 1423GGML_ABORT ( "fatal error" ); 1424} 1425} catch (const sycl:: exception & exc ) { 1426std:: cerr << exc . what () << "Exception caught at file:" << __FILE__ << ", line:" << __LINE__ << std:: endl ; 1427std:: exit ( 1 ); 1428} 1429 1430void ggml_sycl_dup ( ggml_backend_sycl_context & ctx , ggml_tensor * dst ) { 1431scope_op_debug_print scope_dbg_print ( __func__ , dst , /*num_src=*/ 1 ); 1432ggml_sycl_cpy ( ctx , dst -> src [ 0 ], dst ); 1433}