@@ -238,4 +238,81 @@ func.func @test_atomic_rmw(%src: ui64, %value : vector<16x4xf32>, %mask : vector
238238 // expected-error@+1 {{failed to verify that all of {tensorDesc, value, result} have same shape}}
239239 xegpu.atomic_rmw addf %1 , %mask , %value: !xegpu.tensor_desc <16 x8 xf32 , #xegpu.scatter_tdesc_attr <chunk_size = 8 >>, vector <16 xi1 >, vector <16 x4 xf32 > -> vector <16 x8 xf32 >
240240 return
241- }
241+ }
242+
243+ // -----
244+ func.func @tensor_desc_invalid_rank (%src: memref <24 x32 xf32 >) {
245+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
246+ // expected-error@+1 {{desc shape rank exceeds 2}}
247+ !xegpu.tensor_desc <16 x2 x2 xf32 >
248+ return
249+ }
250+
251+ // -----
252+ func.func @tensor_desc_1D_invalid_map_layout (%src: memref <24 x32 xf32 >) {
253+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
254+ // expected-error@+1 {{outer layout and data mapping must be 1 for 1D tensor}}
255+ !xegpu.tensor_desc <16 xf32 , #xegpu.sg_map <wi_layout = [2 , 16 ], wi_data = [1 , 1 ]>>
256+ return
257+ }
258+
259+ // -----
260+ func.func @tensor_desc_1D_invalid_map_data (%src: memref <24 x32 xf32 >) {
261+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
262+ // expected-error@+1 {{outer layout and data mapping must be 1 for 1D tensor}}
263+ !xegpu.tensor_desc <16 xf32 , #xegpu.sg_map <wi_layout = [1 , 16 ], wi_data = [2 , 1 ]>>
264+ return
265+ }
266+
267+ // -----
268+ func.func @tensor_desc_invalid_map_layout (%src: memref <24 x32 xf32 >) {
269+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
270+ // expected-error@+1 {{cannot map 8 elements into 16 by 1 tiles}}
271+ !xegpu.tensor_desc <4 x8 xf32 , #xegpu.sg_map <wi_layout = [1 , 16 ], wi_data = [1 , 1 ]>>
272+ return
273+ }
274+
275+ // -----
276+ func.func @tensor_desc_invalid_map_layout_1 (%src: memref <24 x32 xf32 >) {
277+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
278+ // expected-error@+1 {{cannot map 4 elements into 8 by 1 tiles}}
279+ !xegpu.tensor_desc <4 x8 xf32 , #xegpu.sg_map <wi_layout = [8 , 2 ], wi_data = [1 , 1 ]>>
280+ return
281+ }
282+
283+ // -----
284+ func.func @tensor_desc_invalid_map_data (%src: memref <24 x32 xf32 >) {
285+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
286+ // expected-error@+1 {{cannot map 4 elements into 2 by 4 tiles}}
287+ !xegpu.tensor_desc <4 x8 xf32 , #xegpu.sg_map <wi_layout = [2 , 8 ], wi_data = [4 , 1 ]>>
288+ return
289+ }
290+
291+ // -----
292+ func.func @tensor_desc_invalid_map_data_1 (%src: memref <24 x32 xf32 >) {
293+ %0 = xegpu.create_nd_tdesc %src [0 , 0 ] : memref <24 x32 xf32 > ->
294+ // expected-error@+1 {{cannot map 4 elements into 8 by 1 tiles}}
295+ !xegpu.tensor_desc <4 x8 xf32 , #xegpu.sg_map <wi_layout = [8 , 2 ], wi_data = [1 , 2 ]>>
296+ return
297+ }
298+
299+ // -----
300+ func.func @tensor_desc_scatter_invalid_map_data (%src: ui64 ) {
301+ %0 = arith.constant dense <[0 , 8 , 16 , 24 ]> : vector <4 xindex >
302+ %1 = xegpu.create_tdesc %src , %0 : ui64 , vector <4 xindex > ->
303+ // expected-error@+1 {{cannot map over non-contiguous scattered elements}}
304+ !xegpu.tensor_desc <4 x2 xf32 ,
305+ #xegpu.scatter_tdesc_attr <chunk_size = 2 >,
306+ #xegpu.sg_map <wi_layout = [1 , 1 ], wi_data = [2 , 1 ]>>
307+ return
308+ }
309+
310+ // -----
311+ func.func @tensor_desc_scatter_invalid_map_data_1 (%src: ui64 , %offsets: vector <16 xindex >) {
312+ %1 = xegpu.create_tdesc %src , %offsets : ui64 , vector <16 xindex > ->
313+ // expected-error@+1 {{too few contiguous elements for work item mapping}}
314+ !xegpu.tensor_desc <16 xf32 ,
315+ #xegpu.scatter_tdesc_attr <chunk_size = 1 >,
316+ #xegpu.sg_map <wi_layout = [1 , 8 ], wi_data = [1 , 2 ]>>
317+ return
318+ }
0 commit comments