[Mlir-commits] [mlir] 6fc753a - [mlir][bufferize] Always bufferize top-to-bottom

Matthias Springer llvmlistbot at llvm.org
Thu Mar 3 05:16:15 PST 2022


Author: Matthias Springer
Date: 2022-03-03T22:12:20+09:00
New Revision: 6fc753adaf86d18de1f660abe8e72c0cd870a371

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

LOG: [mlir][bufferize] Always bufferize top-to-bottom

This ensures that we generate memref types with matching layout maps. (Especially when using partial bufferization passes.)

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

Added: 
    

Modified: 
    mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index 24ecadb5e8f4d..f4fed424391fa 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -302,6 +302,17 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
   // Bufferize the op and its nested ops.
   RewritePatternSet patterns(op->getContext());
   populateBufferizationPattern(state, patterns);
+
+  // Bufferize ops top-to-bottom. When creating a new op, we should ideally
+  // know the exact memref type of all operands. Otherwise, we have to use a
+  // memref type with a fully dynamic layout map, which has to canonicalize
+  // away.
+  // Moreover, if "fullyDynamicLayoutMaps = false", we may otherwise have to
+  // insert buffer copies to fold ("finalize") to_memref(to_tensor(x)) ops with
+  // non-cast-compatible layout maps.
+  GreedyRewriteConfig config;
+  config.useTopDownTraversal = true;
+
   if (failed(applyPatternsAndFoldGreedily(op, std::move(patterns))))
     return failure();
 


        


More information about the Mlir-commits mailing list