67
67
"""
68
68
`addi`
69
69
70
- Performs N-bit addition on the operands. The operands are interpreted as
71
- unsigned bitvectors. The result is represented by a bitvector containing the
72
- mathematical value of the addition modulo 2^n, where `n` is the bitwidth.
73
- Because `arith` integers use a two\' s complement representation, this operation
70
+ Performs N-bit addition on the operands. The operands are interpreted as
71
+ unsigned bitvectors. The result is represented by a bitvector containing the
72
+ mathematical value of the addition modulo 2^n, where `n` is the bitwidth.
73
+ Because `arith` integers use a two\' s complement representation, this operation
74
74
is applicable on both signed and unsigned integer operands.
75
75
76
76
The `addi` operation takes two operands and returns one result, each of
77
- these is required to be the same type. This type may be an integer scalar type,
77
+ these is required to be the same type. This type may be an integer scalar type,
78
78
a vector whose element type is integer, or a tensor of integers.
79
79
80
80
This op supports `nuw`/`nsw` overflow flags which stands for
253
253
254
254
Signed integer division. Rounds towards positive infinity, i.e. `7 / -2 = -3`.
255
255
256
- Divison by zero, or signed division overflow (minimum value divided by -1)
257
- is undefined behavior. When applied to `vector` and `tensor` values, the
258
- behavior is undefined if _any_ of its elements are divided by zero or has a
256
+ Divison by zero, or signed division overflow (minimum value divided by -1)
257
+ is undefined behavior. When applied to `vector` and `tensor` values, the
258
+ behavior is undefined if _any_ of its elements are divided by zero or has a
259
259
signed division overflow.
260
260
261
261
# Example
@@ -292,10 +292,10 @@ end
292
292
293
293
Unsigned integer division. Rounds towards positive infinity. Treats the
294
294
leading bit as the most significant, i.e. for `i16` given two\' s complement
295
- representation, `6 / -2 = 6 / (2^16 - 2) = 1`.
295
+ representation, `6 / -2 = 6 / (2^16 - 2) = 1`.
296
296
297
- Division by zero is undefined behavior. When applied to `vector` and
298
- `tensor` values, the behavior is undefined if _any_ elements are divided by
297
+ Division by zero is undefined behavior. When applied to `vector` and
298
+ `tensor` values, the behavior is undefined if _any_ elements are divided by
299
299
zero.
300
300
301
301
# Example
543
543
Signed integer division. Rounds towards zero. Treats the leading bit as
544
544
sign, i.e. `6 / -2 = -3`.
545
545
546
- Divison by zero, or signed division overflow (minimum value divided by -1)
547
- is undefined behavior. When applied to `vector` and `tensor` values, the
548
- behavior is undefined if _any_ of its elements are divided by zero or has a
546
+ Divison by zero, or signed division overflow (minimum value divided by -1)
547
+ is undefined behavior. When applied to `vector` and `tensor` values, the
548
+ behavior is undefined if _any_ of its elements are divided by zero or has a
549
549
signed division overflow.
550
550
551
551
# Example
@@ -590,8 +590,8 @@ Unsigned integer division. Rounds towards zero. Treats the leading bit as
590
590
the most significant, i.e. for `i16` given two\' s complement representation,
591
591
`6 / -2 = 6 / (2^16 - 2) = 0`.
592
592
593
- Division by zero is undefined behavior. When applied to `vector` and
594
- `tensor` values, the behavior is undefined if _any_ elements are divided by
593
+ Division by zero is undefined behavior. When applied to `vector` and
594
+ `tensor` values, the behavior is undefined if _any_ elements are divided by
595
595
zero.
596
596
597
597
# Example
790
790
791
791
Signed integer division. Rounds towards negative infinity, i.e. `5 / -2 = -3`.
792
792
793
- Divison by zero, or signed division overflow (minimum value divided by -1)
794
- is undefined behavior. When applied to `vector` and `tensor` values, the
795
- behavior is undefined if _any_ of its elements are divided by zero or has a
793
+ Divison by zero, or signed division overflow (minimum value divided by -1)
794
+ is undefined behavior. When applied to `vector` and `tensor` values, the
795
+ behavior is undefined if _any_ of its elements are divided by zero or has a
796
796
signed division overflow.
797
797
798
798
# Example
@@ -1467,8 +1467,8 @@ end
1467
1467
Signed integer division remainder. Treats the leading bit as sign, i.e. `6 %
1468
1468
-2 = 0`.
1469
1469
1470
- Division by zero is undefined behavior. When applied to `vector` and
1471
- `tensor` values, the behavior is undefined if _any_ elements are divided by
1470
+ Division by zero is undefined behavior. When applied to `vector` and
1471
+ `tensor` values, the behavior is undefined if _any_ elements are divided by
1472
1472
zero.
1473
1473
1474
1474
# Example
@@ -1512,8 +1512,8 @@ end
1512
1512
Unsigned integer division remainder. Treats the leading bit as the most
1513
1513
significant, i.e. for `i16`, `6 % -2 = 6 % (2^16 - 2) = 6`.
1514
1514
1515
- Division by zero is undefined behavior. When applied to `vector` and
1516
- `tensor` values, the behavior is undefined if _any_ elements are divided by
1515
+ Division by zero is undefined behavior. When applied to `vector` and
1516
+ `tensor` values, the behavior is undefined if _any_ elements are divided by
1517
1517
zero.
1518
1518
1519
1519
# Example
@@ -1581,36 +1581,36 @@ end
1581
1581
"""
1582
1582
`scaling_extf`
1583
1583
1584
- This operation upcasts input floating-point values using provided scale
1585
- values. It expects both scales and the input operand to be of the same shape,
1586
- making the operation elementwise. Scales are usually calculated per block
1584
+ This operation upcasts input floating-point values using provided scale
1585
+ values. It expects both scales and the input operand to be of the same shape,
1586
+ making the operation elementwise. Scales are usually calculated per block
1587
1587
following the OCP MXFP spec as described in https://arxiv.org/abs/2310.10537.
1588
1588
1589
- If scales are calculated per block where blockSize != 1, then scales may
1590
- require broadcasting to make this operation elementwise. For example, let\' s
1591
- say the input is of shape `<dim1 x dim2 x ... dimN>`. Given blockSize != 1 and
1592
- assuming quantization happens on the last axis, the input can be reshaped to
1593
- `<dim1 x dim2 x ... (dimN/blockSize) x blockSize>`. Scales will be calculated
1594
- per block on the last axis. Therefore, scales will be of shape
1595
- `<dim1 x dim2 x ... (dimN/blockSize) x 1>`. Scales could also be of some other
1596
- shape as long as it is broadcast compatible with the input, e.g.,
1589
+ If scales are calculated per block where blockSize != 1, then scales may
1590
+ require broadcasting to make this operation elementwise. For example, let\' s
1591
+ say the input is of shape `<dim1 x dim2 x ... dimN>`. Given blockSize != 1 and
1592
+ assuming quantization happens on the last axis, the input can be reshaped to
1593
+ `<dim1 x dim2 x ... (dimN/blockSize) x blockSize>`. Scales will be calculated
1594
+ per block on the last axis. Therefore, scales will be of shape
1595
+ `<dim1 x dim2 x ... (dimN/blockSize) x 1>`. Scales could also be of some other
1596
+ shape as long as it is broadcast compatible with the input, e.g.,
1597
1597
`<1 x 1 x ... (dimN/blockSize) x 1>`.
1598
1598
1599
- In this example, before calling into `arith.scaling_extf`, scales must be
1600
- broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
1601
- that there could be multiple quantization axes. Internally,
1599
+ In this example, before calling into `arith.scaling_extf`, scales must be
1600
+ broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
1601
+ that there could be multiple quantization axes. Internally,
1602
1602
`arith.scaling_extf` would perform the following:
1603
-
1603
+
1604
1604
```
1605
- resultTy = get_type(result)
1605
+ resultTy = get_type(result)
1606
1606
scaleTy = get_type(scale)
1607
1607
inputTy = get_type(input)
1608
1608
scale.exponent = arith.truncf(scale) : scaleTy to f8E8M0
1609
1609
scale.extf = arith.extf(scale.exponent) : f8E8M0 to resultTy
1610
1610
input.extf = arith.extf(input) : inputTy to resultTy
1611
1611
result = arith.mulf(scale.extf, input.extf)
1612
1612
```
1613
- It propagates NaN values. Therefore, if either scale or the input element
1613
+ It propagates NaN values. Therefore, if either scale or the input element
1614
1614
contains NaN, then the output element value will also be a NaN.
1615
1615
"""
1616
1616
function scaling_extf (
@@ -1638,28 +1638,28 @@ end
1638
1638
"""
1639
1639
`scaling_truncf`
1640
1640
1641
- This operation downcasts input using the provided scale values. It expects
1642
- both scales and the input operand to be of the same shape and, therefore,
1643
- makes the operation elementwise. Scales are usually calculated per block
1641
+ This operation downcasts input using the provided scale values. It expects
1642
+ both scales and the input operand to be of the same shape and, therefore,
1643
+ makes the operation elementwise. Scales are usually calculated per block
1644
1644
following the OCP MXFP spec as described in https://arxiv.org/abs/2310.10537.
1645
1645
Users are required to normalize and clamp the scales as necessary before calling
1646
1646
passing them to this operation. OCP MXFP spec also does the flushing of denorms
1647
- on the input operand, which should be handled during lowering by passing appropriate
1648
- fastMath flag to this operation.
1649
-
1650
- If scales are calculated per block where blockSize != 1, scales may require
1651
- broadcasting to make this operation elementwise. For example, let\' s say the
1652
- input is of shape `<dim1 x dim2 x ... dimN>`. Given blockSize != 1 and
1653
- assuming quantization happens on the last axis, the input can be reshaped to
1654
- `<dim1 x dim2 x ... (dimN/blockSize) x blockSize>`. Scales will be calculated
1655
- per block on the last axis. Therefore, scales will be of shape
1656
- `<dim1 x dim2 x ... (dimN/blockSize) x 1>`. Scales could also be of some other
1657
- shape as long as it is broadcast compatible with the input, e.g.,
1647
+ on the input operand, which should be handled during lowering by passing appropriate
1648
+ fastMath flag to this operation.
1649
+
1650
+ If scales are calculated per block where blockSize != 1, scales may require
1651
+ broadcasting to make this operation elementwise. For example, let\' s say the
1652
+ input is of shape `<dim1 x dim2 x ... dimN>`. Given blockSize != 1 and
1653
+ assuming quantization happens on the last axis, the input can be reshaped to
1654
+ `<dim1 x dim2 x ... (dimN/blockSize) x blockSize>`. Scales will be calculated
1655
+ per block on the last axis. Therefore, scales will be of shape
1656
+ `<dim1 x dim2 x ... (dimN/blockSize) x 1>`. Scales could also be of some other
1657
+ shape as long as it is broadcast compatible with the input, e.g.,
1658
1658
`<1 x 1 x ... (dimN/blockSize) x 1>`.
1659
1659
1660
- In this example, before calling into `arith.scaling_truncf`, scales must be
1661
- broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
1662
- that there could be multiple quantization axes. Internally,
1660
+ In this example, before calling into `arith.scaling_truncf`, scales must be
1661
+ broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
1662
+ that there could be multiple quantization axes. Internally,
1663
1663
`arith.scaling_truncf` would perform the following:
1664
1664
1665
1665
```
@@ -1704,9 +1704,9 @@ end
1704
1704
"""
1705
1705
`shli`
1706
1706
1707
- The `shli` operation shifts the integer value of the first operand to the left
1708
- by the integer value of the second operand. The second operand is interpreted as
1709
- unsigned. The low order bits are filled with zeros. If the value of the second
1707
+ The `shli` operation shifts the integer value of the first operand to the left
1708
+ by the integer value of the second operand. The second operand is interpreted as
1709
+ unsigned. The low order bits are filled with zeros. If the value of the second
1710
1710
operand is greater or equal than the bitwidth of the first operand, then the
1711
1711
operation returns poison.
1712
1712
@@ -1721,7 +1721,7 @@ This op supports `nuw`/`nsw` overflow flags which stands for
1721
1721
%1 = arith.constant 5 : i8 // %1 is 0b00000101
1722
1722
%2 = arith.constant 3 : i8
1723
1723
%3 = arith.shli %1, %2 : i8 // %3 is 0b00101000
1724
- %4 = arith.shli %1, %2 overflow<nsw, nuw> : i8
1724
+ %4 = arith.shli %1, %2 overflow<nsw, nuw> : i8
1725
1725
```
1726
1726
"""
1727
1727
function shli (
@@ -1755,11 +1755,11 @@ end
1755
1755
"""
1756
1756
`shrsi`
1757
1757
1758
- The `shrsi` operation shifts an integer value of the first operand to the right
1759
- by the value of the second operand. The first operand is interpreted as signed,
1760
- and the second operand is interpreter as unsigned. The high order bits in the
1761
- output are filled with copies of the most-significant bit of the shifted value
1762
- (which means that the sign of the value is preserved). If the value of the second
1758
+ The `shrsi` operation shifts an integer value of the first operand to the right
1759
+ by the value of the second operand. The first operand is interpreted as signed,
1760
+ and the second operand is interpreter as unsigned. The high order bits in the
1761
+ output are filled with copies of the most-significant bit of the shifted value
1762
+ (which means that the sign of the value is preserved). If the value of the second
1763
1763
operand is greater or equal than bitwidth of the first operand, then the operation
1764
1764
returns poison.
1765
1765
@@ -1798,9 +1798,9 @@ end
1798
1798
"""
1799
1799
`shrui`
1800
1800
1801
- The `shrui` operation shifts an integer value of the first operand to the right
1801
+ The `shrui` operation shifts an integer value of the first operand to the right
1802
1802
by the value of the second operand. The first operand is interpreted as unsigned,
1803
- and the second operand is interpreted as unsigned. The high order bits are always
1803
+ and the second operand is interpreted as unsigned. The high order bits are always
1804
1804
filled with zeros. If the value of the second operand is greater or equal than the
1805
1805
bitwidth of the first operand, then the operation returns poison.
1806
1806
0 commit comments