22template <
typename OpTy>
23struct MaterializationOpInterface
24 :
public ValueBoundsOpInterface::ExternalModel<
25 MaterializationOpInterface<OpTy>, OpTy> {
26 void populateBoundsForShapedValueDim(Operation *op, Value value, int64_t dim,
27 ValueBoundsConstraintSet &cstr)
const {
29 OpTy::template hasTrait<OpTrait::SameOperandsAndResultShape>(),
30 "expected the result and the source to have the same shape");
31 auto materializationOp = cast<OpTy>(op);
32 assert(value == materializationOp.getResult() &&
"invalid value");
36 Value source = materializationOp.getOperand();
37 if (isa<ShapedType>(value.
getType()) && isa<ShapedType>(source.
getType()))
49 bufferization::BufferizationDialect *dialect) {
50 bufferization::ToBufferOp::attachInterface<
51 bufferization::MaterializationOpInterface<bufferization::ToBufferOp>>(
53 bufferization::ToTensorOp::attachInterface<
54 bufferization::MaterializationOpInterface<bufferization::ToTensorOp>>(
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.
Type getType() const
Return the type of this value.
void registerValueBoundsOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.