Skip to content

Commit

Permalink
Address review comments: remove constraint for re-quant and add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sdasgup3 committed Jun 4, 2023
1 parent 76d3e45 commit 14eef28
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -5612,9 +5612,13 @@ Formally, `result = (operand - zero_point(operand)) * scale(operand)`.
#### Examples

```mlir
// %operand: 20
// %operand: 10
%result = "stablehlo.uniform_dequantize"(%operand) : (tensor<!quant.uniform<i8<-128:127>:f32, 0.5:-20>>) -> tensor<f32>
// %result: 20.0
// %result: 15.0
// %operand: [10, 10]
%result = "stablehlo.uniform_dequantize"(%operand) : (tensor<3x!quant.uniform<i8<-128:127>:f32:0, {0.1:-30, 0.5:-20}>>) -> tensor<3xf32>
// %result: [4.0, 15.0]
```

### uniform_quantize
Expand Down Expand Up @@ -5644,25 +5648,28 @@ Formally,

#### Outputs

| Name | Type | Constraints |
|----------|--------------------------|------------------|
| Name | Type | Constraints |
|----------|------------------|------------------|
| `result` | quantized tensor | (C1), (C2), (C3) |

#### Constraints

* (C1) If `element_type(operand)` is a floating-point type,
* `element_type(operand) = expressed_type(result)`.
* (C2) If `element_type(operand)` is a quantized type,
* `num_bits(storage_type(operand)) >= num_bits(storage_type(result))`.
* `expressed_type(operand) = expressed_type(result)`.
* (C3) `shape(operand) = shape(result)`.

#### Examples

```mlir
// %operand: 20.0
// %operand: 15.0
%result = "stablehlo.uniform_quantize"(%operand) : (tensor<f32>) -> tensor<!quant.uniform<i8<-128:127>:f32, 0.5:-20>>
// %result: 20
// %result: 10
// %operand: [4.0, 15.0]
%result = "stablehlo.uniform_quantize"(%operand) : (tensor<3xf32>) -> tensor<3x!quant.uniform<i8<-128:127>:f32:0, {0.1:-30, 0.5:-20}>>
// %result: [10, 10]
```

### while
Expand Down

0 comments on commit 14eef28

Please sign in to comment.