Skip to content

Instantly share code, notes, and snippets.

View maerhart's full-sized avatar

Martin Erhart maerhart

  • @sifive | ETH Zurich
  • Cambridge, UK
View GitHub Profile
@maerhart
maerhart / buffer_deallocation_pipeline_simplify_deallocation_operations.mlir
Last active October 7, 2023 21:10
buffer_deallocation_pipeline_simplify_deallocation_operations.mlir
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
#map = affine_map<(d0) -> (-d0 + 17, 5)>
#map1 = affine_map<(d0) -> (-d0 + 29, 7)>
module {
module attributes {transform.target_tag = "payload"} {
func.func @test_matmul(%arg0: memref<1x17x19xf32>, %arg1: memref<1x19x29xf32>, %arg2: memref<1x17x29xf32>) {
%c7 = arith.constant 7 : index
%c29 = arith.constant 29 : index
%c5 = arith.constant 5 : index
@maerhart
maerhart / buffer_deallocation_pipeline_lower_deallocations.mlir
Last active October 7, 2023 21:10
buffer_deallocation_pipeline_lower_deallocations.mlir
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
#map = affine_map<(d0) -> (-d0 + 17, 5)>
#map1 = affine_map<(d0) -> (-d0 + 29, 7)>
module {
module attributes {transform.target_tag = "payload"} {
func.func @test_matmul(%arg0: memref<1x17x19xf32>, %arg1: memref<1x19x29xf32>, %arg2: memref<1x17x29xf32>) {
%c7 = arith.constant 7 : index
%c29 = arith.constant 29 : index
%c5 = arith.constant 5 : index
@maerhart
maerhart / buffer_deallocation_pipeline_ownership_based_deallocation.mlir
Last active October 7, 2023 00:30
buffer_deallocation_pipeline_ownership_based_deallocation.mlir
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
#map = affine_map<(d0) -> (-d0 + 17, 5)>
#map1 = affine_map<(d0) -> (-d0 + 29, 7)>
module {
module attributes {transform.target_tag = "payload"} {
func.func @test_matmul(%arg0: memref<1x17x19xf32>, %arg1: memref<1x19x29xf32>, %arg2: memref<1x17x29xf32>) {
%c7 = arith.constant 7 : index
%c29 = arith.constant 29 : index
%c5 = arith.constant 5 : index
@maerhart
maerhart / input.mlir
Created September 11, 2023 11:47
An example IR which is supposed to be supported by the buffer deallocation pass (and is part of the regression test suite), but has a memory leak in the output IR. The new buffer deallocation pass handles the input IR correctly.
// The following input IR is handled incorrectly in the old buffer deallocation pass
// (leads to a memory leak).
func.func @criticalEdge(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
cf.cond_br %arg0, ^bb1, ^bb2(%arg1 : memref<2xf32>)
^bb1:
%0 = memref.alloc() : memref<2xf32>
test.buffer_based in(%arg1: memref<2xf32>) out(%0: memref<2xf32>)
cf.br ^bb2(%0 : memref<2xf32>)
^bb2(%1: memref<2xf32>):
test.copy(%1, %arg2) : (memref<2xf32>, memref<2xf32>)