Skip to content

Commit 850d6d0

Browse files
committed
Add verification for same rank
1 parent e022322 commit 850d6d0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,20 @@ LogicalResult TransposeLoadOp::verify() {
710710
//===----------------------------------------------------------------------===//
711711

712712
LogicalResult MakeDmaDescriptorOp::verify() {
713-
if (getGlobalStaticStrides().empty()) {
713+
ArrayRef<int64_t> globalStaticStrides = getGlobalStaticStrides();
714+
715+
if (globalStaticStrides.empty()) {
714716
return emitOpError("strides must not be empty.");
715717
}
716-
if (getGlobalStaticStrides().back() != 1) {
718+
if (globalStaticStrides.back() != 1) {
717719
return emitOpError("strides for the innermost dimension must be 1.");
718720
}
721+
722+
ArrayRef<int64_t> globalStaticSizes = getGlobalStaticSizes();
723+
if (globalStaticSizes.size() != globalStaticStrides.size()) {
724+
return emitOpError("strides and sizes must have same rank.");
725+
}
726+
719727
return success();
720728
}
721729

mlir/test/Dialect/AMDGPU/invalid.mlir

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,17 @@ func.func @make_dma_descriptor_invalid_empty_strides(%base: !amdgpu.tdm_base<i32
371371
// CHECK-SAME: (%[[BASE:.+]]: !amdgpu.tdm_base<i32>)
372372
func.func @make_dma_descriptor_invalid_innermost_stride(%base: !amdgpu.tdm_base<i32>) {
373373
// expected-error@+1 {{'amdgpu.make_dma_descriptor' op strides for the innermost dimension must be 1.}}
374-
amdgpu.make_dma_descriptor %base globalSize [0] globalStride [1, 2] sharedSize [0] : !amdgpu.tdm_base<i32> -> !amdgpu.tdm_descriptor
374+
amdgpu.make_dma_descriptor %base globalSize [2, 2] globalStride [1, 2] sharedSize [0] : !amdgpu.tdm_base<i32> -> !amdgpu.tdm_descriptor
375375
func.return
376376
}
377+
378+
// -----
379+
380+
// CHECK-LABEL: func @make_dma_descriptor_invalid_size_and_stride_sizes
381+
// CHECK-SAME: (%[[BASE:.+]]: !amdgpu.tdm_base<i32>)
382+
func.func @make_dma_descriptor_invalid_size_and_stride_sizes(%base: !amdgpu.tdm_base<i32>) {
383+
// expected-error@+1 {{'amdgpu.make_dma_descriptor' op strides and sizes must have same rank.}}
384+
amdgpu.make_dma_descriptor %base globalSize [1] globalStride [1, 1] sharedSize [0] : !amdgpu.tdm_base<i32> -> !amdgpu.tdm_descriptor
385+
func.return
386+
}
387+

0 commit comments

Comments
 (0)