@@ -116,95 +116,6 @@ struct MaterializePadEncodingTypeConverter final
116116 }
117117};
118118
119- // / Pattern to convert `iree_tensor_ext.dispatch.tensor.load` operation when
120- // / materializing the encoding.
121- struct MaterializeFlowDispatchTensorLoadOp final
122- : OpConversionPattern<IREE::TensorExt::DispatchTensorLoadOp> {
123- using Base::Base;
124-
125- LogicalResult
126- matchAndRewrite (IREE::TensorExt::DispatchTensorLoadOp loadOp,
127- OpAdaptor adaptor,
128- ConversionPatternRewriter &rewriter) const override {
129- // Only handle operations where the load covers the entire
130- // `!iree_tensor_ext.dispatch.tensor` type.
131- if (!loadOp.isLoadOfWholeSource ()) {
132- return rewriter.notifyMatchFailure (loadOp, " unhandled partial loads" );
133- }
134-
135- auto &typeConverter =
136- *getTypeConverter<MaterializePadEncodingTypeConverter>();
137- IREE::TensorExt::DispatchTensorType sourceType = loadOp.getSourceType ();
138- auto boundTensorType = cast<RankedTensorType>(sourceType.getBoundType ());
139- if (!typeConverter.hasNonZeroPadding (boundTensorType)) {
140- // Let the Nop pattern handle this.
141- return rewriter.notifyMatchFailure (loadOp, " no padding applied" );
142- }
143-
144- auto paddedType =
145- typeConverter.convertType <RankedTensorType>(boundTensorType);
146- assert (paddedType != boundTensorType && " Expected conversion with padding" );
147-
148- SmallVector<OpFoldResult> newMixedSizes =
149- getMixedValues (paddedType.getShape (), loadOp.getSourceDims (), rewriter);
150-
151- SmallVector<OpFoldResult> newOffsets (newMixedSizes.size (),
152- rewriter.getIndexAttr (0 ));
153- SmallVector<OpFoldResult> newStrides (newMixedSizes.size (),
154- rewriter.getIndexAttr (1 ));
155- SmallVector<OpFoldResult> extractSizes = getMixedValues (
156- boundTensorType.getShape (), loadOp.getSourceDims (), rewriter);
157- rewriter.replaceOpWithNewOp <IREE::TensorExt::DispatchTensorLoadOp>(
158- loadOp, adaptor.getSource (), loadOp.getSourceDims (), newOffsets,
159- extractSizes, newStrides);
160- return success ();
161- }
162- };
163-
164- // / Pattern to convert `iree_tensor_ext.dispatch.tensor.store` operation when
165- // / materializing the encoding.
166- struct MaterializeFlowDispatchTensorStoreOp final
167- : OpConversionPattern<IREE::TensorExt::DispatchTensorStoreOp> {
168- using Base::Base;
169-
170- LogicalResult
171- matchAndRewrite (IREE::TensorExt::DispatchTensorStoreOp storeOp,
172- OpAdaptor adaptor,
173- ConversionPatternRewriter &rewriter) const override {
174- // Only handle operations where the store covers the entire
175- // `!iree_tensor_ext.dispatch.tensor` type.
176- if (!storeOp.isStoreToWholeTarget ()) {
177- return rewriter.notifyMatchFailure (storeOp, " unhandled partial stores" );
178- }
179-
180- auto &typeConverter =
181- *getTypeConverter<MaterializePadEncodingTypeConverter>();
182- IREE::TensorExt::DispatchTensorType targetType = storeOp.getTargetType ();
183- auto boundTensorType = cast<RankedTensorType>(targetType.getBoundType ());
184- if (!typeConverter.hasNonZeroPadding (boundTensorType)) {
185- // Let the Nop pattern handle this.
186- return rewriter.notifyMatchFailure (storeOp, " no padding applied" );
187- }
188-
189- IREE::TensorExt::DispatchTensorType newTargetType =
190- typeConverter.convertType <IREE::TensorExt::DispatchTensorType>(
191- targetType);
192- RankedTensorType paddedType = newTargetType.asRankedTensorType ();
193-
194- Location loc = storeOp.getLoc ();
195- SmallVector<OpFoldResult> offsets (paddedType.getRank (),
196- rewriter.getIndexAttr (0 ));
197- SmallVector<OpFoldResult> strides (paddedType.getRank (),
198- rewriter.getIndexAttr (1 ));
199- SmallVector<OpFoldResult> sizes =
200- tensor::getMixedSizes (rewriter, loc, adaptor.getValue ());
201- rewriter.replaceOpWithNewOp <IREE::TensorExt::DispatchTensorStoreOp>(
202- storeOp, adaptor.getValue (), adaptor.getTarget (),
203- adaptor.getTargetDims (), offsets, sizes, strides);
204- return success ();
205- }
206- };
207-
208119// / Pattern to convert `iree_tensor_ext.dispatch.tensor.store` operation when
209120// / materializing the encoding. We can not reuse the existing one because it
210121// / does not transform new dynamic dimension through interface. The other
@@ -293,9 +204,7 @@ struct MaterializeEncodingIntoPaddingPass final
293204 // with the exception of a few ops that have to account for padding.
294205 // We add custom patterns with much higher priority to run before the
295206 // equivalent 'Nop' patterns.
296- materializeEncodingPattern.add <MaterializeFlowDispatchTensorLoadOp,
297- MaterializeFlowDispatchTensorStoreOp,
298- MaterializeInterfaceBindingEncoding>(
207+ materializeEncodingPattern.add <MaterializeInterfaceBindingEncoding>(
299208 typeConverter, context, PatternBenefit{100 });
300209
301210 if (failed (applyPartialConversion (operation, target,
0 commit comments