[mlir][linalg] Cleanup LinalgOp usage in bufferize, detensorize, and interchange.

Replace the uses of deprecated Structured Op Interface methods in Bufferize.cpp, Detensorize.cpp, and Interchange.cpp. The patch is based on https://reviews.llvm.org/D103394.

Differential Revision: https://reviews.llvm.org/D103530
This commit is contained in:
Tobias Gysi 2021-06-03 11:32:11 +00:00
parent 9f815cb578
commit 7c234ae549
3 changed files with 9 additions and 8 deletions

View File

@ -54,7 +54,8 @@ allocateBuffersForResults(Location loc, LinalgOp linalgOp, ValueRange outputs,
Value resultTensor = outputs[resultIndex];
// Clone output buffers whose value is actually used.
if (linalgOp.payloadUsesValueFromOutputOperandIndex(resultIndex)) {
OpOperand *tiedOpOperand = linalgOp.getOutputOperand(resultIndex);
if (linalgOp.payloadUsesValueFromOperand(tiedOpOperand)) {
resultBuffers.push_back(cloneMemref(loc, resultTensor, b));
continue;
}

View File

@ -48,10 +48,11 @@ bool canBeDetensored(TensorType tensorType) {
bool shouldBeDetensored(Operation *op, TypeConverter typeConverter) {
GenericOp genericOp = dyn_cast_or_null<GenericOp>(op);
return genericOp && llvm::all_of(genericOp.getShapedOperandTypes(),
[&](ShapedType shapedType) {
return !typeConverter.isLegal(shapedType);
});
return genericOp &&
llvm::all_of(
genericOp.getInputAndOutputOperands(), [&](OpOperand *opOperand) {
return !typeConverter.isLegal(opOperand->get().getType());
});
}
/// A conversion patttern for detensoring `linalg.generic` ops.

View File

@ -56,9 +56,8 @@ void mlir::linalg::interchangeGenericOp(PatternRewriter &rewriter,
// 2. Compute the interchanged indexing maps.
SmallVector<Attribute, 4> newIndexingMaps;
ArrayRef<Attribute> indexingMaps = genericOp.indexing_maps().getValue();
for (unsigned i = 0, e = genericOp.getNumShapedOperands(); i != e; ++i) {
AffineMap m = indexingMaps[i].cast<AffineMapAttr>().getValue();
for (OpOperand *opOperand : genericOp.getInputAndOutputOperands()) {
AffineMap m = genericOp.getTiedIndexingMap(opOperand);
if (!permutationMap.isEmpty())
m = m.compose(permutationMap);
newIndexingMaps.push_back(AffineMapAttr::get(m));