Skip to content

Commit 8fc3e5c

Browse files
committed
[mlir] Format AffineOps.td. NFC
Drop trailing spaces and reflow text to fit 80 columns.
1 parent 02f03a6 commit 8fc3e5c

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

mlir/include/mlir/Dialect/LoopOps/LoopOps.td

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,45 +61,52 @@ def ForOp : Loop_Op<"for",
6161
}
6262
```
6363

64-
"loop.for" can also operate on loop-carried variables and returns the final values
65-
after loop termination. The initial values of the variables are passed as additional SSA
66-
operands to the "loop.for" following the 3 loop control SSA values mentioned above
67-
(lower bound, upper bound and step). The operation region has equivalent arguments
68-
for each variable representing the value of the variable at the current iteration.
69-
70-
The region must terminate with a "loop.yield" that passes all the current iteration
71-
variables to the next iteration, or to the "loop.for" result, if at the last iteration.
72-
"loop.for" results hold the final values after the last iteration.
64+
"loop.for" can also operate on loop-carried variables and returns the final
65+
values after loop termination. The initial values of the variables are
66+
passed as additional SSA operands to the "loop.for" following the 3 loop
67+
control SSA values mentioned above (lower bound, upper bound and step). The
68+
operation region has equivalent arguments for each variable representing
69+
the value of the variable at the current iteration.
70+
71+
The region must terminate with a "loop.yield" that passes all the current
72+
iteration variables to the next iteration, or to the "loop.for" result, if
73+
at the last iteration. "loop.for" results hold the final values after the
74+
last iteration.
7375

7476
For example, to sum-reduce a memref:
7577

7678
```mlir
77-
func @reduce(%buffer: memref<1024xf32>, %lb: index, %ub: index, %step: index) -> (f32) {
79+
func @reduce(%buffer: memref<1024xf32>, %lb: index,
80+
%ub: index, %step: index) -> (f32) {
7881
// Initial sum set to 0.
7982
%sum_0 = constant 0.0 : f32
8083
// iter_args binds initial values to the loop's region arguments.
81-
%sum = loop.for %iv = %lb to %ub step %step iter_args(%sum_iter = %sum_0) -> (f32) {
84+
%sum = loop.for %iv = %lb to %ub step %step
85+
iter_args(%sum_iter = %sum_0) -> (f32) {
8286
%t = load %buffer[%iv] : memref<1024xf32>
8387
%sum_next = addf %sum_iter, %t : f32
84-
// Yield current iteration sum to next iteration %sum_iter or to %sum if final iteration.
88+
// Yield current iteration sum to next iteration %sum_iter or to %sum
89+
// if final iteration.
8590
loop.yield %sum_next : f32
8691
}
8792
return %sum : f32
8893
}
8994
```
9095

9196
If the "loop.for" defines any values, a yield must be explicitly present.
92-
The number and types of the "loop.for" results must match the initial values
93-
in the "iter_args" binding and the yield operands.
97+
The number and types of the "loop.for" results must match the initial
98+
values in the "iter_args" binding and the yield operands.
9499

95100
Another example with a nested "loop.if" (see "loop.if" for details)
96101
to perform conditional reduction:
97102

98103
```mlir
99-
func @conditional_reduce(%buffer: memref<1024xf32>, %lb: index, %ub: index, %step: index) -> (f32) {
104+
func @conditional_reduce(%buffer: memref<1024xf32>, %lb: index,
105+
%ub: index, %step: index) -> (f32) {
100106
%sum_0 = constant 0.0 : f32
101107
%c0 = constant 0.0 : f32
102-
%sum = loop.for %iv = %lb to %ub step %step iter_args(%sum_iter = %sum_0) -> (f32) {
108+
%sum = loop.for %iv = %lb to %ub step %step
109+
iter_args(%sum_iter = %sum_0) -> (f32) {
103110
%t = load %buffer[%iv] : memref<1024xf32>
104111
%cond = cmpf "ugt", %t, %c0 : f32
105112
%sum_next = loop.if %cond -> (f32) {
@@ -177,8 +184,8 @@ def IfOp : Loop_Op<"if",
177184
}
178185
```
179186

180-
"loop.if" may also return results that are defined in its regions. The values
181-
defined are determined by which execution path is taken.
187+
"loop.if" may also return results that are defined in its regions. The
188+
values defined are determined by which execution path is taken.
182189
For example:
183190
```mlir
184191
%x, %y = loop.if %b -> (f32, f32) {
@@ -260,7 +267,8 @@ def ParallelOp : Loop_Op<"parallel",
260267

261268
The body region must contain exactly one block that terminates with
262269
"loop.yield" without operands. Parsing ParallelOp will create such a region
263-
and insert the terminator when it is absent from the custom format. For example:
270+
and insert the terminator when it is absent from the custom format.
271+
For example:
264272

265273
```mlir
266274
loop.parallel (%iv) = (%lb) to (%ub) step (%step) {
@@ -354,8 +362,8 @@ def ReduceReturnOp :
354362
let summary = "terminator for reduce operation";
355363
let description = [{
356364
"loop.reduce.return" is a special terminator operation for the block inside
357-
"loop.reduce". It terminates the region. It should have the same type as the
358-
operand of "loop.reduce". Example for the custom format:
365+
"loop.reduce". It terminates the region. It should have the same type as
366+
the operand of "loop.reduce". Example for the custom format:
359367

360368
```mlir
361369
loop.reduce.return %res : f32
@@ -382,7 +390,8 @@ def YieldOp : Loop_Op<"yield", [Terminator]> {
382390

383391
let arguments = (ins Variadic<AnyType>:$results);
384392
let builders = [
385-
OpBuilder<"Builder *builder, OperationState &result", [{ /* nothing to do */ }]>
393+
OpBuilder<"Builder *builder, OperationState &result",
394+
[{ /* nothing to do */ }]>
386395
];
387396
}
388397
#endif // LOOP_OPS

0 commit comments

Comments
 (0)