This tutorial gives an introduction to the `mlir-opt` tool, focusing on how to run basic passes with and without options, run pass pipelines from the CLI, and point out particularly useful flags. --------- Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com> Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
28 lines
865 B
MLIR
28 lines
865 B
MLIR
// This file is left in-tree despite having no assertions so it can be
|
|
// referenced by the tutorial text.
|
|
|
|
// RUN: mlir-opt %s
|
|
|
|
module {
|
|
func.func @producer_consumer_fusion(%arg0: memref<10xf32>, %arg1: memref<10xf32>) {
|
|
%0 = memref.alloc() : memref<10xf32>
|
|
%1 = memref.alloc() : memref<10xf32>
|
|
%cst = arith.constant 0.000000e+00 : f32
|
|
affine.for %arg2 = 0 to 10 {
|
|
affine.store %cst, %0[%arg2] : memref<10xf32>
|
|
affine.store %cst, %1[%arg2] : memref<10xf32>
|
|
}
|
|
affine.for %arg2 = 0 to 10 {
|
|
%2 = affine.load %0[%arg2] : memref<10xf32>
|
|
%3 = arith.addf %2, %2 : f32
|
|
affine.store %3, %arg0[%arg2] : memref<10xf32>
|
|
}
|
|
affine.for %arg2 = 0 to 10 {
|
|
%2 = affine.load %1[%arg2] : memref<10xf32>
|
|
%3 = arith.mulf %2, %2 : f32
|
|
affine.store %3, %arg1[%arg2] : memref<10xf32>
|
|
}
|
|
return
|
|
}
|
|
}
|