Skip to content

Commit af57f45

Browse files
committed
Add invalid op checks for new op restriction.
1 parent 1077b3a commit af57f45

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

mlir/test/Dialect/XeGPU/invalid.mlir

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,23 @@ func.func @prefetch_offset_wi_1(%src: memref<4x4xf32>) {
392392
return
393393
}
394394

395+
// -----
396+
func.func @prefetch_offset_wi_2(%src: memref<16xf32>) {
397+
%offsets = arith.constant dense<[0]> : vector<1xindex>
398+
%1 = xegpu.create_tdesc %src, %offsets : memref<16xf32>, vector<1xindex>
399+
-> !xegpu.tensor_desc<1x3xf32, #xegpu.scatter_tdesc_attr<chunk_size = 3>>
400+
// expected-error@+1 {{offsets not allowed}}
401+
xegpu.prefetch %1[%offsets]: !xegpu.tensor_desc<1x3xf32, #xegpu.scatter_tdesc_attr<chunk_size = 3>>, vector<1xindex>
402+
return
403+
}
404+
405+
// -----
406+
func.func @prefetch_offset_wi_3(%src: memref<16xf32>) {
407+
// expected-error@+1 {{Expects offsets}}
408+
xegpu.prefetch %src: memref<16xf32>
409+
return
410+
}
411+
395412
// -----
396413
func.func @load_gather_offset_sg(%src: memref<?xf16>) {
397414
%offsets = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
@@ -434,6 +451,44 @@ func.func @store_scatter_offset_wi_2(%src: memref<4x4xf16>) {
434451
return
435452
}
436453

454+
// -----
455+
func.func @store_scatter_offset_wi_3(%src: memref<16xf16>) {
456+
%val = arith.constant dense<2.9>: vector<1xf16>
457+
%mask = arith.constant dense<1>: vector<1xi1>
458+
// expected-error@+1 {{Expects offsets}}
459+
xegpu.store %val, %src, %mask
460+
: vector<1xf16>, memref<16xf16>, vector<1xi1>
461+
return
462+
}
463+
464+
// -----
465+
func.func @store_scatter_offset_wi_4(%src: !xegpu.tensor_desc<1x1xf32, #xegpu.scatter_tdesc_attr<>>) {
466+
%val = arith.constant dense<2.9>: vector<1xf16>
467+
%offsets = arith.constant dense<[0]> : vector<1xindex>
468+
%mask = arith.constant dense<1>: vector<1xi1>
469+
// expected-error@+1 {{offsets not allowed}}
470+
xegpu.store %val, %src[%offsets], %mask
471+
: vector<1xf16>, !xegpu.tensor_desc<1x1xf32, #xegpu.scatter_tdesc_attr<>>, vector<1xindex>, vector<1xi1>
472+
return
473+
}
474+
475+
// -----
476+
func.func @load_gather_offset_wi_4(%src: !xegpu.tensor_desc<1x2xf16, #xegpu.scatter_tdesc_attr<>>) {
477+
%mask = arith.constant dense<1>: vector<1xi1>
478+
%offsets = arith.constant dense<[0]> : vector<1xindex>
479+
// expected-error@+1 {{offsets not allowed}}
480+
%2 = xegpu.load %src[%offsets], %mask <{chunk_size = 2}> : !xegpu.tensor_desc<1x2xf16, #xegpu.scatter_tdesc_attr<>>, vector<1xindex>, vector<1xi1> -> vector<2xf16>
481+
return
482+
}
483+
484+
// -----
485+
func.func @load_gather_offset_wi_3(%src: ui64) {
486+
%mask = arith.constant dense<1>: vector<1xi1>
487+
// expected-error@+1 {{Expects offsets}}
488+
%2 = xegpu.load %src, %mask <{chunk_size = 2}> : ui64, vector<1xi1> -> vector<2xf16>
489+
return
490+
}
491+
437492
// -----
438493
func.func @load_gather_offset_wi_2(%src: ui64) {
439494
%mask = arith.constant dense<1>: vector<1xi1>

0 commit comments

Comments
 (0)