[Mlir-commits] [mlir] a74e5a8 - [mlir] Move isGuaranteedCollapsible to CollapseShapeOp (NFC).

Adrian Kuegel llvmlistbot at llvm.org
Fri Apr 22 01:31:41 PDT 2022


Author: Adrian Kuegel
Date: 2022-04-22T10:31:25+02:00
New Revision: a74e5a89b9e2176beede93f2ac5f8f806cd79844

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

LOG: [mlir] Move isGuaranteedCollapsible to CollapseShapeOp (NFC).

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
index 5f7ec96162f88..c9209cebce2a0 100644
--- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -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;
 }
 

diff  --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 9a2ebc586daf4..5d16e3f018d43 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -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())

diff  --git a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
index 94df8c54d941e..ca2f9891687ea 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -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


        


More information about the Mlir-commits mailing list