[Mlir-commits] [mlir] [MLIR][Tensor] Fix out-of-bounds FoldEmptyTensorWithDimOp crash #111270 (PR #112196)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 17 09:43:45 PDT 2024


================
@@ -979,7 +979,9 @@ struct FoldEmptyTensorWithDimOp : public OpRewritePattern<DimOp> {
     auto emptyTensorOp = dimOp.getSource().getDefiningOp<EmptyOp>();
     if (!emptyTensorOp || !maybeConstantIndex)
       return failure();
-    if (!emptyTensorOp.getType().isDynamicDim(*maybeConstantIndex))
+    auto emptyTensorType = emptyTensorOp.getType();
----------------
MaheshRavishankar wrote:

> (you could though fold all of these cases to a `ub.unreachable()` intrinsic for example):
> 
> ```
> %a = constant .... tensor<10xf32>
> if (cond) {
>   ...
>   ub.unreachable()
>   ...
> }
> ```

You are missing the point and going on a tangent. The same check is being done in many places.. so your suggestions seems to be
1) Keep doing that. Check at every place if the tensor.dim is out-of-bounds access.
2) Add a different pass that verifies this, but that would have to happen everytime we run the verifier. I dont understand how this is expected to work.

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


More information about the Mlir-commits mailing list