[Mlir-commits] [mlir] 53c7fe5 - [mlir][nvgpu]add dim check test to nvgpu.mma op. (#122864)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jan 14 00:27:48 PST 2025
Author: lonely eagle
Date: 2025-01-14T16:27:44+08:00
New Revision: 53c7fe50d869386459226aeac5ec72ee918737c9
URL: https://github.com/llvm/llvm-project/commit/53c7fe50d869386459226aeac5ec72ee918737c9
DIFF: https://github.com/llvm/llvm-project/commit/53c7fe50d869386459226aeac5ec72ee918737c9.diff
LOG: [mlir][nvgpu]add dim check test to nvgpu.mma op. (#122864)
add shape checks of matrixA, matrixB, and matrixC to the nvgpu.mma's verify.
Added:
Modified:
mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp
mlir/test/Dialect/NVGPU/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp b/mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp
index de9bbcbace6924..a027350e8a5f70 100644
--- a/mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp
+++ b/mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp
@@ -203,6 +203,18 @@ static LogicalResult verifyMmaSyncOp(Operation *op,
// Basic verification
//
+ if (aShape.size() != 2) {
+ return op->emitError() << "matrixA must be 2 dimensional vector";
+ }
+
+ if (bShape.size() != 2) {
+ return op->emitError() << "matrixB must be 2 dimensional vector";
+ }
+
+ if (cShape.size() != 2) {
+ return op->emitError() << "matrixC must be 2 dimensional vector";
+ }
+
auto [m, n, k] = mmaShape;
// verify warp-wide size for vector a
diff --git a/mlir/test/Dialect/NVGPU/invalid.mlir b/mlir/test/Dialect/NVGPU/invalid.mlir
index f7db1140794e54..b5bfbe9ff27b79 100644
--- a/mlir/test/Dialect/NVGPU/invalid.mlir
+++ b/mlir/test/Dialect/NVGPU/invalid.mlir
@@ -354,3 +354,27 @@ func.func @rcp_unsupported_ftz(%in : vector<16xf32>) {
// expected-error @+1 {{'nvgpu.rcp' op has a limitation. #nvgpu<rcp_rounding_mode approx> or non-ftz is not supported yet.}}
%out = nvgpu.rcp %in {rounding = approx} : vector<16xf32>
}
+
+// -----
+
+func.func @check_matrixA_dim(%arg0: vector<16xf16>, %arg1: vector<2x2xf16>, %arg2: vector<2x2xf16>) -> vector<2x2xf16> {
+ // expected-error @+1 {{matrixA must be 2 dimensional vector}}
+ %d = nvgpu.mma.sync (%arg0, %arg1, %arg2) {mmaShape = [16, 8, 16]} : (vector<16xf16>, vector<2x2xf16>, vector<2x2xf16>) -> vector<2x2xf16>
+ return %d : vector<2x2xf16>
+}
+
+// -----
+
+func.func @check_matrixB_dim(%arg0: vector<4x4xf16>, %arg1: vector<4xf16>, %arg2: vector<2x2xf16>) -> vector<2x2xf16> {
+ // expected-error @+1 {{matrixB must be 2 dimensional vector}}
+ %d = nvgpu.mma.sync (%arg0, %arg1, %arg2) {mmaShape = [16, 8, 16]} : (vector<4x4xf16>, vector<4xf16>, vector<2x2xf16>) -> vector<2x2xf16>
+ return %d : vector<2x2xf16>
+}
+
+// -----
+
+func.func @check_matrixC_dim(%arg0: vector<4x4xf16>, %arg1: vector<2x2xf16>, %arg2: vector<4xf16>) -> vector<2x2xf16> {
+ // expected-error @+1 {{matrixC must be 2 dimensional vector}}
+ %d = nvgpu.mma.sync (%arg0, %arg1, %arg2) {mmaShape = [16, 8, 16]} : (vector<4x4xf16>, vector<2x2xf16>, vector<4xf16>) -> vector<2x2xf16>
+ return %d : vector<2x2xf16>
+}
More information about the Mlir-commits
mailing list