doc: sample: add examples of new extensible syntax
This commit is contained in:
14
doc/sample/for-loop-1.mie
Normal file
14
doc/sample/for-loop-1.mie
Normal file
@@ -0,0 +1,14 @@
|
||||
func.func @reduce(%buffer: memref<1024*f32>, %lb: index, %ub: index, %step: index) -> f32 {
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = arith.constant 0.0 : f32
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
%sum = scf.for %iv = %lb to %ub step %step iter-args(%sum.iter = %sum.0) -> (f32) {
|
||||
%t = memref.load %buffer[%iv] : memref<1024*f32>
|
||||
%sum.next = arith.addf %sum.iter, %t : f32
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
scf.yield %sum.next : f32
|
||||
}
|
||||
|
||||
func.return %sum : f32
|
||||
}
|
||||
Reference in New Issue
Block a user