Skip to content

Instantly share code, notes, and snippets.

View matthias-springer's full-sized avatar

Matthias Springer matthias-springer

View GitHub Profile
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
module attributes {transform.target_tag="payload"} {
// Batched TOSA matrix multiplication. %A and %B are the inputs, %C is the
// output.
func.func @test_matmul(%A: memref<1x17x19xf32>, %B: memref<1x19x29xf32>,
%C: memref<1x17x29xf32>) {
%A_tensor = bufferization.to_tensor %A restrict : memref<1x17x19xf32>
%B_tensor = bufferization.to_tensor %B restrict : memref<1x19x29xf32>
// 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>
// Result should be stored in %out.
bufferization.materialize_in_destination %0 in restrict writable %out
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
module attributes {transform.target_tag="payload"} {
// TOSA element-wise addition. %A and %B are the inputs, %C is the output.
func.func @test_matmul(%A_tensor: tensor<100xf32>, %B_tensor: tensor<100xf32>,
%C_tensor: tensor<100xf32>) -> tensor<100xf32> {
%0 = tosa.add %A_tensor, %B_tensor
: (tensor<100xf32>, tensor<100xf32>) -> tensor<100xf32>
%r = bufferization.materialize_in_destination %0 in %C_tensor
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload" -transform-dialect-drop-schedule
module attributes {transform.target_tag="payload"} {
// Batched TOSA matrix multiplication. %A and %B are the inputs, %C is the
// output.
func.func @test_matmul(%A: memref<1x17x19xf32>, %B: memref<1x19x29xf32>,
%C: memref<1x17x29xf32>) {
%A_tensor = bufferization.to_tensor %A restrict : memref<1x17x19xf32>
%B_tensor = bufferization.to_tensor %B restrict : memref<1x19x29xf32>
@matthias-springer
matthias-springer / presentation_urls.txt
Last active November 21, 2023 10:25
MLIR Bufferization: From Tensors to MemRefs
Debugging Spurious Copies: Mini Example
https://gist.github.com/matthias-springer/81748fe1e530974dd5ff6b3ad57e3eeb
Debugging Spurious Copies: Matmul, Tiled
https://gist.github.com/matthias-springer/372162baa30e79c49180bb3ace216995
https://gist.github.com/matthias-springer/b664feb23be0159f72726025923bb9ca
Empty Tensor Elimination
https://gist.github.com/matthias-springer/b3f40d1667c977c29a76cc7a469cc1a0
https://gist.github.com/matthias-springer/e531580242d27f14e0a239e0b6fe80ae
// 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
// 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, %idx: index, %idx2: index)
-> (f32, tensor<3xf32>) {
// Create a new tensor with [%f0, %f0, %f0].
%0 = tensor.from_elements %f0, %f0, %f0 : tensor<3xf32>
// Insert something into the new tensor.
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
#map = affine_map<(d0) -> (d0)>
module attributes {transform.target_tag="payload"} {
// TOSA element-wise addition. %A and %B are the inputs, %C is the output.
func.func @test_matmul(%arg0: memref<100xf32>, %arg1: memref<100xf32>, %arg2: memref<100xf32>) {
%0 = bufferization.to_tensor %arg0 restrict : memref<100xf32>
%1 = bufferization.to_tensor %arg1 restrict : memref<100xf32>
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload"
module attributes {transform.target_tag="payload"} {
// TOSA element-wise addition. %A and %B are the inputs, %C is the output.
func.func @test_matmul(%A: memref<100xf32>, %B: memref<100xf32>,
%C: memref<100xf32>) {
%A_tensor = bufferization.to_tensor %A restrict : memref<100xf32>
%B_tensor = bufferization.to_tensor %B restrict : memref<100xf32>
%0 = tosa.add %A_tensor, %B_tensor
// RUN: mlir-opt %s -test-transform-dialect-interpreter="debug-payload-root-tag=payload" -test-transform-dialect-erase-schedule
#map = affine_map<(d0) -> (-d0 + 17, 5)>
#map1 = affine_map<(d0) -> (-d0 + 29, 7)>
module attributes {transform.target_tag="payload"} {
// Tiled batched matrix multiplication. %A and %B are the inputs, %C is the
// output.
func.func @test_matmul(%A: memref<1x17x19xf32>, %B: memref<1x19x29xf32>,