forked from OSchip/llvm-project
Mark mlir code snippets as being written in mlir
Forgot to add these in previous change :/ PiperOrigin-RevId: 221444322
This commit is contained in:
parent
b1f7e03add
commit
fb4b74ccb3
|
@ -209,7 +209,7 @@ test the dependence analysis infra in the code generator, Andy Davis wrote a
|
||||||
simple pass that checks dependencies and emits them as "notes", allowing him to
|
simple pass that checks dependencies and emits them as "notes", allowing him to
|
||||||
write tests like this:
|
write tests like this:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// RUN: mlir-opt %s -memref-dependence-check -verify
|
// RUN: mlir-opt %s -memref-dependence-check -verify
|
||||||
mlfunc @different_memrefs() {
|
mlfunc @different_memrefs() {
|
||||||
%m.a = alloc() : memref<100xf32>
|
%m.a = alloc() : memref<100xf32>
|
||||||
|
@ -243,7 +243,7 @@ with ShapeRefiner.
|
||||||
The [MLIR Tensor Type](g3doc/LangRef.md#tensor-type) directly captures shape
|
The [MLIR Tensor Type](g3doc/LangRef.md#tensor-type) directly captures shape
|
||||||
information, so you can have things like:
|
information, so you can have things like:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
%x = tf.Add %x, %y : tensor<128 x 8 x ? x f32>
|
%x = tf.Add %x, %y : tensor<128 x 8 x ? x f32>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ unknown dimension can be queried using the "dim" builtin as shown below.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
mlfunc foo(...) {
|
mlfunc foo(...) {
|
||||||
%A = alloc <8x?xf32, #lmap> (%N)
|
%A = alloc <8x?xf32, #lmap> (%N)
|
||||||
...
|
...
|
||||||
|
@ -334,7 +334,7 @@ functions and CFG functions work together.
|
||||||
|
|
||||||
### Non-affine control flow {#non-affine-control-flow}
|
### Non-affine control flow {#non-affine-control-flow}
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// A simple linear search in every row of a matrix
|
// A simple linear search in every row of a matrix
|
||||||
for (i=0; i<N; i++) {
|
for (i=0; i<N; i++) {
|
||||||
for (j=0; j<N; j++) {
|
for (j=0; j<N; j++) {
|
||||||
|
@ -351,7 +351,7 @@ The presence of dynamic control flow leads to a CFG function nested in an ML
|
||||||
function: an ML function captures the outer loop while the inner loop is
|
function: an ML function captures the outer loop while the inner loop is
|
||||||
represented in the CFG function.
|
represented in the CFG function.
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
mlfunc @search(memref<?x?xi32 %A, <?xi32> %S, i32 %key) {
|
mlfunc @search(memref<?x?xi32 %A, <?xi32> %S, i32 %key) {
|
||||||
%ni = dim %A, 0 : memref<?x?xi32>
|
%ni = dim %A, 0 : memref<?x?xi32>
|
||||||
// This loop can be parallelized
|
// This loop can be parallelized
|
||||||
|
@ -410,7 +410,7 @@ for (i=0; i <N; i++)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
mlfunc @outer_nest(%n) : (i32) {
|
mlfunc @outer_nest(%n) : (i32) {
|
||||||
for %i = 0 to %n {
|
for %i = 0 to %n {
|
||||||
for %j = 0 to %n {
|
for %j = 0 to %n {
|
||||||
|
@ -442,7 +442,7 @@ The following example illustrates a reference implementation of a 2D
|
||||||
convolution, which uses an integer set `@@domain` to represent valid input data
|
convolution, which uses an integer set `@@domain` to represent valid input data
|
||||||
in a dilated convolution.
|
in a dilated convolution.
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// Dilation factors S0 and S1 can be constant folded if constant at compile time.
|
// Dilation factors S0 and S1 can be constant folded if constant at compile time.
|
||||||
@@domain = (d0, d1)[S0,S1,S2,S3]: (d0 % S0 == 0, d1 % S1 == 0, d0 >= 0, d1 >= 0,
|
@@domain = (d0, d1)[S0,S1,S2,S3]: (d0 % S0 == 0, d1 % S1 == 0, d0 >= 0, d1 >= 0,
|
||||||
S3 - d0 - 1 >= 0, S4 - d1 - 1 >= 0)
|
S3 - d0 - 1 >= 0, S4 - d1 - 1 >= 0)
|
||||||
|
@ -556,7 +556,7 @@ which is called a schedule tree. Each non-leaf node of the tree is an abstract
|
||||||
polyhedral dimension corresponding to an abstract fused loop for each ML
|
polyhedral dimension corresponding to an abstract fused loop for each ML
|
||||||
instruction that appears in that branch. Each leaf node is an ML Instruction.
|
instruction that appears in that branch. Each leaf node is an ML Instruction.
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// A tiled matmul code (128x128x128) represented in schedule tree form
|
// A tiled matmul code (128x128x128) represented in schedule tree form
|
||||||
|
|
||||||
// #map0 = (d0, d1, d2, d3, d4, d5) -> (128*d0 + d3, 128*d1 + d4, 128*d2 + d5)
|
// #map0 = (d0, d1, d2, d3, d4, d5) -> (128*d0 + d3, 128*d1 + d4, 128*d2 + d5)
|
||||||
|
@ -641,7 +641,7 @@ dimensions.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// read relation: two elements ( d0 <= r0 <= d0+1 )
|
// read relation: two elements ( d0 <= r0 <= d0+1 )
|
||||||
##aff_rel9 = (d0) -> (r0) : r0 - d0 >= 0, d0 - r0 + 1 >= 0
|
##aff_rel9 = (d0) -> (r0) : r0 - d0 >= 0, d0 - r0 + 1 >= 0
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ TODO: figure out the right syntax.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
##rel9 ( ) [s0] -> (r0, r1) : 0 <= r0 <= 1023, 0 <= r1 <= s0 - 1
|
##rel9 ( ) [s0] -> (r0, r1) : 0 <= r0 <= 1023, 0 <= r1 <= s0 - 1
|
||||||
|
|
||||||
extfunc @cblas_reduce_ffi(memref<1024 x ? x f32, #layout_map0, hbm> %M) -> f32 [
|
extfunc @cblas_reduce_ffi(memref<1024 x ? x f32, #layout_map0, hbm> %M) -> f32 [
|
||||||
|
@ -744,7 +744,7 @@ a list of statements that may also include a yield statement.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// Return sum of elements in 1-dimensional mref A
|
// Return sum of elements in 1-dimensional mref A
|
||||||
mlfunc int32 @sum(%A : memref<?xi32>, %N : i32) -> (i32) {
|
mlfunc int32 @sum(%A : memref<?xi32>, %N : i32) -> (i32) {
|
||||||
%init = 0
|
%init = 0
|
||||||
|
@ -774,7 +774,7 @@ situation.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
``` {.mlir}
|
```mlir {.mlir}
|
||||||
// Compute sum of half of the array
|
// Compute sum of half of the array
|
||||||
mlfunc int32 @sum_half(%A, %N) {
|
mlfunc int32 @sum_half(%A, %N) {
|
||||||
%s0 = 0
|
%s0 = 0
|
||||||
|
|
Loading…
Reference in New Issue