Skip to content

Commit 4553746

Browse files
committed
add invalid tests
1 parent 769bf19 commit 4553746

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

mlir/include/mlir/Dialect/XeGPU/IR/XeGPUOps.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,12 @@ def XeGPU_PrefetchOp : XeGPU_Op<"prefetch", []> {
661661

662662
let assemblyFormat = [{
663663
$source
664-
(`,` $offsets^)?
664+
(`[` $offsets^ `]`)?
665665
prop-dict
666-
attr-dict `:` type($source) (`,` type($offsets)^)?
666+
attr-dict `:` type(operands)
667667
}];
668-
668+
// type($source) (type($offsets)^)?
669+
669670
let builders = [
670671
OpBuilder<(ins "Value": $source,
671672
"xegpu::CachePolicyAttr": $l1_hint,

mlir/lib/Dialect/XeGPU/Transforms/XeGPUUnroll.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ struct UnrollLoadGatherOp : public UnrollPattern<xegpu::LoadGatherOp> {
484484
VectorType valueTy = llvm::dyn_cast<VectorType>(op.getValue().getType());
485485
xegpu::TensorDescType tdescTy = op.getTensorDescType();
486486

487-
if (!tdescTy.isScattered())
487+
if (!tdescTy || !tdescTy.isScattered())
488488
return failure();
489489

490490
std::optional<SmallVector<int64_t>> targetShape = getTargetShape(op);
@@ -546,7 +546,7 @@ struct UnrollPrefetchOp : public UnrollPattern<xegpu::PrefetchOp> {
546546
Location loc = op.getLoc();
547547
xegpu::TensorDescType tdescTy = op.getTensorDescType();
548548

549-
if (!tdescTy.isScattered())
549+
if (!tdescTy || !tdescTy.isScattered())
550550
return failure();
551551

552552
std::optional<SmallVector<int64_t>> targetShape = getTargetShape(op);
@@ -575,7 +575,7 @@ struct UnrollStoreScatterOp : public UnrollPattern<xegpu::StoreScatterOp> {
575575
VectorType valueTy = llvm::dyn_cast<VectorType>(op.getValue().getType());
576576
xegpu::TensorDescType tdescTy = op.getTensorDescType();
577577

578-
if (!tdescTy.isScattered())
578+
if (!tdescTy || !tdescTy.isScattered())
579579
return failure();
580580

581581
std::optional<SmallVector<int64_t>> targetShape = getTargetShape(op);

mlir/test/Dialect/XeGPU/invalid.mlir

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,27 +385,48 @@ func.func @load_gather_vc_3(%src: ui64) {
385385
}
386386

387387
// -----
388-
func.func @load_offset(%src: ui64) {
388+
func.func @load_gather_offset_sg(%src: memref<?xf16>) {
389389
%offsets = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
390390
%mask = arith.constant dense<1>: vector<8xi1>
391391
// expected-error@+1 {{Mask should match value except the chunk size dim}}
392392
%2 = xegpu.load %src[%offsets], %mask
393-
: ui64, vector<4xindex>, vector<8xi1>
394-
-> vector<4x2xf32>
393+
: memref<?xf16>, vector<4xindex>, vector<8xi1>
394+
-> vector<4x2xf16>
395+
return
396+
}
397+
398+
// -----
399+
func.func @load_gather_offset_wi(%src: ui64) {
400+
%mask = arith.constant dense<1>: vector<1xi1>
401+
%offsets = arith.constant dense<[0]> : vector<1xindex>
402+
// expected-error@+1 {{value elements must match chunk size}}
403+
%2 = xegpu.load %src[%offsets], %mask <{chunk_size = 2}> : ui64, vector<1xindex>, vector<1xi1> -> vector<4xf32>
404+
return
405+
}
406+
407+
// -----
408+
func.func @store_scatter_offset(%src: memref<?xf16>) {
409+
%val = arith.constant dense<2.9>: vector<4xf16>
410+
%offsets = arith.constant dense<[0]> : vector<1xindex>
411+
%mask = arith.constant dense<1>: vector<1xi1>
412+
// expected-error@+1 {{value elements must match chunk size}}
413+
xegpu.store %val, %src[%offsets], %mask
414+
: vector<4xf16>, memref<?xf16>, vector<1xindex>, vector<1xi1>
395415
return
396416
}
397417

418+
398419
// -----
399-
func.func @store_offset(%src: ui64) {
420+
func.func @load_gather_offset_wi(%src: ui64) {
400421
%val = arith.constant dense<2.9>: vector<4x2xf16>
401-
%offsets = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
402-
%mask = arith.constant dense<1>: vector<8xi1>
403-
// expected-error@+1 {{Mask should match value except the chunk size dim}}
404-
xegpu.store %val, %src[%offsets], %mask
405-
: vector<4x2xf16>, ui64, vector<4xindex>, vector<8xi1>
422+
%mask = arith.constant dense<1>: vector<1xi1>
423+
%offsets = arith.constant dense<[0]> : vector<1xindex>
424+
// expected-error@+1 {{value elements must match chunk size}}
425+
%2 = xegpu.load %src[%offsets], %mask <{chunk_size = 2}> : ui64, vector<1xindex>, vector<1xi1> -> vector<4xf32>
406426
return
407427
}
408428

429+
409430
// -----
410431
func.func @store_scatter_vc_1(%src: memref<24x32xf32>) {
411432
%0 = arith.constant dense<1>: vector<4xi1>

mlir/test/Dialect/XeGPU/ops.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ gpu.func @prefetch(%src: ui64) {
664664
gpu.func @prefetch_offset(%src: ui64) {
665665
//CHECK: %[[cst:.*]] = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
666666
%0 = arith.constant dense<[0, 8, 16, 24]> : vector<4xindex>
667-
// CHECK: xegpu.prefetch %[[arg0]], %cst <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>}> : ui64, vector<4xindex>
668-
xegpu.prefetch %src, %0 <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>}>: ui64, vector<4xindex>
667+
// CHECK: xegpu.prefetch %[[arg0]][%cst] <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>}> : ui64, vector<4xindex>
668+
xegpu.prefetch %src[%0] <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>}>: ui64, vector<4xindex>
669669
gpu.return
670670
}
671671

0 commit comments

Comments
 (0)