Skip to content

Commit 20d1888

Browse files
authored
[mlir][tosa] Update the description of rescale and variable ops (#134815)
Updates the description to align with the specification. Also includes some small cleanup to `sigmoid`, to avoid confusion. Signed-off-by: Luke Hutton <[email protected]>
1 parent 8877b91 commit 20d1888

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

mlir/include/mlir/Dialect/Tosa/IR/TosaOps.td

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,7 @@ def Tosa_SigmoidOp : Tosa_ElementwiseUnaryOp<"sigmoid"> {
545545
For quantized integer data types, the TABLE operator should be used instead.
546546
Each implementation may choose an appropriate TABLE given the scale and zero
547547
point of the input data. Eight or sixteen bit precision tables may be used
548-
based on the input tensor to the sigmoid function. The sigmoid table has 513
549-
entries each of 16-bit precision and covering the input range -16.0 to +16.0
550-
in steps of 1/16.
548+
based on the input tensor to the sigmoid function.
551549
}];
552550

553551
let arguments = (ins
@@ -757,10 +755,10 @@ def Tosa_IntDivOp : Tosa_ElementwiseOp<"int_div", [SameOperandsAndResultElementT
757755
let summary = "Integer divide operator.";
758756

759757
let description = [{
760-
Elementwise integer divide of input1 by input2. Axis of size 1 will be
761-
broadcast as necessary. Rank of input tensors must match. The result of the
762-
divide is truncated towards zero. Expected use is for operations on
763-
non-scaled integers. Floating point divide should use RECIPROCAL and MUL.
758+
Elementwise integer divide of input1 by input2. Axis of size 1 will be
759+
broadcast as necessary. Rank of input tensors must match. The result of the
760+
divide is truncated towards zero. Expected use is for operations on
761+
non-scaled integers. Floating point divide should use RECIPROCAL and MUL.
764762
Quantized integer divide should use TABLE (for 1/x) and MUL.
765763
}];
766764

@@ -2328,7 +2326,21 @@ def Tosa_RescaleOp : Tosa_InferShapedTypeOp<"rescale"> {
23282326
let summary = "Tosa rescale operator.";
23292327

23302328
let description = [{
2331-
Rescale quantized values into a new domain. Supported rescalings are:
2329+
RESCALE is defined using an integer multiply, add, and shift.
2330+
2331+
Rescale supports two precisions of multiplier: 16-bit and 32-bit. The 32-bit multiplier
2332+
version supports two rounding modes to enable simpler lowering of existing frameworks
2333+
that use two stage rounding. All arithmetic is designed so that it does not overflow a
2334+
64-bit accumulator and that the result fits in 32 bits. In particular, a 48-bit value
2335+
cannot be scaled with the 32-bit multiplier because the accumulator would need to have
2336+
80 bits.
2337+
2338+
The shift and value range are limited to allow a variety of implementations. The limit
2339+
of 62 on shift allows the shift to be decomposed as two right shifts of 31.
2340+
2341+
Supported rescalings:
2342+
* This table is showing the supported conversions from the TOSA Specification.
2343+
* The MLIR dialect here can be used to represent other conversions.
23322344

23332345
| Mode | Input | Output | Unsigned input | Unsigned output |
23342346
|------------------------|-------|--------|----------------|-----------------|

mlir/include/mlir/Dialect/Tosa/IR/TosaUtilOps.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def Tosa_VariableOp : Tosa_Op<"variable", []> {
8686
let summary = "Defines a variable";
8787

8888
let description = [{
89-
Defines a new TOSA variable. This is a mutable value.
90-
Modifications are expressed using read/write semantics.
89+
Defines a new TOSA variable. This is a persistent mutable value across multiple
90+
TOSA graph invocations. Modifications are expressed using read/write semantics.
9191
}];
9292

9393
let arguments = (ins
@@ -115,7 +115,7 @@ def Tosa_VariableWriteOp : Tosa_Op<"variable.write", []> {
115115
let summary = "write_buffer operator";
116116

117117
let description = [{
118-
Assigns a value to pseudo-buffer resource holding a mutable tensor.
118+
Assigns a value to the pseudo-buffer resource holding a persistent mutable tensor.
119119
}];
120120

121121
let arguments = (ins
@@ -140,7 +140,7 @@ def Tosa_VariableReadOp : Tosa_Op<"variable.read", []> {
140140
let summary = "read_buffer operator";
141141

142142
let description = [{
143-
Reads the value from a pseudo-buffer resource holding a mutable tensor.
143+
Reads the value from a pseudo-buffer resource holding a persistent mutable tensor.
144144
}];
145145

146146
let arguments = (ins

0 commit comments

Comments
 (0)