@@ -37,65 +37,6 @@ namespace bufferization {
37
37
using namespace mlir ;
38
38
using namespace mlir ::bufferization;
39
39
40
- // ===----------------------------------------------------------------------===//
41
- // BufferizeTypeConverter
42
- // ===----------------------------------------------------------------------===//
43
-
44
- static Value materializeToTensor (OpBuilder &builder, TensorType type,
45
- ValueRange inputs, Location loc) {
46
- assert (inputs.size () == 1 );
47
- assert (isa<BaseMemRefType>(inputs[0 ].getType ()));
48
- return builder.create <bufferization::ToTensorOp>(loc, type, inputs[0 ]);
49
- }
50
-
51
- // / Registers conversions into BufferizeTypeConverter
52
- BufferizeTypeConverter::BufferizeTypeConverter () {
53
- // Keep all types unchanged.
54
- addConversion ([](Type type) { return type; });
55
- // Convert RankedTensorType to MemRefType.
56
- addConversion ([](RankedTensorType type) -> Type {
57
- return MemRefType::get (type.getShape (), type.getElementType ());
58
- });
59
- // Convert UnrankedTensorType to UnrankedMemRefType.
60
- addConversion ([](UnrankedTensorType type) -> Type {
61
- return UnrankedMemRefType::get (type.getElementType (), 0 );
62
- });
63
- addArgumentMaterialization (materializeToTensor);
64
- addSourceMaterialization (materializeToTensor);
65
- addTargetMaterialization ([](OpBuilder &builder, BaseMemRefType type,
66
- ValueRange inputs, Location loc) -> Value {
67
- assert (inputs.size () == 1 && " expected exactly one input" );
68
-
69
- if (auto inputType = dyn_cast<MemRefType>(inputs[0 ].getType ())) {
70
- // MemRef to MemRef cast.
71
- assert (inputType != type && " expected different types" );
72
- // Ranked to unranked casts must be explicit.
73
- auto rankedDestType = dyn_cast<MemRefType>(type);
74
- if (!rankedDestType)
75
- return nullptr ;
76
- BufferizationOptions options;
77
- options.bufferAlignment = 0 ;
78
- FailureOr<Value> replacement =
79
- castOrReallocMemRefValue (builder, inputs[0 ], rankedDestType, options);
80
- if (failed (replacement))
81
- return nullptr ;
82
- return *replacement;
83
- }
84
-
85
- if (isa<TensorType>(inputs[0 ].getType ())) {
86
- // Tensor to MemRef cast.
87
- return builder.create <bufferization::ToMemrefOp>(loc, type, inputs[0 ]);
88
- }
89
-
90
- llvm_unreachable (" only tensor/memref input types supported" );
91
- });
92
- }
93
-
94
- void mlir::bufferization::populateBufferizeMaterializationLegality (
95
- ConversionTarget &target) {
96
- target.addLegalOp <bufferization::ToTensorOp, bufferization::ToMemrefOp>();
97
- }
98
-
99
40
namespace {
100
41
101
42
static LayoutMapOption parseLayoutMapOption (const std::string &s) {
@@ -564,17 +505,3 @@ bufferization::bufferizeBlockSignature(Block *block, RewriterBase &rewriter,
564
505
565
506
return success ();
566
507
}
567
-
568
- BufferizationOptions bufferization::getPartialBufferizationOptions () {
569
- BufferizationOptions options;
570
- options.allowUnknownOps = true ;
571
- options.copyBeforeWrite = true ;
572
- options.enforceAliasingInvariants = false ;
573
- options.unknownTypeConverterFn = [](Value value, Attribute memorySpace,
574
- const BufferizationOptions &options) {
575
- return getMemRefTypeWithStaticIdentityLayout (
576
- cast<TensorType>(value.getType ()), memorySpace);
577
- };
578
- options.opFilter .allowDialect <BufferizationDialect>();
579
- return options;
580
- }
0 commit comments