forked from OSchip/llvm-project
[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:
parent
9f815cb578
commit
7c234ae549
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue