Skip to content

Commit 84d4bb7

Browse files
committed
[mlir][Linalg] Inline an interface method to its only user.
It seems only the default implementation is ever used, so it doesn't seem necessary to include this method in the interface. Differential Revision: https://reviews.llvm.org/D130986
1 parent b19de81 commit 84d4bb7

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -983,26 +983,6 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
983983
return detail::canOpOperandsBeDroppedImpl($_op, droppedOperands);
984984
}]
985985
>,
986-
InterfaceMethod<
987-
/*desc=*/[{
988-
Return the range of position in the result of the affine map
989-
computed by getLoopsToShapesMap() which correspond to the
990-
AffineExprs used to access the outputs of the operation.
991-
}],
992-
/*retTy=*/"std::pair<int64_t, int64_t>",
993-
/*methodName=*/"getResultsPositionInLoopsToShapeMap",
994-
/*args=*/(ins),
995-
/*methodBody=*/"",
996-
/*defaultImplementation=*/[{
997-
int64_t inputRankSum = 0;
998-
int64_t outputRankSum = 0;
999-
for(OpOperand *input : getInputOperands())
1000-
inputRankSum += getRank(input);
1001-
for(OpOperand *output : getOutputOperands())
1002-
outputRankSum += getRank(output);
1003-
return {inputRankSum, inputRankSum + outputRankSum};
1004-
}]
1005-
>,
1006986
InterfaceMethod<
1007987
/*desc=*/[{
1008988
Like `getShape`, but only returns statically-known information, without

mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,17 @@ struct HasAffineDimExprVisitor
566566
llvm::SmallBitVector positions;
567567
};
568568

569+
static std::pair<int64_t, int64_t>
570+
getResultsPositionInLoopsToShapeMap(LinalgOp &op) {
571+
int64_t inputRankSum = 0;
572+
int64_t outputRankSum = 0;
573+
for (OpOperand *input : op.getInputOperands())
574+
inputRankSum += op.getRank(input);
575+
for (OpOperand *output : op.getOutputOperands())
576+
outputRankSum += op.getRank(output);
577+
return {inputRankSum, inputRankSum + outputRankSum};
578+
}
579+
569580
LogicalResult
570581
LinalgOp::reifyResultShapes(OpBuilder &b,
571582
ReifiedRankedShapedTypeDims &reifiedReturnShapes) {
@@ -582,7 +593,7 @@ LinalgOp::reifyResultShapes(OpBuilder &b,
582593

583594
// Find the position in the above map that represents the shape of the
584595
// result:dim being inferred.
585-
auto resultShapesSubMapPos = getResultsPositionInLoopsToShapeMap();
596+
auto resultShapesSubMapPos = getResultsPositionInLoopsToShapeMap(*this);
586597

587598
/// From loopsToShapesMap extract the submap that represents the shape of the
588599
/// (resultIdx, dim) needed.

0 commit comments

Comments
 (0)