[Mlir-commits] [mlir] [mlir][tensor] Make tensor::PadOp a ReifyRankedShapedTypeOpInterface (PR #145867)

Matthias Springer llvmlistbot at llvm.org
Thu Jun 26 05:05:30 PDT 2025


================
@@ -195,9 +196,12 @@ FailureOr<Value> bufferization::allocateTensorForShapedValue(
         reifiedShapes = true;
         auto &shape =
             resultDims[llvm::cast<OpResult>(shapedValue).getResultNumber()];
-        for (const auto &dim : enumerate(tensorType.getShape()))
-          if (ShapedType::isDynamic(dim.value()))
-            dynamicSizes.push_back(cast<Value>(shape[dim.index()]));
+        for (const auto &dim : enumerate(tensorType.getShape())) {
+          if (ShapedType::isDynamic(dim.value())) {
+            dynamicSizes.push_back(
+                getValueOrCreateConstantIndexOp(b, loc, shape[dim.index()]));
----------------
matthias-springer wrote:

I think this function is fine. `reifyResultShapes` is guaranteed to return an SSA value for each dynamic dimension, so the `cast<Value>` is fine.


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


More information about the Mlir-commits mailing list