Skip to content

[mlir][nvgpu] Fix crash when handling 0D memref in OptimizeSharedMemoryPass #124517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mlir/lib/Dialect/NVGPU/Transforms/OptimizeSharedMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ mlir::nvgpu::optimizeSharedMemoryReadsAndWrites(Operation *parentOp,
if (!memRefType || !NVGPUDialect::hasSharedMemoryAddressSpace(memRefType))
return failure();

// Not support 0D MemRefs.
if (memRefType.getRank() == 0)
return failure();

// Abort if the given value has any sub-views; we do not do any alias
// analysis.
bool hasSubView = false;
Expand Down
10 changes: 10 additions & 0 deletions mlir/test/Dialect/NVGPU/optimize-shared-memory.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,13 @@ func.func @abort_if_subview(%arg0: memref<128x128xf16>,

return %mat: vector<1x2xf16>
}

// -----

// Ensure this case not crash

// CHECK-LABEL: func @test_0_d
func.func @test_0_d() -> memref<i32, #gpu.address_space<workgroup>> {
%alloc = memref.alloc() : memref<i32, #gpu.address_space<workgroup>>
return %alloc : memref<i32, #gpu.address_space<workgroup>>
}
Loading