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 May 23, 2023
1 parent bc84398 commit f8fcb10
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -5598,6 +5598,10 @@ Formally, `result = (operand - zero_point(operand)) * scale(operand)`.
// %operand: 20
%result = "stablehlo.uniform_dequantize"(%operand) : (tensor<!quant.uniform<i8<-128:127>:f32, 0.5:-20>>) -> tensor<f32>
// %result: 20.0
// %operand: [10, 20]
%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, 20.0]
```

### uniform_quantize
Expand Down Expand Up @@ -5627,16 +5631,15 @@ 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)`.

Expand All @@ -5646,6 +5649,10 @@ Formally,
// %operand: 20.0
%result = "stablehlo.uniform_quantize"(%operand) : (tensor<f32>) -> tensor<!quant.uniform<i8<-128:127>:f32, 0.5:-20>>
// %result: 20
// %operand: [4.0, 20.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, 20]
```

### while
Expand Down

0 comments on commit f8fcb10

Please sign in to comment.