20 struct IndexOpInterface
21 :
public ValueBoundsOpInterface::ExternalModel<IndexOpInterface, IndexOp> {
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 (
Value operand : linalgOp->getOperands()) {
39 assert(flatDimPos >= flatDimCtr &&
"invalid pos");
40 auto shapedType = llvm::cast<ShapedType>(operand.getType());
41 if (flatDimPos < flatDimCtr + shapedType.getRank()) {
42 cstr.
bound(value) < cstr.
getExpr(operand, flatDimPos - flatDimCtr);
45 flatDimCtr += shapedType.getRank();
57 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.
Operation is the basic unit of execution within MLIR.
A helper class to be used with ValueBoundsOpInterface.
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.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.