Skip to content

Commit a8fbe1a

Browse files
committed
Verify tile and tensor's rank are the same
1 parent 850d6d0 commit a8fbe1a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,16 @@ LogicalResult MakeDmaDescriptorOp::verify() {
720720
}
721721

722722
ArrayRef<int64_t> globalStaticSizes = getGlobalStaticSizes();
723-
if (globalStaticSizes.size() != globalStaticStrides.size()) {
723+
size_t rank = globalStaticSizes.size();
724+
if (rank != globalStaticStrides.size()) {
724725
return emitOpError("strides and sizes must have same rank.");
725726
}
726727

728+
ArrayRef<int64_t> sharedStaticSizes = getSharedStaticSizes();
729+
if (rank != sharedStaticSizes.size()) {
730+
return emitOpError("tensor must have same rank as tile.");
731+
}
732+
727733
return success();
728734
}
729735

mlir/test/Dialect/AMDGPU/invalid.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,12 @@ func.func @make_dma_descriptor_invalid_size_and_stride_sizes(%base: !amdgpu.tdm_
385385
func.return
386386
}
387387

388+
// -----
389+
390+
// CHECK-LABEL: func @make_dma_descriptor_invalid_shared_and_global_rank
391+
// CHECK-SAME: (%[[BASE:.+]]: !amdgpu.tdm_base<i32>)
392+
func.func @make_dma_descriptor_invalid_shared_and_global_rank(%base: !amdgpu.tdm_base<i32>) {
393+
// expected-error@+1 {{'amdgpu.make_dma_descriptor' op tensor must have same rank as tile.}}
394+
amdgpu.make_dma_descriptor %base globalSize [4, 4] globalStride [1, 1] sharedSize [2] : !amdgpu.tdm_base<i32> -> !amdgpu.tdm_descriptor
395+
func.return
396+
}

0 commit comments

Comments
 (0)