[Mlir-commits] [mlir] [mlir][memref] Fix an invalid dim loop motion crash (PR #74204)
Sanjoy Das
llvmlistbot at llvm.org
Sun Dec 3 20:24:04 PST 2023
================
@@ -893,8 +893,9 @@ Speculation::Speculatability DimOp::getSpeculatability() {
if (!rankedSourceType)
return Speculation::NotSpeculatable;
- // The verifier rejects operations that violate this assertion.
- assert(constantIndex < rankedSourceType.getRank());
+ if (rankedSourceType.getRank() < constantIndex)
----------------
sanjoy wrote:
(This is based on my understanding of LLVM IR, some of these assumptions may be subtly wrong for MLIR dialects.)
As I see it, there are three possibilities, and it's not clear to me which one holds:
1. `tensor.dim 5 %v : tensor<?x?xf32>` is syntactically valid. If so, the verifier should not error out in this case (it's valid IR), and this PR is fine.
2. `tensor.dim 5 %v : tensor<?x?xf32>` is syntactically invalid. If so, the verifier should error out and `DimOp::getSpeculatability` should never be called on such operations. So `assert`ing is fine.
3. `tensor.dim 5 %v : tensor<?x?xf32>` is syntactically invalid, but `DimOp::getSpeculatability` can be called on invalid IR for convenience. If this is the case I understand the PR, but this needs to be explicitly called out as a comment.
https://github.com/llvm/llvm-project/pull/74204
More information about the Mlir-commits
mailing list