1namespace dnnl {
2namespace impl {
3namespace gpu {
4namespace ocl {
5const char *custom_reorder_kernel = R"==(/******************************************************************************* )==""\n"
6R"==(* Copyright 2019-2022 Intel Corporation )==""\n"
7R"==(* )==""\n"
8R"==(* Licensed under the Apache License, Version 2.0 (the "License"); )==""\n"
9R"==(* you may not use this file except in compliance with the License. )==""\n"
10R"==(* You may obtain a copy of the License at )==""\n"
11R"==(* )==""\n"
12R"==(* http: )==""\n"
13R"==(* )==""\n"
14R"==(* Unless required by applicable law or agreed to in writing, software )==""\n"
15R"==(* distributed under the License is distributed on an "AS IS" BASIS, )==""\n"
16R"==(* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. )==""\n"
17R"==(* See the License for the specific language governing permissions and )==""\n"
18R"==(* limitations under the License. )==""\n"
19R"==(*******************************************************************************/ )==""\n"
20R"==(#include "gpu/ocl/reorder_common.h" )==""\n"
21R"==(KERNEL_ATTR )==""\n"
22R"==(__kernel void custom_reorder(__global SRC_DATA_T *restrict src, )==""\n"
23R"==(__global DST_DATA_T *restrict dst, __global float *restrict src_scales, )==""\n"
24R"==(__global int *restrict src_zps, __global float *restrict dst_scales, )==""\n"
25R"==(__global int *restrict dst_zps, float sum_scale, int sum_zp) { )==""\n"
26R"==(const int src_zp = GET_SRC_ZP(src_zps); )==""\n"
27R"==(const int dst_zp = GET_DST_ZP(dst_zps); )==""\n"
28R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES == 1 )==""\n"
29R"==(float src_scale = src_scales[0]; )==""\n"
30R"==(#else )==""\n"
31R"==(float src_scale = 1.0f; )==""\n"
32R"==(#endif )==""\n"
33R"==(#if WITH_DST_SCALE && DST_NUM_SCALES == 1 )==""\n"
34R"==(float dst_scale = dst_scales[0]; )==""\n"
35R"==(#else )==""\n"
36R"==(float dst_scale = 1.0f; )==""\n"
37R"==(#endif )==""\n"
38R"==(src += SRC_OFFSET0; )==""\n"
39R"==(dst += DST_OFFSET0; )==""\n"
40R"==(#if UNALIGNED )==""\n"
41R"==(const int d0 = GWS_GET_D0(); )==""\n"
42R"==(const int d1_blk_start = GWS_GET_D1(); )==""\n"
43R"==(const int d2_blk_start = GWS_GET_D2(); )==""\n"
44R"==(const int d3_blk_start = GWS_GET_D3(); )==""\n"
45R"==(const int d4_blk_start = GWS_GET_D4(); )==""\n"
46R"==(const int d5_blk_start = GWS_GET_D5(); )==""\n"
47R"==(const int d1_blk_end = d1_blk_start + GWS_GET_D1_BLOCK(); )==""\n"
48R"==(const int d2_blk_end = d2_blk_start + GWS_GET_D2_BLOCK(); )==""\n"
49R"==(const int d3_blk_end = d3_blk_start + GWS_GET_D3_BLOCK(); )==""\n"
50R"==(const int d4_blk_end = d4_blk_start + GWS_GET_D4_BLOCK(); )==""\n"
51R"==(const int d5_blk_end = d5_blk_start + GWS_GET_D5_BLOCK(); )==""\n"
52R"==(for_(int d1 = d1_blk_start; d1 < d1_blk_end; ++d1) )==""\n"
53R"==(for_(int d2 = d2_blk_start; d2 < d2_blk_end; ++d2) )==""\n"
54R"==(for_(int d3 = d3_blk_start; d3 < d3_blk_end; ++d3) )==""\n"
55R"==(for_(int d4 = d4_blk_start; d4 < d4_blk_end; ++d4) )==""\n"
56R"==(for (int d5 = d5_blk_start; d5 < d5_blk_end; ++d5) { )==""\n"
57R"==(const int src_off = SRC_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
58R"==(const int dst_off = DST_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
59R"==(#if PAD_FILL_ZERO == 1 )==""\n"
60R"==(int pad_d0 = d0 >= SRC_D0; )==""\n"
61R"==(int pad_d1 = NDIMS > 1 && d1 >= SRC_D1; )==""\n"
62R"==(int pad_d2 = NDIMS > 2 && d2 >= SRC_D2; )==""\n"
63R"==(int pad_d3 = NDIMS > 3 && d3 >= SRC_D3; )==""\n"
64R"==(int pad_d4 = NDIMS > 4 && d4 >= SRC_D4; )==""\n"
65R"==(int pad_d5 = NDIMS > 5 && d5 >= SRC_D5; )==""\n"
66R"==(if (pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5) { )==""\n"
67R"==(dst[dst_off] = 0; )==""\n"
68R"==(continue; )==""\n"
69R"==(} )==""\n"
70R"==(#endif )==""\n"
71R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES > 1 )==""\n"
72R"==(src_scale = src_scales[SCALE_OFF(SRC, d0, d1, d2, d3, d4, d5)]; )==""\n"
73R"==(#endif )==""\n"
74R"==(#if WITH_DST_SCALE && DST_NUM_SCALES > 1 )==""\n"
75R"==(dst_scale = dst_scales[SCALE_OFF(DST, d0, d1, d2, d3, d4, d5)]; )==""\n"
76R"==(#endif )==""\n"
77R"==(REORDER(dst[dst_off], src[src_off], src_scale, dst_scale, sum_scale, )==""\n"
78R"==(src_zp, dst_zp, sum_zp); )==""\n"
79R"==(} )==""\n"
80R"==(#elif ALT_OFFSETS )==""\n"
81R"==(const int d0 = get_global_id(0); )==""\n"
82R"==(const int d1 = get_global_id(1); )==""\n"
83R"==(const int d2 = get_global_id(2); )==""\n"
84R"==(#ifdef LIMIT_MAX_D0 )==""\n"
85R"==(if (d0 >= LIMIT_MAX_D0) { return; } )==""\n"
86R"==(#endif )==""\n"
87R"==(const int src_base = S0 * d0 + S1 * d1 + S2 * d2; )==""\n"
88R"==(const int dst_base = D0 * d0 + D1 * d1 + D2 * d2; )==""\n"
89R"==(for (int db = 0; db < BLK; ++db) { )==""\n"
90R"==(const int src_off = src_base + db * SB; )==""\n"
91R"==(const int dst_off = dst_base + db * DB; )==""\n"
92R"==(REORDER(dst[dst_off], src[src_off], src_scale, dst_scale, sum_scale, )==""\n"
93R"==(src_zp, dst_zp, sum_zp); )==""\n"
94R"==(} )==""\n"
95R"==(#elif PLAIN_xFxE_TO_ABCDEF )==""\n"
96R"==(const int d0 = GWS_GET_D0(); )==""\n"
97R"==(const int d1 = GWS_GET_D1(); )==""\n"
98R"==(const int d2 = GWS_GET_D2(); )==""\n"
99R"==(const int d3 = GWS_GET_D3(); )==""\n"
100R"==(const int d4 = GWS_GET_D4(); )==""\n"
101R"==(const int d5 = GWS_GET_D5(); )==""\n"
102R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
103R"==(#define SUM_OUTPUT 1 )==""\n"
104R"==(#else )==""\n"
105R"==(#define SUM_OUTPUT 0 )==""\n"
106R"==(#endif )==""\n"
107R"==(const unsigned sglid = get_sub_group_local_id(); )==""\n"
108R"==(#define REORDER_BLOCK(block_size, src_memory, src_swap, src_offset) \ )==""\n"
109R"==({ \ )==""\n"
110R"==(unroll_for(unsigned sidx = 0; sidx < block_size; ++sidx) { \ )==""\n"
111R"==(const unsigned src_off \ )==""\n"
112R"==(= SRC_OFF(d0, d1, d2, d3, d4, sidx + src_offset); \ )==""\n"
113R"==(src_memory[sidx] = SRC_BLOCK_READ(&src[src_off]); \ )==""\n"
114R"==(} \ )==""\n"
115R"==(unroll_for(int j = 0; j < SUB_GROUP_SIZE; j++) \ )==""\n"
116R"==(unroll_for(int i = 0; i < block_size; i++) { \ )==""\n"
117R"==(unsigned x = (i + j * block_size) / SUB_GROUP_SIZE; \ )==""\n"
118R"==(unsigned y = (i + j * block_size) % SUB_GROUP_SIZE; \ )==""\n"
119R"==(unsigned sg_src = (i + j * block_size) / block_size; \ )==""\n"
120R"==(src_swap[x][y] = intel_sub_group_shuffle(src_mem[i], sg_src); \ )==""\n"
121R"==(} \ )==""\n"
122R"==(\ )==""\n"
123R"==(DST_DATA_T dst_tmp; \ )==""\n"
124R"==(unsigned dst_off; \ )==""\n"
125R"==(if (block_size < 16) dst_off = DST_OFF(d0, d1, d2, d3, d4, 0); \ )==""\n"
126R"==(\ )==""\n"
127R"==(unroll_for(unsigned sidx = 0; sidx < block_size; ++sidx) { \ )==""\n"
128R"==(if (block_size >= 16) \ )==""\n"
129R"==(dst_off = DST_OFF(d0, d1, d2, d3, d4 + sidx, src_offset); \ )==""\n"
130R"==(if (SUM_OUTPUT) dst_tmp = DST_BLOCK_READ(&dst[dst_off]); \ )==""\n"
131R"==(REORDER(dst_tmp, src_swap[sidx][sglid], src_scale, dst_scale, \ )==""\n"
132R"==(sum_scale, src_zp, dst_zp, sum_zp); \ )==""\n"
133R"==(DST_BLOCK_WRITE(&dst[dst_off], dst_tmp); \ )==""\n"
134R"==(if (block_size < 16) dst_off += SUB_GROUP_SIZE; \ )==""\n"
135R"==(} \ )==""\n"
136R"==(} )==""\n"
137R"==(#if DST_D5 > 16 )==""\n"
138R"==(unsigned block_size = 16; )==""\n"
139R"==(#else )==""\n"
140R"==(unsigned block_size = DST_D5; )==""\n"
141R"==(#endif )==""\n"
142R"==(SRC_DATA_T src_mem[16]; )==""\n"
143R"==(SRC_DATA_T src_all[16][SUB_GROUP_SIZE]; )==""\n"
144R"==(REORDER_BLOCK(block_size, src_mem, src_all, d5); )==""\n"
145R"==(#elif TRANSPOSE_NXN || LOCAL_NXN )==""\n"
146R"==(#define BATCH_SIZE SUB_GROUP_SIZE )==""\n"
147R"==(int sgId = get_sub_group_local_id(); )==""\n"
148R"==(int sg_off = get_sub_group_id() * SUB_GROUP_SIZE * BATCH_SIZE; )==""\n"
149R"==(const int d0 = GWS_GET_D0(); )==""\n"
150R"==(const int d1 = GWS_GET_D1(); )==""\n"
151R"==(const int d2 = GWS_GET_D2(); )==""\n"
152R"==(const int d3 = GWS_GET_D3(); )==""\n"
153R"==(const int d4 = GWS_GET_D4(); )==""\n"
154R"==(const int d5 = GWS_GET_D5(); )==""\n"
155R"==(const int d0_block = GWS_GET_D0_BLOCK(); )==""\n"
156R"==(const int d1_block = GWS_GET_D1_BLOCK(); )==""\n"
157R"==(const int d2_block = GWS_GET_D2_BLOCK(); )==""\n"
158R"==(const int d3_block = GWS_GET_D3_BLOCK(); )==""\n"
159R"==(const int d4_block = GWS_GET_D4_BLOCK(); )==""\n"
160R"==(const int d5_block = GWS_GET_D5_BLOCK(); )==""\n"
161R"==(#ifdef TRANSPOSE_NXN )==""\n"
162R"==(SRC_DATA_T src_buf[SUB_GROUP_SIZE]; )==""\n"
163R"==(SRC_DATA_T dst_buf[SUB_GROUP_SIZE]; )==""\n"
164R"==(#else )==""\n"
165R"==(__local SRC_DATA_T tmp[SG_PER_WG * BATCH_SIZE]; )==""\n"
166R"==(#endif )==""\n"
167R"==(SRC_DATA_T send_buf; )==""\n"
168R"==(#if PAD_FILL_ZERO == 1 )==""\n"
169R"==(const int pad_d0 = d0 >= SRC_D0; )==""\n"
170R"==(const int pad_d1 = NDIMS > 1 && d1 >= SRC_D1; )==""\n"
171R"==(const int pad_d2 = NDIMS > 2 && d2 >= SRC_D2; )==""\n"
172R"==(const int pad_d3 = NDIMS > 3 && d3 >= SRC_D3; )==""\n"
173R"==(const int pad_d4 = NDIMS > 4 && d4 >= SRC_D4; )==""\n"
174R"==(const int pad_d5 = NDIMS > 5 && d5 >= SRC_D5; )==""\n"
175R"==(const int pad = pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5; )==""\n"
176R"==(#else )==""\n"
177R"==(const int pad = 0; )==""\n"
178R"==(#endif )==""\n"
179R"==(if (!pad) { )==""\n"
180R"==(for_(int d0i = 0; d0i < d0_block; d0i++) )==""\n"
181R"==(for_(int d1i = 0; d1i < d1_block; d1i++) )==""\n"
182R"==(for_(int d2i = 0; d2i < d2_block; d2i++) )==""\n"
183R"==(for_(int d3i = 0; d3i < d3_block; d3i++) )==""\n"
184R"==(for_(int d4i = 0; d4i < d4_block; d4i++) )==""\n"
185R"==(for (int d5i = 0; d5i < d5_block; d5i++) { )==""\n"
186R"==(const int iter = d0i + d1i + d2i + d3i + d4i + d5i; )==""\n"
187R"==(const int src_off = SRC_OFF( )==""\n"
188R"==(d0 + d0i, d1 + d1i, d2 + d2i, d3 + d3i, d4 + d4i, d5 + d5i); )==""\n"
189R"==(#ifdef TRANSPOSE_NXN )==""\n"
190R"==(src_buf[iter] = SRC_BLOCK_READ(&src[src_off]); )==""\n"
191R"==(#else )==""\n"
192R"==(tmp[sg_off + iter * SUB_GROUP_SIZE + sgId] )==""\n"
193R"==(= SRC_BLOCK_READ(&src[src_off]); )==""\n"
194R"==(#endif )==""\n"
195R"==(} )==""\n"
196R"==(#ifdef TRANSPOSE_NXN )==""\n"
197R"==(dst_buf[sgId] = src_buf[sgId]; )==""\n"
198R"==(for (int i = 1; i < SUB_GROUP_SIZE; i++) { )==""\n"
199R"==(send_buf = src_buf[(i + sgId) % BATCH_SIZE]; )==""\n"
200R"==(dst_buf[(BATCH_SIZE + sgId - i) % BATCH_SIZE] )==""\n"
201R"==(= intel_sub_group_shuffle( )==""\n"
202R"==(send_buf, (BATCH_SIZE + sgId - i) % BATCH_SIZE); )==""\n"
203R"==(} )==""\n"
204R"==(#endif )==""\n"
205R"==(} )==""\n"
206R"==(for_(int d0i = 0; d0i < d0_block; d0i++) )==""\n"
207R"==(for_(int d1i = 0; d1i < d1_block; d1i++) )==""\n"
208R"==(for_(int d2i = 0; d2i < d2_block; d2i++) )==""\n"
209R"==(for_(int d3i = 0; d3i < d3_block; d3i++) )==""\n"
210R"==(for_(int d4i = 0; d4i < d4_block; d4i++) )==""\n"
211R"==(for (int d5i = 0; d5i < d5_block; d5i++) { )==""\n"
212R"==(const int iter = d0i + d1i + d2i + d3i + d4i + d5i; )==""\n"
213R"==(#if DST_BLOCK_DIM == 0 )==""\n"
214R"==(const int dst_off = DST_OFF(d0 + iter, d1, d2, d3, d4, d5); )==""\n"
215R"==(#elif DST_BLOCK_DIM == 1 )==""\n"
216R"==(const int dst_off = DST_OFF(d0, d1 + iter, d2, d3, d4, d5); )==""\n"
217R"==(#elif DST_BLOCK_DIM == 2 )==""\n"
218R"==(const int dst_off = DST_OFF(d0, d1, d2 + iter, d3, d4, d5); )==""\n"
219R"==(#elif DST_BLOCK_DIM == 3 )==""\n"
220R"==(const int dst_off = DST_OFF(d0, d1, d2, d3 + iter, d4, d5); )==""\n"
221R"==(#elif DST_BLOCK_DIM == 4 )==""\n"
222R"==(const int dst_off = DST_OFF(d0, d1, d2, d3, d4 + iter, d5); )==""\n"
223R"==(#elif DST_BLOCK_DIM == 5 )==""\n"
224R"==(const int dst_off = DST_OFF(d0, d1, d2, d3, d4, d5 + iter); )==""\n"
225R"==(#endif )==""\n"
226R"==(DST_DATA_T dst_tmp; )==""\n"
227R"==(if (!pad) { )==""\n"
228R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
229R"==(dst_tmp = DST_BLOCK_READ(&dst[dst_off]); )==""\n"
230R"==(#endif )==""\n"
231R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES > 1 )==""\n"
232R"==(src_scale = src_scales[SCALE_OFF(SRC, d0, d1, d2, d3, d4, d5)]; )==""\n"
233R"==(#endif )==""\n"
234R"==(#if WITH_DST_SCALE && DST_NUM_SCALES > 1 )==""\n"
235R"==(dst_scale = dst_scales[SCALE_OFF(DST, d0, d1, d2, d3, d4, d5)]; )==""\n"
236R"==(#endif )==""\n"
237R"==(#ifdef TRANSPOSE_NXN )==""\n"
238R"==(REORDER(dst_tmp, dst_buf[iter], src_scale, dst_scale, sum_scale, )==""\n"
239R"==(src_zp, dst_zp, sum_zp); )==""\n"
240R"==(#else )==""\n"
241R"==(send_buf = tmp[sg_off + sgId * SUB_GROUP_SIZE + iter]; )==""\n"
242R"==(REORDER(dst_tmp, send_buf, src_scale, dst_scale, sum_scale, src_zp, )==""\n"
243R"==(dst_zp, sum_zp); )==""\n"
244R"==(#endif )==""\n"
245R"==(} else { )==""\n"
246R"==(dst_tmp = 0; )==""\n"
247R"==(} )==""\n"
248R"==(DST_BLOCK_WRITE(&dst[dst_off], dst_tmp); )==""\n"
249R"==(} )==""\n"
250R"==(#elif REORDER_NCHW )==""\n"
251R"==(#define BIGGER_THAN_16 (SRC_D1 >= 16) )==""\n"
252R"==(int sgId = get_sub_group_local_id(); )==""\n"
253R"==(const int d0 = GWS_GET_D0(); )==""\n"
254R"==(const int d1 = GWS_GET_D1(); )==""\n"
255R"==(const int d2 = GWS_GET_D2(); )==""\n"
256R"==(const int d3 = GWS_GET_D3(); )==""\n"
257R"==(const int d1_block = GWS_GET_D1_BLOCK(); )==""\n"
258R"==(SRC_DATA_T src_buf[SUB_GROUP_SIZE]; )==""\n"
259R"==(SRC_DATA_T dst_buf[SUB_GROUP_SIZE]; )==""\n"
260R"==(#if BIGGER_THAN_16 )==""\n"
261R"==(SRC_DATA_T send_buf; )==""\n"
262R"==(#else )==""\n"
263R"==(SRC_DATA_T exch_buf[d1_block][SUB_GROUP_SIZE]; )==""\n"
264R"==(#endif )==""\n"
265R"==(#if BIGGER_THAN_16 )==""\n"
266R"==(#define STRIDE_S SRC_D1 )==""\n"
267R"==(#else )==""\n"
268R"==(#define STRIDE_S 16 )==""\n"
269R"==(#endif )==""\n"
270R"==(#define STRIDE_D (SRC_D2 * SRC_D3) )==""\n"
271R"==(for (int i = 0; i < d1_block; i++) { )==""\n"
272R"==(int src_off = SRC_OFF(d0, d1, d2, d3, 0, 0) + STRIDE_S * i; )==""\n"
273R"==(src_buf[i] = SRC_BLOCK_READ(&src[src_off]); )==""\n"
274R"==(} )==""\n"
275R"==(#if BIGGER_THAN_16 )==""\n"
276R"==(for (int i = 0; i < SUB_GROUP_SIZE; i++) { )==""\n"
277R"==(send_buf = src_buf[(i + sgId) % 16]; )==""\n"
278R"==(dst_buf[(16 + sgId - i) % 16] )==""\n"
279R"==(= intel_sub_group_shuffle(send_buf, (16 + sgId - i) % 16); )==""\n"
280R"==(} )==""\n"
281R"==(#else )==""\n"
282R"==(for (int i = 0; i < d1_block; i++) { )==""\n"
283R"==(for (int sg = 0; sg < SUB_GROUP_SIZE; sg++) { )==""\n"
284R"==(exch_buf[i][sg] = intel_sub_group_shuffle(src_buf[i], sg); )==""\n"
285R"==(} )==""\n"
286R"==(} )==""\n"
287R"==(for (int i = 0; i < d1_block; i++) { )==""\n"
288R"==(int ofs = i + sgId * d1_block; )==""\n"
289R"==(dst_buf[i] = exch_buf[ofs / SUB_GROUP_SIZE][ofs % SUB_GROUP_SIZE]; )==""\n"
290R"==(} )==""\n"
291R"==(#endif )==""\n"
292R"==(for (int i = 0; i < d1_block; i++) { )==""\n"
293R"==(int dst_off = DST_OFF(d0, d1, d2, d3, 0, 0) + STRIDE_D * i; )==""\n"
294R"==(DST_DATA_T dst_tmp; )==""\n"
295R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
296R"==(dst_tmp = DST_BLOCK_READ(&dst[dst_off]); )==""\n"
297R"==(#endif )==""\n"
298R"==(REORDER(dst_tmp, dst_buf[i], src_scale, dst_scale, sum_scale, src_zp, )==""\n"
299R"==(dst_zp, sum_zp); )==""\n"
300R"==(DST_BLOCK_WRITE(&dst[dst_off], dst_tmp); )==""\n"
301R"==(} )==""\n"
302R"==(#elif PLAIN_TO_ABCD84A42B )==""\n"
303R"==(const int sglid = get_sub_group_local_id(); )==""\n"
304R"==(const int sg = get_sub_group_id(); )==""\n"
305R"==(#define SRC_D3_ALIGNED (SRC_D3 % SUB_GROUP_SIZE == 0) )==""\n"
306R"==(#define IS_SRC_ABCD_LAYOUT (SRC_S3_0 == 1) )==""\n"
307R"==(#define IS_SRC_ACDB_LAYOUT (SRC_S3_0 != 1) )==""\n"
308R"==(const int d0 = GWS_GET_D0(); )==""\n"
309R"==(const int d1 = GWS_GET_D1(); )==""\n"
310R"==(const int d2 = GWS_GET_D2(); )==""\n"
311R"==(const int d3 = GWS_GET_D3(); )==""\n"
312R"==(const int d0_block = GWS_GET_D0_BLOCK(); )==""\n"
313R"==(const int d1_block = GWS_GET_D1_BLOCK(); )==""\n"
314R"==(const int d01_block = d0_block * d1_block; )==""\n"
315R"==(__local SRC_DATA_T loc_buf[SG_PER_WG][d01_block][SUB_GROUP_SIZE]; )==""\n"
316R"==(for (int d0_inner = 0; d0_inner < d0_block; d0_inner++) { )==""\n"
317R"==(for (int d1_inner = 0; d1_inner < d1_block; d1_inner++) { )==""\n"
318R"==(if (SRC_D0 % d0_block != 0 && d0 + d0_inner >= SRC_D0) { )==""\n"
319R"==(loc_buf[sg][d0_inner * d1_block + d1_inner][sglid] = 0; )==""\n"
320R"==(continue; )==""\n"
321R"==(} )==""\n"
322R"==(if (SRC_D1 % d1_block != 0 && d1 + d1_inner >= SRC_D1) { )==""\n"
323R"==(loc_buf[sg][d0_inner * d1_block + d1_inner][sglid] = 0; )==""\n"
324R"==(continue; )==""\n"
325R"==(} )==""\n"
326R"==(if (IS_SRC_ABCD_LAYOUT )==""\n"
327R"==(&& (SRC_D3_ALIGNED || d3 + SUB_GROUP_SIZE < SRC_D3)) { )==""\n"
328R"==(const int src_off )==""\n"
329R"==(= SRC_OFF(d0 + d0_inner, d1 + d1_inner, d2, d3, 0, 0); )==""\n"
330R"==(loc_buf[sg][d0_inner * d1_block + d1_inner][sglid] )==""\n"
331R"==(= src[src_off + sglid]; )==""\n"
332R"==(} else { )==""\n"
333R"==(if (SRC_D3_ALIGNED || d3 + sglid < SRC_D3) { )==""\n"
334R"==(const int src_off = SRC_OFF( )==""\n"
335R"==(d0 + d0_inner, d1 + d1_inner, d2, d3 + sglid, 0, 0); )==""\n"
336R"==(loc_buf[sg][d0_inner * d1_block + d1_inner][sglid] )==""\n"
337R"==(= src[src_off]; )==""\n"
338R"==(} )==""\n"
339R"==(} )==""\n"
340R"==(} )==""\n"
341R"==(} )==""\n"
342R"==(if (SRC_D3_ALIGNED || d3 + SUB_GROUP_SIZE < SRC_D3) { )==""\n"
343R"==(for (int d = 0; d < SUB_GROUP_SIZE; d += 8) { )==""\n"
344R"==(SRC_DATA8_T src_tmp; )==""\n"
345R"==(for (int i = 0; i < 8; i++) { )==""\n"
346R"==(src_tmp[i] = loc_buf[sg][sglid][d + i]; )==""\n"
347R"==(} )==""\n"
348R"==(const int dst_off = DST_OFF(d0, d1, d2, d3 + d, 0, 0); )==""\n"
349R"==(DST_DATA8_T dst_tmp; )==""\n"
350R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
351R"==(for (int n = 0; n < 8; n++) { )==""\n"
352R"==(dst_tmp[n] = dst[dst_off + sglid + n * SUB_GROUP_SIZE]; )==""\n"
353R"==(} )==""\n"
354R"==(#endif )==""\n"
355R"==(REORDER8(dst_tmp, src_tmp, src_scale, dst_scale, sum_scale, src_zp, )==""\n"
356R"==(dst_zp, sum_zp); )==""\n"
357R"==(for (int n = 0; n < 8; n++) { )==""\n"
358R"==(dst[dst_off + sglid + n * SUB_GROUP_SIZE] = dst_tmp[n]; )==""\n"
359R"==(} )==""\n"
360R"==(} )==""\n"
361R"==(} else { )==""\n"
362R"==(for (int d = 0; d < SUB_GROUP_SIZE; d++) { )==""\n"
363R"==(if (d3 + d < SRC_D3) { )==""\n"
364R"==(const SRC_DATA_T src_tmp = loc_buf[sg][sglid][d]; )==""\n"
365R"==(const int dst_off = DST_OFF(d0, d1, d2, d3 + d, 0, 0); )==""\n"
366R"==(DST_DATA_T dst_tmp; )==""\n"
367R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
368R"==(dst_tmp[n] = dst[dst_off + sglid]; )==""\n"
369R"==(#endif )==""\n"
370R"==(REORDER(dst_tmp, src_tmp, src_scale, dst_scale, sum_scale, )==""\n"
371R"==(src_zp, dst_zp, sum_zp); )==""\n"
372R"==(dst[dst_off + sglid] = dst_tmp; )==""\n"
373R"==(} )==""\n"
374R"==(} )==""\n"
375R"==(} )==""\n"
376R"==(#elif PLAIN_TO_AB_XX_8AYB )==""\n"
377R"==(int sgId = get_sub_group_local_id(); )==""\n"
378R"==(const int d0 = GWS_GET_D0(); )==""\n"
379R"==(const int d1 = GWS_GET_D1(); )==""\n"
380R"==(const int d0b = GWS_GET_D0_BLOCK(); )==""\n"
381R"==(const int d1b = GWS_GET_D1_BLOCK(); )==""\n"
382R"==(SRC_DATA_T src_buf[d0b]; )==""\n"
383R"==(DST_DATA_T dst_buf[d0b]; )==""\n"
384R"==(for (int d0i = 0; d0i < d0b; ++d0i) { )==""\n"
385R"==(const int src_off = SRC_OFF(d0 + d0i, d1, 0, 0, 0, 0); )==""\n"
386R"==(src_buf[d0i] = SRC_BLOCK_READ(&src[src_off]); )==""\n"
387R"==(} )==""\n"
388R"==(SRC_DATA_T tmp_buf[d0b][SUB_GROUP_SIZE]; )==""\n"
389R"==(for (int i = 0; i < d0b; i++) { )==""\n"
390R"==(for (int sg = 0; sg < SUB_GROUP_SIZE; sg++) { )==""\n"
391R"==(tmp_buf[i][sg] = intel_sub_group_shuffle(src_buf[i], sg); )==""\n"
392R"==(} )==""\n"
393R"==(} )==""\n"
394R"==(#if BLK_L == 4 )==""\n"
395R"==(for (int d0i = 0; d0i < d0b; ++d0i) { )==""\n"
396R"==(dst_buf[d0i] = tmp_buf[(d0i % 2 * BLK_L) + sgId / BLK_L] )==""\n"
397R"==([(d0i / 2) * BLK_L + sgId % BLK_L]; )==""\n"
398R"==(} )==""\n"
399R"==(#else )==""\n"
400R"==(for (int d0i = 0; d0i < d0b; ++d0i) { )==""\n"
401R"==(dst_buf[d0i] = tmp_buf[sgId / BLK_L][d0i * BLK_L + sgId % BLK_L]; )==""\n"
402R"==(} )==""\n"
403R"==(#endif )==""\n"
404R"==(for (int d0i = 0; d0i < d0b; ++d0i) { )==""\n"
405R"==(const int dst_off = DST_OFF(d0, d1, 0, 0, 0, 0) + SUB_GROUP_SIZE * d0i; )==""\n"
406R"==(DST_DATA_T dst_tmp; )==""\n"
407R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
408R"==(dst_tmp = DST_BLOCK_READ(&dst[dst_off]); )==""\n"
409R"==(#endif )==""\n"
410R"==(REORDER(dst_tmp, dst_buf[d0i], src_scale, dst_scale, sum_scale, src_zp, )==""\n"
411R"==(dst_zp, sum_zp); )==""\n"
412R"==(DST_BLOCK_WRITE(&dst[dst_off], dst_tmp); )==""\n"
413R"==(} )==""\n"
414R"==(#elif VECTORIZE_LAST_DIM )==""\n"
415R"==(const int d0 = GWS_GET_D0(); )==""\n"
416R"==(const int d1 = GWS_GET_D1(); )==""\n"
417R"==(const int d2 = GWS_GET_D2(); )==""\n"
418R"==(const int d3 = GWS_GET_D3(); )==""\n"
419R"==(const int d4 = GWS_GET_D4(); )==""\n"
420R"==(const int d5 = GWS_GET_D5(); )==""\n"
421R"==(const int d0_block = GWS_GET_D0_BLOCK(); )==""\n"
422R"==(const int d1_block = GWS_GET_D1_BLOCK(); )==""\n"
423R"==(const int d2_block = GWS_GET_D2_BLOCK(); )==""\n"
424R"==(const int d3_block = GWS_GET_D3_BLOCK(); )==""\n"
425R"==(const int d4_block = GWS_GET_D4_BLOCK(); )==""\n"
426R"==(for_(int d0i = 0; d0i < d0_block; d0i++) )==""\n"
427R"==(for_(int d1i = 0; d1i < d1_block; d1i++) )==""\n"
428R"==(for_(int d2i = 0; d2i < d2_block; d2i++) )==""\n"
429R"==(for_(int d3i = 0; d3i < d3_block; d3i++) )==""\n"
430R"==(for (int d4i = 0; d4i < d4_block; d4i++) { )==""\n"
431R"==(int src_off )==""\n"
432R"==(= SRC_OFF(d0 + d0i, d1 + d1i, d2 + d2i, d3 + d3i, d4 + d4i, d5); )==""\n"
433R"==(SRC_DATA_T src_tmp = SRC_BLOCK_READ(&src[src_off]); )==""\n"
434R"==(int dst_off )==""\n"
435R"==(= DST_OFF(d0 + d0i, d1 + d1i, d2 + d2i, d3 + d3i, d4 + d4i, d5); )==""\n"
436R"==(DST_DATA_T dst_tmp; )==""\n"
437R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
438R"==(dst_tmp = DST_BLOCK_READ(&dst[dst_off]); )==""\n"
439R"==(#endif )==""\n"
440R"==(REORDER(dst_tmp, src_tmp, src_scale, dst_scale, sum_scale, src_zp, )==""\n"
441R"==(dst_zp, sum_zp); )==""\n"
442R"==(DST_BLOCK_WRITE(&dst[dst_off], dst_tmp); )==""\n"
443R"==(} )==""\n"
444R"==(#elif PAD_INNERMOST )==""\n"
445R"==(const int sgId = get_sub_group_local_id(); )==""\n"
446R"==(int d[6]; )==""\n"
447R"==(int blk[6]; )==""\n"
448R"==(int b[6] = {0, 0, 0, 0, 0, 0}; )==""\n"
449R"==(d[0] = GWS_GET_D0(); )==""\n"
450R"==(d[1] = GWS_GET_D1(); )==""\n"
451R"==(d[2] = GWS_GET_D2(); )==""\n"
452R"==(d[3] = GWS_GET_D3(); )==""\n"
453R"==(d[4] = GWS_GET_D4(); )==""\n"
454R"==(d[5] = GWS_GET_D5(); )==""\n"
455R"==(blk[0] = GWS_GET_D0_BLOCK(); )==""\n"
456R"==(blk[1] = GWS_GET_D1_BLOCK(); )==""\n"
457R"==(blk[2] = GWS_GET_D2_BLOCK(); )==""\n"
458R"==(blk[3] = GWS_GET_D3_BLOCK(); )==""\n"
459R"==(blk[4] = GWS_GET_D4_BLOCK(); )==""\n"
460R"==(blk[5] = GWS_GET_D5_BLOCK(); )==""\n"
461R"==(__local SRC_DATA_T cache[SG_PER_WG * GROUP * GROUP * VECT_SIZE]; )==""\n"
462R"==(const int sg_off = get_sub_group_id() * VECT_SIZE * (GROUP * GROUP); )==""\n"
463R"==(for (int i = 0; i < blk[SRC_LOOP_DIM]; i++) { )==""\n"
464R"==(b[SRC_LOOP_DIM] = i; )==""\n"
465R"==(const int src_off = SRC_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
466R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
467R"==(unroll_for(int j = 0; j < GROUP; j++) { )==""\n"
468R"==(const int coff = sg_off + VECT_SIZE * GROUP * i + VECT_SIZE * j; )==""\n"
469R"==(const int soff = src_off + INNERMOST_SIZE * j; )==""\n"
470R"==(#if NON_INNERMOST_PADDING == 1 )==""\n"
471R"==(const int pad_d0 = d[0] + b[0] >= SRC_D0; )==""\n"
472R"==(const int pad_d1 = NDIMS > 1 && d[1] + b[1] >= SRC_D1; )==""\n"
473R"==(const int pad_d2 = NDIMS > 2 && d[2] + b[2] >= SRC_D2; )==""\n"
474R"==(const int pad_d3 = NDIMS > 3 && d[3] + b[3] >= SRC_D3; )==""\n"
475R"==(const int pad_d4 = NDIMS > 4 && d[4] + b[4] >= SRC_D4; )==""\n"
476R"==(const int pad_d5 = NDIMS > 5 && d[5] + b[5] >= SRC_D5; )==""\n"
477R"==(if (pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5) { )==""\n"
478R"==(cache[coff + sgId] = 0; )==""\n"
479R"==(continue; )==""\n"
480R"==(} )==""\n"
481R"==(#endif )==""\n"
482R"==(if (sgId < INNERMOST_SIZE) { )==""\n"
483R"==(cache[coff + sgId] = src[soff + sgId]; )==""\n"
484R"==(} else { )==""\n"
485R"==(cache[coff + sgId] = 0; )==""\n"
486R"==(} )==""\n"
487R"==(} )==""\n"
488R"==(} )==""\n"
489R"==(b[SRC_LOOP_DIM] = 0; )==""\n"
490R"==(for (int i = 0; i < blk[DST_LOOP_DIM]; i++) { )==""\n"
491R"==(b[DST_LOOP_DIM] = i; )==""\n"
492R"==(const int dst_off = DST_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
493R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
494R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES > 1 )==""\n"
495R"==(src_scale = src_scales[SCALE_OFF(SRC, d[0] + b[0], d[1] + b[1], )==""\n"
496R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
497R"==(#endif )==""\n"
498R"==(#if WITH_DST_SCALE && DST_NUM_SCALES > 1 )==""\n"
499R"==(dst_scale = dst_scales[SCALE_OFF(DST, d[0] + b[0], d[1] + b[1], )==""\n"
500R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
501R"==(#endif )==""\n"
502R"==(unroll_for(int j = 0; j < GROUP; j++) { )==""\n"
503R"==(const int coff = sg_off + VECT_SIZE * GROUP * j + VECT_SIZE * i; )==""\n"
504R"==(const int doff = dst_off + VECT_SIZE * j; )==""\n"
505R"==(DST_DATA_T dst_tmp; )==""\n"
506R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
507R"==(dst_tmp = dst[doff + sgId * DST_INNERMOST_STRIDE]; )==""\n"
508R"==(#endif )==""\n"
509R"==(REORDER(dst_tmp, cache[coff + sgId], src_scale, dst_scale, )==""\n"
510R"==(sum_scale, src_zp, dst_zp, sum_zp); )==""\n"
511R"==(dst[doff + sgId * DST_INNERMOST_STRIDE] = dst_tmp; )==""\n"
512R"==(} )==""\n"
513R"==(} )==""\n"
514R"==(#elif VECTORIZE_GROUPS )==""\n"
515R"==(int d[6]; )==""\n"
516R"==(int blk[6]; )==""\n"
517R"==(int b[6] = {0, 0, 0, 0, 0, 0}; )==""\n"
518R"==(d[0] = GWS_GET_D0(); )==""\n"
519R"==(d[1] = GWS_GET_D1(); )==""\n"
520R"==(d[2] = GWS_GET_D2(); )==""\n"
521R"==(d[3] = GWS_GET_D3(); )==""\n"
522R"==(d[4] = GWS_GET_D4(); )==""\n"
523R"==(d[5] = GWS_GET_D5(); )==""\n"
524R"==(blk[0] = GWS_GET_D0_BLOCK(); )==""\n"
525R"==(blk[1] = GWS_GET_D1_BLOCK(); )==""\n"
526R"==(blk[2] = GWS_GET_D2_BLOCK(); )==""\n"
527R"==(blk[3] = GWS_GET_D3_BLOCK(); )==""\n"
528R"==(blk[4] = GWS_GET_D4_BLOCK(); )==""\n"
529R"==(blk[5] = GWS_GET_D5_BLOCK(); )==""\n"
530R"==(SRC_DATA_T cache[GROUP * GROUP]; )==""\n"
531R"==(int coeff = (VECT_DIM == SRC_LOOP_DIM ? get_sub_group_size() : 1); )==""\n"
532R"==(for (int i = 0; i < blk[SRC_LOOP_DIM]; i++) { )==""\n"
533R"==(b[SRC_LOOP_DIM] = coeff * i; )==""\n"
534R"==(const int src_off = SRC_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
535R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
536R"==(unroll_for(int j = 0; j < GROUP; j++) { )==""\n"
537R"==(int cidx = GROUP * i + j; )==""\n"
538R"==(int sidx = src_off + get_sub_group_size() * j; )==""\n"
539R"==(#if PAD_FILL_ZERO == 1 )==""\n"
540R"==(int pad_d0 = d[0] + b[0] >= SRC_D0; )==""\n"
541R"==(int pad_d1 = NDIMS > 1 && d[1] + b[1] >= SRC_D1; )==""\n"
542R"==(int pad_d2 = NDIMS > 2 && d[2] + b[2] >= SRC_D2; )==""\n"
543R"==(int pad_d3 = NDIMS > 3 && d[3] + b[3] >= SRC_D3; )==""\n"
544R"==(int pad_d4 = NDIMS > 4 && d[4] + b[4] >= SRC_D4; )==""\n"
545R"==(int pad_d5 = NDIMS > 5 && d[5] + b[5] >= SRC_D5; )==""\n"
546R"==(if (pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5) { )==""\n"
547R"==(cache[cidx] = 0; )==""\n"
548R"==(continue; )==""\n"
549R"==(} )==""\n"
550R"==(#endif )==""\n"
551R"==(cache[cidx] = SRC_BLOCK_READ(&src[sidx]); )==""\n"
552R"==(} )==""\n"
553R"==(} )==""\n"
554R"==(b[SRC_LOOP_DIM] = 0; )==""\n"
555R"==(coeff = (VECT_DIM == DST_LOOP_DIM ? get_sub_group_size() : 1); )==""\n"
556R"==(for (int i = 0; i < blk[DST_LOOP_DIM]; i++) { )==""\n"
557R"==(b[DST_LOOP_DIM] = coeff * i; )==""\n"
558R"==(const int dst_off = DST_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
559R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
560R"==(int pad_d0 = d[0] + b[0] >= DST_PD0; )==""\n"
561R"==(int pad_d1 = NDIMS > 1 && d[1] + b[1] >= DST_PD1; )==""\n"
562R"==(int pad_d2 = NDIMS > 2 && d[2] + b[2] >= DST_PD2; )==""\n"
563R"==(int pad_d3 = NDIMS > 3 && d[3] + b[3] >= DST_PD3; )==""\n"
564R"==(int pad_d4 = NDIMS > 4 && d[4] + b[4] >= DST_PD4; )==""\n"
565R"==(int pad_d5 = NDIMS > 5 && d[5] + b[5] >= DST_PD5; )==""\n"
566R"==(if (pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5) { )==""\n"
567R"==(continue; )==""\n"
568R"==(} )==""\n"
569R"==(unroll_for(int j = 0; j < GROUP; j++) { )==""\n"
570R"==(int cidx = i + j * GROUP; )==""\n"
571R"==(int didx = dst_off + get_sub_group_size() * j; )==""\n"
572R"==(DST_DATA_T dst_tmp; )==""\n"
573R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
574R"==(dst_tmp = DST_BLOCK_READ(&dst[didx]); )==""\n"
575R"==(#endif )==""\n"
576R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES > 1 )==""\n"
577R"==(src_scale = src_scales[SCALE_OFF(SRC, d[0] + b[0], d[1] + b[1], )==""\n"
578R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
579R"==(#endif )==""\n"
580R"==(#if WITH_DST_SCALE && DST_NUM_SCALES > 1 )==""\n"
581R"==(dst_scale = dst_scales[SCALE_OFF(DST, d[0] + b[0], d[1] + b[1], )==""\n"
582R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
583R"==(#endif )==""\n"
584R"==(REORDER(dst_tmp, cache[cidx], src_scale, dst_scale, sum_scale, )==""\n"
585R"==(src_zp, dst_zp, sum_zp); )==""\n"
586R"==(DST_BLOCK_WRITE(&dst[didx], dst_tmp); )==""\n"
587R"==(} )==""\n"
588R"==(} )==""\n"
589R"==(#elif USE_DENSE_VECT )==""\n"
590R"==(const int d0_blk_start = GWS_GET_D0(); )==""\n"
591R"==(const int d0_blk_end = d0_blk_start + (GWS_GET_D0_BLOCK() * 16); )==""\n"
592R"==(for (int d0 = d0_blk_start; d0 < d0_blk_end; d0 += 128) { )==""\n"
593R"==(SRC_DATA8_T src_tmp = SRC_BLOCK_READ8(&src[d0]); )==""\n"
594R"==(DST_DATA8_T dst_tmp; )==""\n"
595R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
596R"==(dst_tmp = DST_BLOCK_READ8(&dst[d0]); )==""\n"
597R"==(#endif )==""\n"
598R"==(REORDER8(dst_tmp, src_tmp, src_scale, dst_scale, sum_scale, src_zp, )==""\n"
599R"==(dst_zp, sum_zp); )==""\n"
600R"==(DST_BLOCK_WRITE8(&dst[d0], dst_tmp); )==""\n"
601R"==(} )==""\n"
602R"==(#elif XAB_XBA )==""\n"
603R"==(const int sgId = get_sub_group_local_id(); )==""\n"
604R"==(const int sgNr = get_sub_group_id(); )==""\n"
605R"==(const int wgId )==""\n"
606R"==(= get_group_id(0) + 10 * get_group_id(1) + 100 * get_group_id(2); )==""\n"
607R"==(int d[6]; )==""\n"
608R"==(int blk[6]; )==""\n"
609R"==(int b[6] = {0, 0, 0, 0, 0, 0}; )==""\n"
610R"==(d[0] = GWS_GET_D0(); )==""\n"
611R"==(d[1] = GWS_GET_D1(); )==""\n"
612R"==(d[2] = GWS_GET_D2(); )==""\n"
613R"==(d[3] = GWS_GET_D3(); )==""\n"
614R"==(d[4] = GWS_GET_D4(); )==""\n"
615R"==(d[5] = GWS_GET_D5(); )==""\n"
616R"==(blk[0] = GWS_GET_D0_BLOCK(); )==""\n"
617R"==(blk[1] = GWS_GET_D1_BLOCK(); )==""\n"
618R"==(blk[2] = GWS_GET_D2_BLOCK(); )==""\n"
619R"==(blk[3] = GWS_GET_D3_BLOCK(); )==""\n"
620R"==(blk[4] = GWS_GET_D4_BLOCK(); )==""\n"
621R"==(blk[5] = GWS_GET_D5_BLOCK(); )==""\n"
622R"==(__local SRC_DATA_T tmp[SG_PER_WG * SUB_GROUP_SIZE * BLOCK_SIZE]; )==""\n"
623R"==(SRC_DATA_T data; )==""\n"
624R"==(const int sgLs = SUB_GROUP_SIZE * BLOCK_SIZE; )==""\n"
625R"==(const int wg_off = sgNr * sgLs; )==""\n"
626R"==(for (int i = 0; i < blk[SRC_BLK_DIM]; i++) { )==""\n"
627R"==(b[SRC_BLK_DIM] = SRC_OFF_COEFF * i; )==""\n"
628R"==(const int src_off = SRC_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
629R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
630R"==(#if PAD_FILL_ZERO == 1 )==""\n"
631R"==(const int pad_d0 = d[0] + b[0] >= SRC_D0; )==""\n"
632R"==(const int pad_d1 = NDIMS > 1 && d[1] + b[1] >= SRC_D1; )==""\n"
633R"==(const int pad_d2 = NDIMS > 2 && d[2] + b[2] >= SRC_D2; )==""\n"
634R"==(const int pad_d3 = NDIMS > 3 && d[3] + b[3] >= SRC_D3; )==""\n"
635R"==(const int pad_d4 = NDIMS > 4 && d[4] + b[4] >= SRC_D4; )==""\n"
636R"==(const int pad_d5 = NDIMS > 5 && d[5] + b[5] >= SRC_D5; )==""\n"
637R"==(if (pad_d0 || pad_d1 || pad_d2 || pad_d3 || pad_d4 || pad_d5) { )==""\n"
638R"==(tmp[wg_off + SUB_GROUP_SIZE * i + sgId] = 0; )==""\n"
639R"==(continue; )==""\n"
640R"==(} )==""\n"
641R"==(#endif )==""\n"
642R"==(data = src[src_off + sgId]; )==""\n"
643R"==(tmp[wg_off + SUB_GROUP_SIZE * i + sgId] = data; )==""\n"
644R"==(} )==""\n"
645R"==(b[SRC_BLK_DIM] = 0; )==""\n"
646R"==(for (int i = 0; i < blk[SRC_BLK_DIM]; i++) { )==""\n"
647R"==(b[DST_BLK_DIM] = DST_OFF_COEFF * i; )==""\n"
648R"==(const int dst_off = DST_OFF(d[0] + b[0], d[1] + b[1], d[2] + b[2], )==""\n"
649R"==(d[3] + b[3], d[4] + b[4], d[5] + b[5]); )==""\n"
650R"==(#if XB_TO_XAB )==""\n"
651R"==(SRC_DATA_T data = tmp[wg_off + (sgId % (SUB_GROUP_SIZE / BLOCK_SIZE)) )==""\n"
652R"==(+ (sgId / (SUB_GROUP_SIZE / BLOCK_SIZE)) * SUB_GROUP_SIZE )==""\n"
653R"==(+ (SUB_GROUP_SIZE / BLOCK_SIZE) * i]; )==""\n"
654R"==(#else )==""\n"
655R"==(SRC_DATA_T data = tmp[wg_off + (sgId % BLOCK_SIZE) * SUB_GROUP_SIZE )==""\n"
656R"==(+ sgId / BLOCK_SIZE + (SUB_GROUP_SIZE / BLOCK_SIZE) * i]; )==""\n"
657R"==(#endif )==""\n"
658R"==(#if WITH_SRC_SCALE && SRC_NUM_SCALES > 1 )==""\n"
659R"==(src_scale = src_scales[SCALE_OFF(SRC, d[0] + b[0], d[1] + b[1], )==""\n"
660R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
661R"==(#endif )==""\n"
662R"==(#if WITH_DST_SCALE && DST_NUM_SCALES > 1 )==""\n"
663R"==(dst_scale = dst_scales[SCALE_OFF(DST, d[0] + b[0], d[1] + b[1], )==""\n"
664R"==(d[2] + b[2], d[3] + b[3], d[4] + b[4], d[5] + b[5])]; )==""\n"
665R"==(#endif )==""\n"
666R"==(DST_DATA_T dst_tmp; )==""\n"
667R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
668R"==(dst_tmp = dst[dst_off + sgId]; )==""\n"
669R"==(#endif )==""\n"
670R"==(REORDER(dst_tmp, data, src_scale, dst_scale, sum_scale, src_zp, dst_zp, )==""\n"
671R"==(sum_zp); )==""\n"
672R"==(dst[dst_off + sgId] = dst_tmp; )==""\n"
673R"==(} )==""\n"
674R"==(#else )==""\n"
675R"==(const int d0 = GWS_GET_D0(); )==""\n"
676R"==(const int d1 = GWS_GET_D1(); )==""\n"
677R"==(const int d2 = GWS_GET_D2(); )==""\n"
678R"==(const int d3 = GWS_GET_D3(); )==""\n"
679R"==(const int d4 = GWS_GET_D4(); )==""\n"
680R"==(const int d5 = GWS_GET_D5(); )==""\n"
681R"==(const int local_id = get_sub_group_local_id(); )==""\n"
682R"==(#if SRC_16A16B || DST_16A16B || SRC_16B16A || DST_16B16A )==""\n"
683R"==(src += SRC_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
684R"==(dst += DST_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
685R"==(SRC_DATA8_T in0, in1; )==""\n"
686R"==(#if SRC_16A16B || SRC_16B16A )==""\n"
687R"==(in0 = SRC_BLOCK_READ8(&src[0]); )==""\n"
688R"==(in1 = SRC_BLOCK_READ8(&src[8 * 16]); )==""\n"
689R"==(#else )==""\n"
690R"==(for (int i = 0; i < 8; i++) { )==""\n"
691R"==(#if DST_16B16A )==""\n"
692R"==(in0[i] = src[SRC_OFF(local_id, i, 0, 0, 0, 0)]; )==""\n"
693R"==(in1[i] = src[SRC_OFF(local_id, i + 8, 0, 0, 0, 0)]; )==""\n"
694R"==(#else )==""\n"
695R"==(in0[i] = src[SRC_OFF(i, local_id, 0, 0, 0, 0)]; )==""\n"
696R"==(in1[i] = src[SRC_OFF(i + 8, local_id, 0, 0, 0, 0)]; )==""\n"
697R"==(#endif )==""\n"
698R"==(} )==""\n"
699R"==(#endif )==""\n"
700R"==(DST_DATA8_T dst0, dst1; )==""\n"
701R"==(#if (SRC_16A16B || SRC_16B16A) && (DST_16A16B || DST_16B16A) )==""\n"
702R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
703R"==(for (int i = 0; i < 8; i++) { )==""\n"
704R"==(#if SRC_16B16A )==""\n"
705R"==(dst0[i] = dst[DST_OFF(local_id, i + 0, 0, 0, 0, 0)]; )==""\n"
706R"==(dst1[i] = dst[DST_OFF(local_id, i + 8, 0, 0, 0, 0)]; )==""\n"
707R"==(#else )==""\n"
708R"==(dst0[i] = dst[DST_OFF(i + 0, local_id, 0, 0, 0, 0)]; )==""\n"
709R"==(dst1[i] = dst[DST_OFF(i + 8, local_id, 0, 0, 0, 0)]; )==""\n"
710R"==(#endif )==""\n"
711R"==(} )==""\n"
712R"==(#endif )==""\n"
713R"==(#elif DST_16A16B || DST_16B16A )==""\n"
714R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
715R"==(dst0 = DST_BLOCK_READ8(&dst[0]); )==""\n"
716R"==(dst1 = DST_BLOCK_READ8(&dst[8 * 16]); )==""\n"
717R"==(#endif )==""\n"
718R"==(#else )==""\n"
719R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
720R"==(for (int i = 0; i < 8; i++) { )==""\n"
721R"==(#if SRC_16B16A )==""\n"
722R"==(dst0[i] = dst[DST_OFF(local_id, i + 0, 0, 0, 0, 0)]; )==""\n"
723R"==(dst1[i] = dst[DST_OFF(local_id, i + 8, 0, 0, 0, 0)]; )==""\n"
724R"==(#else )==""\n"
725R"==(dst0[i] = dst[DST_OFF(i + 0, local_id, 0, 0, 0, 0)]; )==""\n"
726R"==(dst1[i] = dst[DST_OFF(i + 8, local_id, 0, 0, 0, 0)]; )==""\n"
727R"==(#endif )==""\n"
728R"==(} )==""\n"
729R"==(#endif )==""\n"
730R"==(#endif )==""\n"
731R"==(REORDER8( )==""\n"
732R"==(dst0, in0, src_scale, dst_scale, sum_scale, src_zp, dst_zp, sum_zp); )==""\n"
733R"==(REORDER8( )==""\n"
734R"==(dst1, in1, src_scale, dst_scale, sum_scale, src_zp, dst_zp, sum_zp); )==""\n"
735R"==(#if (SRC_16A16B || SRC_16B16A) && (DST_16A16B || DST_16B16A) )==""\n"
736R"==(for (int i = 0; i < 8; i++) { )==""\n"
737R"==(#if SRC_16B16A )==""\n"
738R"==(dst[DST_OFF(local_id, i + 0, 0, 0, 0, 0)] = dst0[i]; )==""\n"
739R"==(dst[DST_OFF(local_id, i + 8, 0, 0, 0, 0)] = dst1[i]; )==""\n"
740R"==(#else )==""\n"
741R"==(dst[DST_OFF(i + 0, local_id, 0, 0, 0, 0)] = dst0[i]; )==""\n"
742R"==(dst[DST_OFF(i + 8, local_id, 0, 0, 0, 0)] = dst1[i]; )==""\n"
743R"==(#endif )==""\n"
744R"==(} )==""\n"
745R"==(#elif DST_16A16B || DST_16B16A )==""\n"
746R"==(DST_BLOCK_WRITE8(&dst[0], dst0); )==""\n"
747R"==(DST_BLOCK_WRITE8(&dst[8 * 16], dst1); )==""\n"
748R"==(#else )==""\n"
749R"==(for (int i = 0; i < 8; i++) { )==""\n"
750R"==(#if SRC_16B16A )==""\n"
751R"==(dst[DST_OFF(local_id, i + 0, 0, 0, 0, 0)] = dst0[i]; )==""\n"
752R"==(dst[DST_OFF(local_id, i + 8, 0, 0, 0, 0)] = dst1[i]; )==""\n"
753R"==(#else )==""\n"
754R"==(dst[DST_OFF(i + 0, local_id, 0, 0, 0, 0)] = dst0[i]; )==""\n"
755R"==(dst[DST_OFF(i + 8, local_id, 0, 0, 0, 0)] = dst1[i]; )==""\n"
756R"==(#endif )==""\n"
757R"==(} )==""\n"
758R"==(#endif )==""\n"
759R"==(#elif SRC_16B || DST_16B )==""\n"
760R"==(SRC_DATA_T src_tmp; )==""\n"
761R"==(#if SRC_16B )==""\n"
762R"==(src += SRC_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
763R"==(src_tmp = SRC_BLOCK_READ(&src[0]); )==""\n"
764R"==(#else )==""\n"
765R"==(src += SRC_OFF(d0, d1 + local_id, d2, d3, d4, d5); )==""\n"
766R"==(src_tmp = src[0]; )==""\n"
767R"==(#endif )==""\n"
768R"==(DST_DATA_T dst_tmp; )==""\n"
769R"==(#if DST_16B )==""\n"
770R"==(dst += DST_OFF(d0, d1, d2, d3, d4, d5); )==""\n"
771R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
772R"==(dst_tmp = DST_BLOCK_READ(&dst[0]); )==""\n"
773R"==(#endif )==""\n"
774R"==(#else )==""\n"
775R"==(dst += DST_OFF(d0, d1 + local_id, d2, d3, d4, d5); )==""\n"
776R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
777R"==(dst_tmp = dst[0]; )==""\n"
778R"==(#endif )==""\n"
779R"==(#endif )==""\n"
780R"==(REORDER(dst_tmp, src_tmp, src_scale, dst_scale, sum_scale, src_zp, dst_zp, )==""\n"
781R"==(sum_zp); )==""\n"
782R"==(#if DST_16B )==""\n"
783R"==(DST_BLOCK_WRITE(&dst[0], dst_tmp); )==""\n"
784R"==(#else )==""\n"
785R"==(dst[0] = dst_tmp; )==""\n"
786R"==(#endif )==""\n"
787R"==(#elif SRC_16B16C || DST_16B16C || SRC_16C16B || DST_16C16B )==""\n"
788R"==(const int g = d0; )==""\n"
789R"==(SRC_DATA8_T in0, in1; )==""\n"
790R"==(#if SRC_16B16C || SRC_16C16B )==""\n"
791R"==(src += SRC_OFF_G(g, d1, d2, d3, d4, d5); )==""\n"
792R"==(in0 = SRC_BLOCK_READ8(&src[0]); )==""\n"
793R"==(in1 = SRC_BLOCK_READ8(&src[8 * 16]); )==""\n"
794R"==(#else )==""\n"
795R"==(for (int i = 0; i < 8; i++) { )==""\n"
796R"==(#if DST_16C16B )==""\n"
797R"==(in0[i] = src[SRC_OFF_G(g, d1 + local_id, d2 + i + 0, d3, d4, d5)]; )==""\n"
798R"==(in1[i] = src[SRC_OFF_G(g, d1 + local_id, d2 + i + 8, d3, d4, d5)]; )==""\n"
799R"==(#else )==""\n"
800R"==(in0[i] = src[SRC_OFF_G(g, d1 + i + 0, d2 + local_id, d3, d4, d5)]; )==""\n"
801R"==(in1[i] = src[SRC_OFF_G(g, d1 + i + 8, d2 + local_id, d3, d4, d5)]; )==""\n"
802R"==(#endif )==""\n"
803R"==(} )==""\n"
804R"==(#endif )==""\n"
805R"==(DST_DATA8_T dst0, dst1; )==""\n"
806R"==(#if (SRC_16B16C || SRC_16C16B) && (DST_16B16C || DST_16C16B) )==""\n"
807R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
808R"==(for (int i = 0; i < 8; i++) { )==""\n"
809R"==(#if SRC_16C16B )==""\n"
810R"==(dst0[i] = dst[DST_OFF_G(g, d1 + local_id, d2 + i + 0, d3, d4, d5)]; )==""\n"
811R"==(dst1[i] = dst[DST_OFF_G(g, d1 + local_id, d2 + i + 8, d3, d4, d5)]; )==""\n"
812R"==(#else )==""\n"
813R"==(dst0[i] = dst[DST_OFF_G(g, d1 + i + 0, d2 + local_id, d3, d4, d5)]; )==""\n"
814R"==(dst1[i] = dst[DST_OFF_G(g, d1 + i + 8, d2 + local_id, d3, d4, d5)]; )==""\n"
815R"==(#endif )==""\n"
816R"==(} )==""\n"
817R"==(#endif )==""\n"
818R"==(#elif DST_16B16C || DST_16C16B )==""\n"
819R"==(dst += DST_OFF_G(g, d1, d2, d3, d4, d5); )==""\n"
820R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
821R"==(dst0 = DST_BLOCK_READ8(&dst[0]); )==""\n"
822R"==(dst1 = DST_BLOCK_READ8(&dst[8 * 16]); )==""\n"
823R"==(#endif )==""\n"
824R"==(#else )==""\n"
825R"==(#if WITH_SUM_SCALE || WITH_SUM_ZPOINT )==""\n"
826R"==(for (int i = 0; i < 8; i++) { )==""\n"
827R"==(#if SRC_16C16B )==""\n"
828R"==(dst0[i] = dst[DST_OFF_G(g, d1 + local_id, d2 + i + 0, d3, d4, d5)]; )==""\n"
829R"==(dst1[i] = dst[DST_OFF_G(g, d1 + local_id, d2 + i + 8, d3, d4, d5)]; )==""\n"
830R"==(#else )==""\n"
831R"==(dst0[i] = dst[DST_OFF_G(g, d1 + i + 0, d2 + local_id, d3, d4, d5)]; )==""\n"
832R"==(dst1[i] = dst[DST_OFF_G(g, d1 + i + 8, d2 + local_id, d3, d4, d5)]; )==""\n"
833R"==(#endif )==""\n"
834R"==(} )==""\n"
835R"==(#endif )==""\n"
836R"==(#endif )==""\n"
837R"==(REORDER8( )==""\n"
838R"==(dst0, in0, src_scale, dst_scale, sum_scale, src_zp, dst_zp, sum_zp); )==""\n"
839R"==(REORDER8( )==""\n"
840R"==(dst1, in1, src_scale, dst_scale, sum_scale, src_zp, dst_zp, sum_zp); )==""\n"
841R"==(#if (SRC_16B16C || SRC_16C16B) && (DST_16B16C || DST_16C16B) )==""\n"
842R"==(for (int i = 0; i < 8; i++) { )==""\n"
843R"==(#if SRC_16C16B )==""\n"
844R"==(dst[DST_OFF_G(g, d1 + local_id, d2 + i + 0, d3, d4, d5)] = dst0[i]; )==""\n"
845R"==(dst[DST_OFF_G(g, d1 + local_id, d2 + i + 8, d3, d4, d5)] = dst1[i]; )==""\n"
846R"==(#else )==""\n"
847R"==(dst[DST_OFF_G(g, d1 + i + 0, d2 + local_id, d3, d4, d5)] = dst0[i]; )==""\n"
848R"==(dst[DST_OFF_G(g, d1 + i + 8, d2 + local_id, d3, d4, d5)] = dst1[i]; )==""\n"
849R"==(#endif )==""\n"
850R"==(} )==""\n"
851R"==(#elif DST_16B16C || DST_16C16B )==""\n"
852R"==(DST_BLOCK_WRITE8(&dst[0], dst0); )==""\n"
853R"==(DST_BLOCK_WRITE8(&dst[8 * 16], dst1); )==""\n"
854R"==(#else )==""\n"
855R"==(for (int i = 0; i < 8; i++) { )==""\n"
856R"==(#if SRC_16C16B )==""\n"
857R"==(dst[DST_OFF_G(g, d1 + local_id, d2 + i + 0, d3, d4, d5)] = dst0[i]; )==""\n"
858R"==(dst[DST_OFF_G(g, d1 + local_id, d2 + i + 8, d3, d4, d5)] = dst1[i]; )==""\n"
859R"==(#else )==""\n"
860R"==(dst[DST_OFF_G(g, d1 + i + 0, d2 + local_id, d3, d4, d5)] = dst0[i]; )==""\n"
861R"==(dst[DST_OFF_G(g, d1 + i + 8, d2 + local_id, d3, d4, d5)] = dst1[i]; )==""\n"
862R"==(#endif )==""\n"
863R"==(} )==""\n"
864R"==(#endif )==""\n"
865R"==(#endif )==""\n"
866R"==(#endif )==""\n"
867R"==(} )==""\n"
868R"==()==";
869}
870}
871}
872}