[Mlir-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Add columns for constant values/dims (PR #86097)
Matthias Springer
llvmlistbot at llvm.org
Mon Mar 25 03:07:24 PDT 2024
================
@@ -107,25 +107,47 @@ AffineExpr ValueBoundsConstraintSet::getExpr(Value value,
assertValidValueDim(value, dim);
#endif // NDEBUG
+ // Check if the value/dim is statically known. In that case, an affine
+ // constant expression should be returned. This allows us to support
+ // multiplications with constants. (Multiplications of two columns in the
+ // constraint set is not supported.)
+ std::optional<int64_t> constSize = std::nullopt;
auto shapedType = dyn_cast<ShapedType>(value.getType());
if (shapedType) {
- // Static dimension: return constant directly.
if (shapedType.hasRank() && !shapedType.isDynamicDim(*dim))
- return builder.getAffineConstantExpr(shapedType.getDimSize(*dim));
- } else {
- // Constant index value: return directly.
- if (auto constInt = ::getConstantIntValue(value))
- return builder.getAffineConstantExpr(*constInt);
+ constSize = shapedType.getDimSize(*dim);
----------------
matthias-springer wrote:
I don't fully understand the different between symbols and dimensions in `IntegerRelation`. The limitations that I am aware of:
- `getSliceBounds` can only be called on a dimensions, so the first "column" that I add to the constraint set (for which we want to compute LB/UB) is a dimension.
- `projectOut` works on both symbols and dimensions, so all other values are added as symbols.
Basically we have only one dimension and everything else is a symbol. (But the current implementation would make it easy to change this.) This seems to work well so far.
https://github.com/llvm/llvm-project/pull/86097
More information about the Mlir-commits
mailing list