[Mlir-commits] [mlir] eb9a9b9 - [mlir][tosa] Create and use utility to print shapes (#191774)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 14 01:54:59 PDT 2026
Author: Luke Hutton
Date: 2026-04-14T09:54:54+01:00
New Revision: eb9a9b91ea65a7b0da1f84511df1c81805a4f7fd
URL: https://github.com/llvm/llvm-project/commit/eb9a9b91ea65a7b0da1f84511df1c81805a4f7fd
DIFF: https://github.com/llvm/llvm-project/commit/eb9a9b91ea65a7b0da1f84511df1c81805a4f7fd.diff
LOG: [mlir][tosa] Create and use utility to print shapes (#191774)
Follow up for #191300
Added:
Modified:
mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
index 0834aa2123a9c..2754d3b21d4a6 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
@@ -650,6 +650,18 @@ LogicalResult tryUpdateDimOrFailure(Operation *op, int64_t &currDim,
return success();
}
+static void printShapeToDiagnostic(InFlightDiagnostic &diag,
+ ArrayRef<int64_t> shape) {
+ auto printDim = [&](int64_t dim) {
+ if (ShapedType::isDynamic(dim))
+ diag << "?";
+ else
+ diag << dim;
+ };
+
+ llvm::interleaveComma(shape, diag, printDim);
+}
+
LogicalResult verifyConvOutputSize(
Operation *op, const int64_t inputSize, const int64_t kernelSize,
const int64_t outputSize, const int64_t padBefore, const int64_t padAfter,
@@ -2073,15 +2085,9 @@ LogicalResult MatMulOp::verify() {
failed(
verifyCompatibleShape(outputType.getShape(), expectedOutputShape))) {
InFlightDiagnostic opError = emitOpError("expected output shape ");
- auto stringifyDim = [&](int64_t d) {
- if (ShapedType::isDynamic(d))
- opError << "?";
- else
- opError << d;
- };
- llvm::interleaveComma(outputType.getShape(), opError, stringifyDim);
+ printShapeToDiagnostic(opError, outputType.getShape());
opError << " to be compatible with expected output shape ";
- llvm::interleaveComma(expectedOutputShape, opError, stringifyDim);
+ printShapeToDiagnostic(opError, expectedOutputShape);
return opError;
}
@@ -2214,15 +2220,9 @@ LogicalResult MatmulTBlockScaledOp::verify() {
failed(
verifyCompatibleShape(outputType.getShape(), expectedOutputShape))) {
InFlightDiagnostic opError = emitOpError("expected output shape ");
- auto stringifyDim = [&](int64_t d) {
- if (ShapedType::isDynamic(d))
- opError << "?";
- else
- opError << d;
- };
- llvm::interleaveComma(outputType.getShape(), opError, stringifyDim);
+ printShapeToDiagnostic(opError, outputType.getShape());
opError << " to be compatible with expected output shape ";
- llvm::interleaveComma(expectedOutputShape, opError, stringifyDim);
+ printShapeToDiagnostic(opError, expectedOutputShape);
return opError;
}
More information about the Mlir-commits
mailing list