27 boundMap, mapOperands, type, var, stopCondition, closedUB)))
36 ArrayRef<std::pair<
Value, std::optional<int64_t>>> mapOperands) {
39 for (
auto valueDim : mapOperands) {
40 Value value = valueDim.first;
41 std::optional<int64_t> dim = valueDim.second;
43 if (!dim.has_value()) {
46 operands.push_back(value);
50 assert(cast<ShapedType>(value.
getType()).isDynamicDim(*dim) &&
51 "expected dynamic dim");
52 if (isa<RankedTensorType>(value.
getType())) {
54 operands.push_back(b.
create<tensor::DimOp>(loc, value, *dim));
55 }
else if (isa<MemRefType>(value.
getType())) {
57 operands.push_back(b.
create<memref::DimOp>(loc, value, *dim));
59 llvm_unreachable(
"cannot generate DimOp for unsupported shaped type");
72 if (
auto expr = dyn_cast<AffineDimExpr>(boundMap.
getResult(0)))
73 return static_cast<OpFoldResult>(operands[expr.getPosition()]);
74 if (
auto expr = dyn_cast<AffineSymbolExpr>(boundMap.
getResult(0)))
76 operands[expr.getPosition() + boundMap.
getNumDims()]);
79 b.
create<affine::AffineApplyOp>(loc, boundMap, operands).getResult());
86 auto reifyToOperands = [&](
Value v, std::optional<int64_t> d,
96 stopCondition ? stopCondition : reifyToOperands,
103 auto reifyToOperands = [&](
Value v, std::optional<int64_t> d,
108 stopCondition ? stopCondition : reifyToOperands,
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
int64_t getSingleConstantResult() const
Returns the constant result of this map.
bool isSingleConstant() const
Returns true if this affine map is a single result constant function.
unsigned getNumDims() const
AffineExpr getResult(unsigned idx) const
IntegerAttr getIndexAttr(int64_t value)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
This class represents a single result from folding an operation.
A variable that can be added to the constraint set as a "column".
A helper class to be used with ValueBoundsOpInterface.
static LogicalResult computeBound(AffineMap &resultMap, ValueDimList &mapOperands, presburger::BoundType type, const Variable &var, StopConditionFn stopCondition, bool closedUB=false)
Compute a bound for the given variable.
std::function< bool(Value, std::optional< int64_t >, ValueBoundsConstraintSet &cstr)> StopConditionFn
The stop condition when traversing the backward slice of a shaped value/ index-type value.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
FailureOr< OpFoldResult > reifyValueBound(OpBuilder &b, Location loc, presburger::BoundType type, const ValueBoundsConstraintSet::Variable &var, ValueBoundsConstraintSet::StopConditionFn stopCondition, bool closedUB=false)
Reify a bound for the given variable in terms of SSA values for which stopCondition is met.
FailureOr< OpFoldResult > reifyIndexValueBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
Reify a bound for the given index-typed value in terms of SSA values for which stopCondition is met.
void canonicalizeMapAndOperands(AffineMap *map, SmallVectorImpl< Value > *operands)
Modifies both map and operands in-place so as to:
OpFoldResult materializeComputedBound(OpBuilder &b, Location loc, AffineMap boundMap, ArrayRef< std::pair< Value, std::optional< int64_t >>> mapOperands)
Materialize an already computed bound with Affine dialect ops.
FailureOr< OpFoldResult > reifyShapedValueDimBound(OpBuilder &b, Location loc, presburger::BoundType type, Value value, int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition=nullptr, bool closedUB=false)
Reify a bound for the specified dimension of the given shaped value in terms of SSA values for which ...
BoundType
The type of bound: equal, lower bound or upper bound.
Include the generated interface declarations.
SmallVector< std::pair< Value, std::optional< int64_t > >> ValueDimList