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

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Aug 6 08:27:53 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) +
----------------
banach-space wrote:

> Doesn't Twine allow for concatenating numbers directly?

Nope (but I might be missing sth): https://github.com/llvm/llvm-project/blob/b1234ddbe2652aa7948242a57107ca7ab12fd2f8/llvm/include/llvm/ADT/Twine.h#L554-L575

However, you can create a `Twine` from `unsigned`: https://github.com/llvm/llvm-project/blob/b1234ddbe2652aa7948242a57107ca7ab12fd2f8/llvm/include/llvm/ADT/Twine.h#L349

Let me do that instead.

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


More information about the Mlir-commits mailing list