[Mlir-commits] [mlir] [mlir][IntRangeInference] Infer values for {memref, tensor}.dim (PR #122945)
Krzysztof Drewniak
llvmlistbot at llvm.org
Tue Jan 14 12:56:20 PST 2025
================
@@ -725,3 +726,46 @@ std::optional<bool> mlir::intrange::evaluatePred(CmpPredicate pred,
return false;
return std::nullopt;
}
+
+//===----------------------------------------------------------------------===//
+// Shaped type dimension accessors / ShapedDimOpInterface
+//===----------------------------------------------------------------------===//
+
+ConstantIntRanges
+mlir::intrange::inferShapedDimOpInterface(ShapedDimOpInterface op,
+ const IntegerValueRange &maybeDim) {
+ unsigned width =
+ ConstantIntRanges::getStorageBitwidth(op->getResult(0).getType());
+ APInt zero = APInt::getZero(width);
+ APInt typeMax = APInt::getSignedMaxValue(width);
+
+ auto shapedTy = cast<ShapedType>(op.getShapedValue().getType());
+ if (!shapedTy.hasRank())
+ return ConstantIntRanges::fromSigned(zero, typeMax);
+
+ int64_t rank = shapedTy.getRank();
+ int64_t minDim = 0;
+ int64_t maxDim = rank - 1;
----------------
krzysz00 wrote:
Is it? I could've sworn it was validated against, but maybe I misread something. I'll try to add one and report back.
https://github.com/llvm/llvm-project/pull/122945
More information about the Mlir-commits
mailing list