[mlir][linalg] Update result position calculation in the Structured Op Interface...
authorTobias Gysi <gysit@google.com>
Wed, 2 Jun 2021 12:29:50 +0000 (12:29 +0000)
committerTobias Gysi <gysit@google.com>
Wed, 2 Jun 2021 12:31:02 +0000 (12:31 +0000)
Remove two unused methods and replace the implementation of getResultsPositionInLoopsToShapeMap. The patch is based on https://reviews.llvm.org/D103394.

Differential Revision: https://reviews.llvm.org/D103397

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

index 16510c9..69426cf 100644 (file)
@@ -789,55 +789,22 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
     >,
     InterfaceMethod<
       /*desc=*/[{
-        Return the position in the results of the affine map computed
-        by getLoopsToShapesMap() that represents the shape of an
-        operand (input or output) at a dimension.
-      }],
-      /*retTy=*/"Optional<unsigned>",
-      /*methodName=*/"getOperandDimPositionInLoopsToShapeMap",
-      /*args=*/(ins "unsigned":$operandIdx, "unsigned":$dim),
-      /*methodBody=*/"",
-      /*defaultImplementation=*/[{
-        unsigned pos = 0;
-        for (OpOperand *opOperand : getInputAndOutputOperands()) {
-          if (opOperand->getOperandNumber() == operandIdx) return pos + dim;
-          pos += getRank(opOperand);
-        }
-        return {};
-      }]
-    >,
-    InterfaceMethod<
-      /*desc=*/[{
-        Return the position in the results of the affine map computed
-        by getLoopsToShapesMap() that represents the shape of an
-        input operand at a dimension.
-      }],
-      /*retTy=*/"Optional<unsigned>",
-      /*methodName=*/"getInputValueDimPositionInLoopsToShapeMap",
-      /*args=*/(ins "unsigned":$inputIdx, "unsigned":$dim),
-      /*methodBody=*/"",
-      /*defaultImplementation=*/[{
-        if (inputIdx >= getNumInputs()) return {};
-        return getOperandDimPositionInLoopsToShapeMap(inputIdx, dim);
-      }]
-    >,
-    InterfaceMethod<
-      /*desc=*/[{
         Return the range of position in the result of the affine map
         computed by getLoopsToShapesMap() which correspond to the
         AffineExprs used to access the outputs of the operation.
       }],
-      /*retTy=*/"std::pair<unsigned, unsigned>",
+      /*retTy=*/"std::pair<int64_t, int64_t>",
       /*methodName=*/"getResultsPositionInLoopsToShapeMap",
       /*args=*/(ins),
       /*methodBody=*/"",
       /*defaultImplementation=*/[{
-        OpOperand *opOperand = getOutputOperand(getNumOutputs()-1);
-        return
-          {*getOperandDimPositionInLoopsToShapeMap(getNumInputs(), 0),
-           (*getOperandDimPositionInLoopsToShapeMap
-                 (getNumInputs() + getNumOutputs() - 1,
-                  getRank(opOperand) - 1)) + 1};
+        int64_t inputRankSum = 0;
+        int64_t outputRankSum = 0;
+        for(OpOperand *input : getInputOperands())
+          inputRankSum += getRank(input);
+        for(OpOperand *output : getOutputOperands())
+          outputRankSum += getRank(output);
+        return {inputRankSum, inputRankSum + outputRankSum};
       }]
     >,
     InterfaceMethod<