Skip to content

Commit 5e3e7a8

Browse files
committed
Test cases
1 parent d23c97d commit 5e3e7a8

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

mlir/test/Dialect/XeGPU/invalid.mlir

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,81 @@ func.func @test_atomic_rmw(%src: ui64, %value : vector<16x4xf32>, %mask : vector
315315
// expected-error@+1 {{failed to verify that all of {tensorDesc, value, result} have same shape}}
316316
xegpu.atomic_rmw addf %1, %mask, %value: !xegpu.tensor_desc<16x8xf32, #xegpu.scatter_tdesc_attr<chunk_size = 8>>, vector<16xi1>, vector<16x4xf32> -> vector<16x8xf32>
317317
return
318-
}
318+
}
319+
320+
// -----
321+
func.func @tensor_desc_invalid_rank(%src: memref<24x32xf32>) {
322+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
323+
// expected-error@+1 {{desc shape rank exceeds 2}}
324+
!xegpu.tensor_desc<16x2x2xf32>
325+
return
326+
}
327+
328+
// -----
329+
func.func @tensor_desc_1D_invalid_map_layout(%src: memref<24x32xf32>) {
330+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
331+
// expected-error@+1 {{outer layout and data mapping must be 1 for 1D tensor}}
332+
!xegpu.tensor_desc<16xf32, #xegpu.sg_map<wi_layout = [2, 16], wi_data = [1, 1]>>
333+
return
334+
}
335+
336+
// -----
337+
func.func @tensor_desc_1D_invalid_map_data(%src: memref<24x32xf32>) {
338+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
339+
// expected-error@+1 {{outer layout and data mapping must be 1 for 1D tensor}}
340+
!xegpu.tensor_desc<16xf32, #xegpu.sg_map<wi_layout = [1, 16], wi_data = [2, 1]>>
341+
return
342+
}
343+
344+
// -----
345+
func.func @tensor_desc_invalid_map_layout(%src: memref<24x32xf32>) {
346+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
347+
// expected-error@+1 {{cannot map 8 elements into 16 by 1 tiles}}
348+
!xegpu.tensor_desc<4x8xf32, #xegpu.sg_map<wi_layout = [1, 16], wi_data = [1, 1]>>
349+
return
350+
}
351+
352+
// -----
353+
func.func @tensor_desc_invalid_map_layout_1(%src: memref<24x32xf32>) {
354+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
355+
// expected-error@+1 {{cannot map 4 elements into 8 by 1 tiles}}
356+
!xegpu.tensor_desc<4x8xf32, #xegpu.sg_map<wi_layout = [8, 2], wi_data = [1, 1]>>
357+
return
358+
}
359+
360+
// -----
361+
func.func @tensor_desc_invalid_map_data(%src: memref<24x32xf32>) {
362+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
363+
// expected-error@+1 {{cannot map 4 elements into 2 by 4 tiles}}
364+
!xegpu.tensor_desc<4x8xf32, #xegpu.sg_map<wi_layout = [2, 8], wi_data = [4, 1]>>
365+
return
366+
}
367+
368+
// -----
369+
func.func @tensor_desc_invalid_map_data_1(%src: memref<24x32xf32>) {
370+
%0 = xegpu.create_nd_tdesc %src[0, 0] : memref<24x32xf32> ->
371+
// expected-error@+1 {{cannot map 4 elements into 8 by 1 tiles}}
372+
!xegpu.tensor_desc<4x8xf32, #xegpu.sg_map<wi_layout = [8, 2], wi_data = [1, 2]>>
373+
return
374+
}
375+
376+
// -----
377+
func.func @tensor_desc_scatter_invalid_map_data(%src: ui64) {
378+
%0 = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
379+
%1 = xegpu.create_tdesc %src, %0 : ui64, vector<4xindex> ->
380+
// expected-error@+1 {{cannot map over non-contiguous scattered elements}}
381+
!xegpu.tensor_desc<4x2xf32,
382+
#xegpu.scatter_tdesc_attr<chunk_size = 2>,
383+
#xegpu.sg_map<wi_layout = [1, 1], wi_data = [2, 1]>>
384+
return
385+
}
386+
387+
// -----
388+
func.func @tensor_desc_scatter_invalid_map_data_1(%src: ui64, %offsets: vector<16xindex>) {
389+
%1 = xegpu.create_tdesc %src, %offsets : ui64, vector<16xindex> ->
390+
// expected-error@+1 {{too few contiguous elements for work item mapping}}
391+
!xegpu.tensor_desc<16xf32,
392+
#xegpu.scatter_tdesc_attr<chunk_size = 1>,
393+
#xegpu.sg_map<wi_layout = [1, 8], wi_data = [1, 2]>>
394+
return
395+
}

0 commit comments

Comments
 (0)