[llvm] [mlir] [clang-tools-extra] [mlir][benchmark] Fix broken benchmark script (PR #68841)
https://github.com/sott0n updated https://github.com/llvm/llvm-project/pull/68841 >From 372847091b7d6a73a78eb9de2685cbca4d62c285 Mon Sep 17 00:00:00 2001 From: Kohei Yamaguchi Date: Thu, 12 Oct 2023 10:16:06 + Subject: [PATCH] [mlir][benchmark] Fix broken benchmark script --- mlir/benchmark/python/common.py | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mlir/benchmark/python/common.py b/mlir/benchmark/python/common.py index c605726df2a5f64..076bacdb4c23c21 100644 --- a/mlir/benchmark/python/common.py +++ b/mlir/benchmark/python/common.py @@ -13,10 +13,9 @@ def setup_passes(mlir_module): """Setup pass pipeline parameters for benchmark functions.""" opt = ( "parallelization-strategy=none" -" vectorization-strategy=none vl=1 enable-simd-index32=False" ) -pipeline = f"sparse-compiler{{{opt}}}" -PassManager.parse(pipeline).run(mlir_module) +pipeline = f"builtin.module(sparse-compiler{{{opt}}})" +PassManager.parse(pipeline).run(mlir_module.operation) def create_sparse_np_tensor(dimensions, number_of_elements): @@ -73,7 +72,7 @@ def emit_benchmark_wrapped_main_func(kernel_func, timer_func): create a "time measuring" variant of a function. """ i64_type = ir.IntegerType.get_signless(64) -memref_of_i64_type = ir.MemRefType.get([-1], i64_type) +memref_of_i64_type = ir.MemRefType.get([ir.ShapedType.get_dynamic_size()], i64_type) wrapped_func = func.FuncOp( # Same signature and an extra buffer of indices to save timings. "main", @@ -86,7 +85,7 @@ def emit_benchmark_wrapped_main_func(kernel_func, timer_func): with ir.InsertionPoint(wrapped_func.add_entry_block()): timer_buffer = wrapped_func.arguments[-1] zero = arith.ConstantOp.create_index(0) -n_iterations = memref.DimOp(ir.IndexType.get(), timer_buffer, zero) +n_iterations = memref.DimOp(timer_buffer, zero) one = arith.ConstantOp.create_index(1) iter_args = list(wrapped_func.arguments[-num_results - 1 : -1]) loop = scf.ForOp(zero, n_iterations, one, iter_args) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [clang-tools-extra] [llvm] [clang] [mlir][spirv] Support alias/restrict function argument decorations (PR #76353)
sott0n wrote: @kuhar @antiagainst Thanks for your comment and support to land this PR! If you have any issues or TODO tasks in SPIR-V dialect, I would be happy if you could share it with me. https://github.com/llvm/llvm-project/pull/76353 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] [compiler-rt] [mlir] [mlir][bufferization] Fix SimplifyClones with dealloc before cloneOp (PR #79098)
https://github.com/sott0n updated https://github.com/llvm/llvm-project/pull/79098 >From cceb921d9bc7e3a4c1efe7050d6bfe6cb2eb49e7 Mon Sep 17 00:00:00 2001 From: Kohei Yamaguchi Date: Tue, 23 Jan 2024 14:30:02 + Subject: [PATCH 1/2] [mlir][bufferization] Fix SimplifyClones with dealloc before cloneOp The SimplifyClones pass relies on the assumption that the deallocOp follows the cloneOp. However, a crash occurs when there is a redundantDealloc preceding the cloneOp. This PR addresses the issue by ensuring the presence of deallocOp after cloneOp. The verification is performed by checking if the loop of the sub sequent node of cloneOp reaches the tail of the list. Fix #74306 --- .../Dialect/Bufferization/IR/BufferizationOps.cpp| 5 + mlir/test/Dialect/Bufferization/canonicalize.mlir| 12 2 files changed, 17 insertions(+) diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp index 253fcf2525121b8..9275a1e4aacee92 100644 --- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp @@ -505,6 +505,11 @@ struct SimplifyClones : public OpRewritePattern { // of the source. for (Operation *pos = cloneOp->getNextNode(); pos != redundantDealloc; pos = pos->getNextNode()) { + // If the next node is nullptr, it indicates there is no redundantDealloc + // after cloneOp, means that there is a redundantDealloc preseding + // cloneOp. + if (!pos) +return failure(); auto effectInterface = dyn_cast(pos); if (!effectInterface) continue; diff --git a/mlir/test/Dialect/Bufferization/canonicalize.mlir b/mlir/test/Dialect/Bufferization/canonicalize.mlir index 3edae7827f25f71..b6c0a0e25efe0ea 100644 --- a/mlir/test/Dialect/Bufferization/canonicalize.mlir +++ b/mlir/test/Dialect/Bufferization/canonicalize.mlir @@ -235,6 +235,18 @@ func.func @clone_and_realloc(%arg0: memref) { // - +// Verify SimplifyClones skips clones with preceding deallocation. +// CHECK-LABEL: @clone_and_preceding_dealloc +func.func @clone_and_preceding_dealloc(%arg0: memref) -> memref<32xf32> { + memref.dealloc %arg0 : memref + %0 = bufferization.clone %arg0 : memref to memref<32xf32> + return %0 : memref<32xf32> +} +// CHECK-SAME: %[[ARG:.*]]: memref +// CHECK-NOT: %cast = memref.cast %[[ARG]] + +// - + // CHECK-LABEL: func @tensor_cast_to_memref // CHECK-SAME: %[[ARG0:.+]]: tensor<4x6x16x32xi8> func.func @tensor_cast_to_memref(%arg0 : tensor<4x6x16x32xi8>) -> >From 0ecc46a516fc67c84b6d3ba86cbee46592ed2a3f Mon Sep 17 00:00:00 2001 From: Kohei Yamaguchi Date: Tue, 23 Jan 2024 17:27:02 + Subject: [PATCH 2/2] addressed a comment --- mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp index 9275a1e4aacee92..eb4a96f35499048 100644 --- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp @@ -505,9 +505,7 @@ struct SimplifyClones : public OpRewritePattern { // of the source. for (Operation *pos = cloneOp->getNextNode(); pos != redundantDealloc; pos = pos->getNextNode()) { - // If the next node is nullptr, it indicates there is no redundantDealloc - // after cloneOp, means that there is a redundantDealloc preseding - // cloneOp. + // Bail if we run out of operations while looking for a deallocation op. if (!pos) return failure(); auto effectInterface = dyn_cast(pos); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [mlir] [clang] [clang-tools-extra] [compiler-rt] [mlir][bufferization] Fix SimplifyClones with dealloc before cloneOp (PR #79098)
sott0n wrote: @matthias-springer Could you land it? I don't have commit access. https://github.com/llvm/llvm-project/pull/79098 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits