Skip to content

Commit 3b6e09a

Browse files
committed
[mlir][xegpu] fix load/store/prefetch op offset verifier
1 parent 40a042e commit 3b6e09a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

mlir/lib/Dialect/XeGPU/IR/XeGPUOps.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,8 @@ LogicalResult PrefetchNdOp::verify() {
472472
return emitOpError("invalid l3_hint: ") << getL3HintAttr();
473473

474474
int64_t tDescRank = tdescTy.getRank();
475-
int64_t offsetSize = static_cast<int64_t>(getOffsets().size());
476-
int64_t constOffsetSize =
477-
getConstOffsetsAttr() ? getConstOffsetsAttr().size() : 0;
478-
if (((offsetSize != 0) && (offsetSize != tDescRank)) ||
479-
((constOffsetSize != 0) && (constOffsetSize != tDescRank)))
475+
int64_t offsetSize = getMixedOffsets().size();
476+
if (offsetSize != 0 && offsetSize != tDescRank)
480477
return emitOpError(
481478
"Mismatched ranks between offsets and tensor descriptor");
482479

@@ -597,11 +594,8 @@ LogicalResult LoadNdOp::verify() {
597594
<< tdescTy;
598595

599596
int64_t tDescRank = tdescTy.getRank();
600-
int64_t offsetSize = static_cast<int64_t>(getOffsets().size());
601-
int64_t constOffsetSize =
602-
getConstOffsetsAttr() ? getConstOffsetsAttr().size() : 0;
603-
if (((offsetSize != 0) && (offsetSize != tDescRank)) ||
604-
((constOffsetSize != 0) && (constOffsetSize != tDescRank)))
597+
int64_t offsetSize = getMixedOffsets().size();
598+
if (offsetSize != 0 && offsetSize != tDescRank)
605599
return emitOpError(
606600
"Mismatched ranks between offsets and tensor descriptor");
607601

@@ -691,11 +685,8 @@ LogicalResult StoreNdOp::verify() {
691685
<< dstTy;
692686

693687
int64_t tDescRank = dstTy.getRank();
694-
int64_t offsetSize = static_cast<int64_t>(getOffsets().size());
695-
int64_t constOffsetSize =
696-
getConstOffsetsAttr() ? getConstOffsetsAttr().size() : 0;
697-
if (((offsetSize != 0) && (offsetSize != tDescRank)) ||
698-
((constOffsetSize != 0) && (constOffsetSize != tDescRank)))
688+
int64_t offsetSize = getMixedOffsets().size();
689+
if (offsetSize != 0 && offsetSize != tDescRank)
699690
return emitOpError(
700691
"Mismatched ranks between offsets and tensor descriptor");
701692

mlir/test/Dialect/XeGPU/ops.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ gpu.func @subgroup_load_nd_offset_1(%src: memref<24x32xf32>, %x : index, %y : in
278278
gpu.return
279279
}
280280

281+
// CHECK: func @subgroup_load_nd_offset_2(%[[arg0:.*]]: memref<24x32xf32>, %arg1: index) {
282+
gpu.func @subgroup_load_nd_offset_2(%src: memref<24x32xf32>, %x : index) {
283+
// CHECK: %[[R0:.*]] = xegpu.create_nd_tdesc %arg0 : memref<24x32xf32> -> !xegpu.tensor_desc<16x8xf32>
284+
%1 = xegpu.create_nd_tdesc %src : memref<24x32xf32> -> !xegpu.tensor_desc<16x8xf32>
285+
// CHECK: %[[R1:.*]] = xegpu.load_nd %[[R0]][%arg1, 0] <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>, transpose = array<i64: 1, 0>}> : !xegpu.tensor_desc<16x8xf32> -> vector<8x16xf32>
286+
%2 = xegpu.load_nd %1[%x, 0] <{l1_hint = #xegpu.cache_hint<cached>, l2_hint = #xegpu.cache_hint<uncached>, transpose = array<i64: 1, 0>}> : !xegpu.tensor_desc<16x8xf32> -> vector<8x16xf32>
287+
gpu.return
288+
}
289+
281290
// CHECK: func @simt_load_nd_8(%[[arg0:.*]]: memref<24x32xf32>) {
282291
gpu.func @simt_load_nd_8(%src: memref<24x32xf32>) {
283292
// CHECK: %[[R0:.*]] = xegpu.create_nd_tdesc %arg0[0, 0] : memref<24x32xf32> -> !xegpu.tensor_desc<16x8xf32>

0 commit comments

Comments
 (0)