Skip to content

Commit

Permalink
Address feedback comment on using familar MLIR syntax for eBNF grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
sdasgup3 committed Mar 27, 2023
1 parent 37e8ed7 commit 2bbd784
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,21 @@ IntegerType ::= 'si4' | 'si8' | 'si16' | 'si32' | 'si64'
| 'ui4' | 'ui8' | 'ui16' | 'ui32' | 'ui64'
FloatType ::= 'f8E4M3FN' | 'f8E5M2' | 'bf16' | 'f16' | 'f32' | 'f64'
ComplexType ::= 'complex' '<' ('f32' | 'f64') '>'
QuantizedType ::= '!quant.uniform' '<' QuantizationStorageType
QuantizedType ::= '!quant.uniform' '<' QuantizationStorageTypeSpec
':' QuantizationExpressedType
':' QuantizationStorageMin
':' QuantizationStorageMax
':' QuantizationScales
':' QuantizationZeroPoints
{':' QuantizationDimension} '>'
[':' QuantizationDimension]
',' QuantizationScalesAndZeroPoints '>'
QuantizationStorageTypeSpec ::= QuantizationStorageType ['<' QuantizationStorageMin ':' QuantizationStorageMax '>']
QuantizationStorageType ::= IntegerType
QuantizationExpressedType ::= FloatType
QuantizationStorageMin ::= IntegerConstant
QuantizationStorageMax ::= IntegerConstant
QuantizationScales ::= '[' FloatConstant {',' FloatConstant} ']'
QuantizationZeroPoints ::= '[' IntegerConstant {',' IntegerConstant} ']'
QuantizationExpressedType ::= FloatType
QuantizationDimension ::= IntegerConstant
QuantizationScalesAndZeroPoints ::= (QuantizationScaleAndZero | '{' QuantizationScaleAndZero {',' QuantizationScaleAndZero} '}')
QuantizationScaleAndZero ::= QuantizationScale ':' QuantizationZeroPoint
QuantizationScale ::= FloatConstant
QuantizationZeroPoint ::= IntegerConstant
```

**Element types** represent elements of tensor types. Unlike in many programming
Expand Down Expand Up @@ -215,21 +216,21 @@ Quantized types satisfy the following constraints:
* `storage_min = -2^(d-1)+1`, `storage_max = 2^(d-1)-1`.
* If `is_unsigned(storage_type)`:
* `storage_min = 0`, `storage_max = 2^d - 1`.
* (C5) For all `i`, `type(scales[i]) = expressed_type`.
* (C6) For all `i`, `scales[i] > 0`.
* (C7) For all `i`, `type(zero_points[i]) = i64`.
* (C8) `size(scales) = size(zero_points)`.
* (C9) If `quantization_dimension` is empty, then `size(scales) = 1`.
* (C10) If `quantization_dimension` is not empty, then
* (C5) `type(scale) = expressed_type`.
* (C6) `scale > 0`.
* (C7) `type(zero_point) = i64`.
* (C8) If `quantization_dimension` is empty, then
`size(scales_and_zero_points) = 1`.
* (C9) If `quantization_dimension` is not empty, then
`0 <= quantization_dimension`.

Furthermore, tensors of quantized types satisfy the following constraints:

* For per-tensor quantization:
* No additional constraints.
* For per-axis quantization:
* (C11) `quantization_dimension < size(shape)`.
* (C12) `size(scales) = shape[quantization_dimension]`.
* (C10) `quantization_dimension < size(shape)`.
* (C11) `size(scales_and_zero_points) = shape[quantization_dimension]`.

```ebnf
FunctionType ::= '(' [ValueType {',' ValueType}] ')' '->' '(' [ValueType {',' ValueType}] ')'
Expand Down

0 comments on commit 2bbd784

Please sign in to comment.