Created
October 4, 2023 14:26
-
-
Save matthias-springer/61fa7e65ea56490104eec684eddf6dcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload" | |
module attributes {transform.target_tag="payload"} { | |
func.func @test(%f0: f32, %f1: f32, %out: memref<3xf32>) { | |
// Create a new tensor with [%f0, %f0, %f0]. | |
%0 = tensor.from_elements %f0, %f0, %f0 : tensor<3xf32> | |
bufferization.materialize_in_destination %0 in restrict writable %out | |
: (tensor<3xf32>, memref<3xf32>) -> () | |
func.return | |
} | |
} | |
transform.sequence failures(propagate) { | |
^bb0(%module1: !transform.any_op): | |
// Rewrite tensor.from_elements in destination-passing style | |
%from_elements = transform.structured.match ops{["tensor.from_elements"]} | |
in %module1 : (!transform.any_op) -> !transform.any_op | |
transform.structured.rewrite_in_destination_passing_style %from_elements | |
: (!transform.any_op) -> !transform.any_op | |
// Eliminate empty tensors | |
transform.bufferization.eliminate_empty_tensors %module1 : !transform.any_op | |
// Bufferize | |
%module2 = transform.bufferization.one_shot_bufferize %module1 | |
: (!transform.any_op) -> !transform.any_op | |
// Canonicalize + CSE | |
transform.apply_patterns to %module2 { | |
transform.apply_patterns.canonicalization | |
} {apply_cse} : !transform.any_op | |
// Deallocate buffers | |
%module3 = transform.apply_registered_pass | |
"buffer-deallocation-pipeline" to %module2 | |
: (!transform.any_op) -> !transform.any_op | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment