Skip to content

Commit 651d88e

Browse files
authored
[mlir][vector] Update reduction kind docs. NFC. (#70673)
Update the documentation surrounding reduction kinds. Highlight different min/max reduction kinds for signed/unsigned integers and floats. Update IR examples.
1 parent 093bc6b commit 651d88e

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.td

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ def Vector_ContractionOp :
8686

8787
An optional kind attribute may be used to specify the combining function
8888
between the intermediate result and accumulator argument of rank K. This
89-
attribute can take the values add/mul/min/max for int/fp, and/or/xor for
90-
int only. The default is "add".
89+
attribute can take the values `add`/`mul`/`minsi`/`minui`/`maxsi`/`maxui`
90+
/`and`/`or`/`xor` for integers, and `add`/`mul`/`minf`/`maxf`/`minimumf`
91+
/`maximumf` for floats. The default is `add`.
9192

9293
Example:
9394

@@ -149,7 +150,7 @@ def Vector_ContractionOp :
149150
#contraction_trait = {
150151
indexing_maps = #contraction_accesses,
151152
iterator_types = ["reduction"],
152-
kind = #vector.kind<max>
153+
kind = #vector.kind<maxf>
153154
}
154155
%6 = vector.contract #contraction_trait %0, %1, %2
155156
: vector<10xf32>, vector<10xf32> into f32
@@ -232,7 +233,8 @@ def Vector_ReductionOp :
232233
let summary = "reduction operation";
233234
let description = [{
234235
Reduces an 1-D vector "horizontally" into a scalar using the given
235-
operation (add/mul/min/max for int/fp and and/or/xor for int only).
236+
operation: `add`/`mul`/`minsi`/`minui`/`maxsi`/`maxui`/`and`/`or`/`xor` for
237+
integers, and `add`/`mul`/`minf`/`maxf`/`minimumf`/`maximumf` for floats.
236238
Reductions also allow an optional fused accumulator.
237239

238240
Note that these operations are restricted to 1-D vectors to remain
@@ -289,8 +291,9 @@ def Vector_MultiDimReductionOp :
289291
let summary = "Multi-dimensional reduction operation";
290292
let description = [{
291293
Reduces an n-D vector into an (n-k)-D vector (or a scalar when k == n)
292-
using the given operation (add/mul/min/max for int/fp and and/or/xor for
293-
int only).
294+
using the given operation: `add`/`mul`/`minsi`/`minui`/`maxsi`/`maxui`
295+
/`and`/`or`/`xor` for integers, and `add`/`mul`/`minf`/`maxf`/`minimumf`
296+
/`maximumf` for floats.
294297
Takes an initial accumulator operand.
295298

296299
Example:
@@ -937,11 +940,12 @@ def Vector_OuterProductOp :
937940
lowered to the LLVMIR dialect, this form emits `llvm.intr.fma`, which
938941
is guaranteed to lower to actual `fma` instructions on x86.
939942

940-
An optional kind attribute may be specified to be add/mul/min/max
941-
for int/fp, and and/or/xor for int only. The default is "add", in which
942-
case the operation returns a fused multiply-add. In other cases it returns
943-
a multiply followed by the appropriate operation (for example, a compare and
944-
select for "max").
943+
An optional kind attribute may be specified to be: `add`/`mul`/`minsi`
944+
/`minui`/`maxsi`/`maxui`/`and`/`or`/`xor` for integers, and `add`/`mul`
945+
/`minf`/`maxf`/`minimumf`/`maximumf` for floats.
946+
The default is `add`, in which case the operation returns a fused
947+
multiply-add. In other cases it returns a multiply followed by the
948+
appropriate operation (for example, a compare and select for `maxf`).
945949

946950
Example:
947951

@@ -953,7 +957,7 @@ def Vector_OuterProductOp :
953957
vector<4xf32>, vector<8xf32>, vector<4x8xf32>
954958
return %3: vector<4x8xf32>
955959

956-
%4 = vector.outerproduct %0, %1, %2 {kind = #vector.kind<max>}:
960+
%4 = vector.outerproduct %0, %1, %2 {kind = #vector.kind<maxf>}:
957961
vector<4xf32>, vector<8xf32>, vector<4x8xf32>
958962
return %3: vector<4x8xf32>
959963

@@ -2764,10 +2768,10 @@ def Vector_ScanOp :
27642768
let description = [{
27652769
Performs an inclusive/exclusive scan on an n-D vector along a single
27662770
dimension returning an n-D result vector using the given
2767-
operation (add/mul/min/max for int/fp and and/or/xor for
2768-
int only) and a specified value for the initial value. The operator
2769-
returns the result of scan as well as the result of the last
2770-
reduction in the scan.
2771+
operation (`add`/`mul`/`minsi`/`minui`/`maxsi`/`maxui`/`and`/`or`/`xor` for
2772+
integers, and `add`/`mul`/`minf`/`maxf`/`minimumf`/`maximumf` for floats),
2773+
and a specified value for the initial value. The operator returns the
2774+
result of scan as well as the result of the last reduction in the scan.
27712775

27722776
Example:
27732777

0 commit comments

Comments
 (0)