[mlir] Move isGuaranteedCollapsible to CollapseShapeOp (NFC).
authorAdrian Kuegel <akuegel@google.com>
Fri, 22 Apr 2022 07:44:28 +0000 (09:44 +0200)
committerAdrian Kuegel <akuegel@google.com>
Fri, 22 Apr 2022 08:31:25 +0000 (10:31 +0200)
It seems more natural than to have it as a static method of ExpandShapeOp.
Also fix a typo ("the the" -> "the").

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

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp

index 5f7ec96..c9209ce 100644 (file)
@@ -1256,7 +1256,7 @@ def MemRef_ExpandShapeOp : MemRef_ReassociativeReshapeOp<"expand_shape"> {
     the behavior is undefined.
 
     The source memref can be zero-ranked. In that case, the reassociation
-    indices must be empty and the the result shape may only consist of unit
+    indices must be empty and the result shape may only consist of unit
     dimensions.
 
     For simplicity, this op may not be used to cast dynamicity of dimension
@@ -1294,15 +1294,7 @@ def MemRef_ExpandShapeOp : MemRef_ReassociativeReshapeOp<"expand_shape"> {
     OpBuilder<(ins "ArrayRef<int64_t>":$resultShape, "Value":$src,
                "ArrayRef<ReassociationIndices>":$reassociation)>
   ];
-
-  let extraClassDeclaration = commonExtraClassDeclaration # [{
-    /// Return `true` if this source MemRef type is guaranteed to be collapsible
-    /// according to the given reassociation indices. In the presence of dynamic
-    /// strides this is usually not the case.
-    static bool isGuaranteedCollapsible(
-        MemRefType srcType, ArrayRef<ReassociationIndices> reassociation);
-  }];
-
+  let extraClassDeclaration = commonExtraClassDeclaration;
   let hasVerifier = 1;
 }
 
@@ -1382,7 +1374,14 @@ def MemRef_CollapseShapeOp : MemRef_ReassociativeReshapeOp<"collapse_shape"> {
       build($_builder, $_state, resultType, src, reassociationMaps, attrs);
     }]>
   ];
-  let extraClassDeclaration = commonExtraClassDeclaration;
+  let extraClassDeclaration = commonExtraClassDeclaration # [{
+    /// Return `true` if this source MemRef type is guaranteed to be collapsible
+    /// according to the given reassociation indices. In the presence of dynamic
+    /// strides this is usually not the case.
+    static bool isGuaranteedCollapsible(
+        MemRefType srcType, ArrayRef<ReassociationIndices> reassociation);
+  }];
+
   let hasVerifier = 1;
 }
 
index 9a2ebc5..5d16e3f 100644 (file)
@@ -1866,7 +1866,7 @@ computeCollapsedLayoutMap(MemRefType srcType,
                                     srcType.getContext());
 }
 
-bool ExpandShapeOp::isGuaranteedCollapsible(
+bool CollapseShapeOp::isGuaranteedCollapsible(
     MemRefType srcType, ArrayRef<ReassociationIndices> reassociation) {
   // MemRefs with standard layout are always collapsible.
   if (srcType.getLayout().isIdentity())
index 94df8c5..ca2f989 100644 (file)
@@ -144,7 +144,7 @@ struct CollapseShapeOpInterface
     // If the dims are not collapsible (due to an incompatible source layout
     // map), force an out-of-place bufferization, i.e., a buffer copy. This
     // newly allocated buffer will have no layout map and thus be collapsible.
-    bool canBeCollapsed = memref::ExpandShapeOp::isGuaranteedCollapsible(
+    bool canBeCollapsed = memref::CollapseShapeOp::isGuaranteedCollapsible(
         bufferType, collapseShapeOp.getReassociationIndices());
     Optional<BufferizationState::ForceInPlacability> overrideInPlace =
         canBeCollapsed