[Mlir-commits] [mlir] e1a1508 - [mlir][linalg] Update result position calculation in the Structured Op Interface (NFC).

Tobias Gysi llvmlistbot at llvm.org
Wed Jun 2 05:54:58 PDT 2021


Author: Tobias Gysi
Date: 2021-06-02T12:31:02Z
New Revision: e1a150846d373f547e6b81c737333da27c4d29d7

URL: https://github.com/llvm/llvm-project/commit/e1a150846d373f547e6b81c737333da27c4d29d7
DIFF: https://github.com/llvm/llvm-project/commit/e1a150846d373f547e6b81c737333da27c4d29d7.diff

LOG: [mlir][linalg] Update result position calculation in the Structured Op Interface (NFC).

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index 16510c906e25..69426cf1fded 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -787,57 +787,24 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
         return inversePermutation(getLoopsToShapesMap());
       }]
     >,
-    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<


        


More information about the Mlir-commits mailing list