20struct IndexOpInterface
21 :
public ValueBoundsOpInterface::ExternalModel<IndexOpInterface, IndexOp> {
22 void populateBoundsForIndexValue(Operation *op, Value value,
23 ValueBoundsConstraintSet &cstr)
const {
24 auto indexOp = cast<IndexOp>(op);
25 auto linalgOp = indexOp->getParentOfType<LinalgOp>();
26 assert(value == indexOp.getResult() &&
"invalid value");
29 cstr.
bound(value) >= 0;
34 linalgOp.getShapesToLoopsMap().getResult(indexOp.getDim()))
37 int64_t flatDimCtr = 0;
38 for (OpOperand &operand : linalgOp->getOpOperands()) {
39 assert(flatDimPos >= flatDimCtr &&
"invalid pos");
41 int64_t rank = linalgOp.getRank(&operand);
42 if (flatDimPos < flatDimCtr + rank) {
44 cstr.
getExpr(operand.get(), flatDimPos - flatDimCtr);
59 IndexOp::attachInterface<IndexOpInterface>(*ctx);
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
AffineExpr getExpr(Value value, std::optional< int64_t > dim=std::nullopt)
Return an expression that represents the given index-typed value or shaped value dimension.
BoundBuilder bound(Value value)
Add a bound for the given index-typed value or shaped value.
void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.