Name Strings
SPV_INTEL_arbitrary_precision_fixed_point
Contact
To report problems with this extension, please open a new issue at:
Contributors
-
Ajaykumar Kannan, Intel
-
Shuo Niu, Intel
-
Daniel Zhang, Intel
Notice
Copyright (c) 2023 Intel Corporation
Status
Final draft
Version
Last Modified Date |
2023-03-21 |
Revision |
1 |
Dependencies
This extension is written against the SPIR-V Specification Version 1.6, Revision 2.
While this extension does not require SPV_INTEL_arbitrary_precision_integers, the new operators it adds are significantly more useful when that extension is supported as the combination of the two extensions allows for more freedom in the width of arbitrary precision data types that can be represented (see the definition of the W
parameter below).
This extension is built on Mentor Graphics ac_datatypes spec v3.9.2.
Overview
This extension introduces operations for arbitrary precision fixed point numbers called ac_fixed. The ac_fixed datatype is an industry standard for fixed point numbers and is published by Mentor Graphics at hlslibs.org. This datatype and its corresponding operations can be useful on targets that can take advantage of narrower representation such as FPGAs.
Data Representation
The ac_fixed datatype will be represented in SPIR-V as a pseudo type using OpTypeInt.
It is characterized by three parameters: W
, I
, and S
.
-
W
is the total width of the datatype (including a sign bit, if required) and is encoded in the width of the OpTypeInt. -
I
determines the position of the decimal point.-
When
I
>= 0,I
bits starting from the MSB ofW
are before the decimal point. IfI
is greater thanW
, then additional 0 bits are implied after the bits ofW
and before the decimal point. -
When
I
< 0,-I
0 bits are implied after the decimal point and before the MSB ofW
.
-
-
S
determines if this is a signed or an unsigned number. Note that the support for signedness in OpTypeInt is not leveraged here. If the ac_fixed is signed, then the MSB (most significant bit) will contain the sign bit.
The datatype itself does not contain any information regarding I
and S
.
Each operation will contain information about the input and result datatypes (including W
, S
, and I
) where W
is implicit from the size of the OpTypeInt.
A variable of ac_fixed type can contain both an integer component and a fractional component depending on the value of I
.
Based on its value, the number of bits allocated for the integer and fractional portions will change.
Note that it is also possible that one of the two portions may have no bits.
Extension Name
To use this extension within a SPIR-V module, the following OpExtension must be present in the module:
OpExtension "SPV_INTEL_arbitrary_precision_fixed_point"
New Capabilities
This extension introduces a new capability:
ArbitraryPrecisionFixedPointINTEL
New Instructions
Instructions added under the ArbitraryPrecisionFixedPointINTEL capability:
OpFixedSqrtINTEL OpFixedRecipINTEL OpFixedRsqrtINTEL OpFixedSinINTEL OpFixedCosINTEL OpFixedSinCosINTEL OpFixedSinPiINTEL OpFixedCosPiINTEL OpFixedSinCosPiINTEL OpFixedLogINTEL OpFixedExpINTEL
Token Number Assignments
ArbitraryPrecisionFixedPointINTEL |
5922 |
OpFixedSqrtINTEL |
5923 |
OpFixedRecipINTEL |
5924 |
OpFixedRsqrtINTEL |
5925 |
OpFixedSinINTEL |
5926 |
OpFixedCosINTEL |
5927 |
OpFixedSinCosINTEL |
5928 |
OpFixedSinPiINTEL |
5929 |
OpFixedCosPiINTEL |
5930 |
OpFixedSinCosPiINTEL |
5931 |
OpFixedLogINTEL |
5932 |
OpFixedExpINTEL |
5933 |
Modifications to the SPIR-V Specification Version 1.6
After Section 3.16, add a new section "3.16b Quantization Modes" as follows:
Quantization Modes
Value | Mode | Behavior | Enabling Capabilities |
---|---|---|---|
0 |
TRN_INTEL |
Truncate towards -Inf |
ArbitraryPrecisionFixedPointINTEL |
1 |
TRN_ZERO_INTEL |
Truncate towards 0 |
ArbitraryPrecisionFixedPointINTEL |
2 |
RND_INTEL |
Round towards +Inf |
ArbitraryPrecisionFixedPointINTEL |
3 |
RND_ZERO_INTEL |
Round towards 0 |
ArbitraryPrecisionFixedPointINTEL |
4 |
RND_INF_INTEL |
Round positive values toward +Inf and negative values toward -Inf |
ArbitraryPrecisionFixedPointINTEL |
5 |
RND_MIN_INF_INTEL |
Round towards -Inf |
ArbitraryPrecisionFixedPointINTEL |
6 |
RND_CONV_INTEL |
Round towards even |
ArbitraryPrecisionFixedPointINTEL |
7 |
RND_CONV_ODD_INTEL |
Round towards odd |
ArbitraryPrecisionFixedPointINTEL |
After Section 3.16, add a new section "3.16c Overflow Modes" as follows:
Overflow Modes
Value | Mode | Behavior | Enabling Capabilities |
---|---|---|---|
0 |
WRAP_INTEL |
Drop the bits to the left of the MSB |
ArbitraryPrecisionFixedPointINTEL |
1 |
SAT_INTEL |
Saturate to the closest of MIN or MAX |
ArbitraryPrecisionFixedPointINTEL |
2 |
SAT_ZERO_INTEL |
Set to 0 on overflow |
ArbitraryPrecisionFixedPointINTEL |
3 |
SAT_SYM_INTEL |
For unsigned, treat as SAT_INTEL. For signed: a positive overflow will saturate at the maximum positive value, whereas a negative overflow will saturate to the negation of the maximum positive value, as opposed to the most negative value. |
ArbitraryPrecisionFixedPointINTEL |
After Section 3.16, add a new section "3.16d Signedness Modes" as follows:
Signedness Modes
Value | Mode | Behavior | Enabling Capabilities |
---|---|---|---|
0 |
UNSIGNED_INTEL |
Input and result types are unsigned |
ArbitraryPrecisionFixedPointINTEL |
1 |
SIGNED_INTEL |
Input and result types are signed |
ArbitraryPrecisionFixedPointINTEL |
Capability
Modify Section 3.31, Capability, adding a row to the Capability table:
Capability | Implicitly Declares | |
---|---|---|
5922 |
ArbitraryPrecisionFixedPointINTEL Enables arbitrary precision fixed-point math instructions. |
Instructions
In Section 3.32.13, Arithmetic Instructions, add the following instructions:
OpFixedSqrtINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the square root of the value is returned in Result. The behavior of this function is undefined for input values < 0. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5923 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedRecipINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the reciprocal ( Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5924 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedRsqrtINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the reciprocal square root ( Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5925 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedSinINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the sine of the value is returned in Result. Note that the angles are measured in radians. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5926 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedCosINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the cosine of the value is returned in Result. Note that the angles are measured in radians. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5927 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedSinCosINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and both the sine and cosine of the value are returned in Result. Note that the angles are measured in radians. Result Type must be a two-component vector of OpTypeInt. The first component of the Result contains the sine of the Input and is an arbitrary fixed point number. The second component of the Result contains the cosine of the Input and is also an arbitrary fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of each component of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5928 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedSinPiINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the sine of pi * Input is returned in Result. Note that the angles are measured in radians. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5929 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedCosPiINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the cosine of pi * Input is returned in Result. Note that the angles are measured in radians. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5930 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedSinCosPiINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and both the sine and cosine of pi * Input are returned in Result. Note that the angles are measured in radians. Result Type must be a two-component vector of OpTypeInt. The first component of the Result contains the sine of the Input and is an arbitrary fixed point number. The second component of the Result contains the cosine of the Input and is also an arbitrary fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of each component of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5931 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedLogINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the log of the value is returned in Result. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5932 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
OpFixedExpINTEL An OpTypeInt representing an arbitrary precision fixed point number (ac_fixed) is passed in as the Input and the exp of the value is returned in Result. Result Type must be OpTypeInt. Result is the <id> of the operation’s result, which is an arbitrary precision fixed point number. S is chosen from Table 3.16d that indicates the Signedness Mode of the input and output types. I is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the input type. rI is a signed 32-bit integer that refers to the location of the fixed-point relative to the MSB of the result type. Q is a QuantizationMode enum chosen from Table 3.16b that indicates the Quantization Mode of this operation. O is an OverflowMode enum chosen from Table 3.16c that indicates the Overflow Mode of this operation. |
Capability: ArbitraryPrecisionFixedPointINTEL |
||||||||
9 |
5933 |
<id> Result Type |
Result <id> |
Input <id> |
Signedness S |
Literal I |
Literal rI |
QuatntizationMode Q |
OverflowMode O |
Validation Rules
None.
Issues
None.
Revision History
Rev | Date | Author | Changes |
---|---|---|---|
1 |
2023-03-21 |
Ajaykumar Kannan |
Initial Public Release |