[Mlir-commits] [mlir] [mlir][vector] Clarify the semantics of BroadcastOp (PR #101928)

Jakub Kuderski llvmlistbot at llvm.org
Tue Aug 6 09:03:10 PDT 2024


================
@@ -2406,16 +2422,24 @@ mlir::vector::isBroadcastableTo(Type srcType, VectorType dstVectorType,
 }
 
 LogicalResult BroadcastOp::verify() {
-  std::pair<int, int> mismatchingDims;
+  std::pair<VectorDim, VectorDim> mismatchingDims;
   BroadcastableToResult res = isBroadcastableTo(
       getSourceType(), getResultVectorType(), &mismatchingDims);
   if (res == BroadcastableToResult::Success)
     return success();
   if (res == BroadcastableToResult::SourceRankHigher)
     return emitOpError("source rank higher than destination rank");
-  if (res == BroadcastableToResult::DimensionMismatch)
-    return emitOpError("dimension mismatch (")
-           << mismatchingDims.first << " vs. " << mismatchingDims.second << ")";
+  if (res == BroadcastableToResult::DimensionMismatch) {
+    std::string msg = (Twine("dimension mismatch (") +
+                       (mismatchingDims.first.isScalable ? "[" : "") +
+                       std::to_string(mismatchingDims.first.dim) +
----------------
kuhar wrote:

Or alternatively, why not use the `<<` operator on the diagnostic itself? `return emitOpError("Foo") << bar << "baz";

https://github.com/llvm/llvm-project/pull/101928


More information about the Mlir-commits mailing list