RegLayout
When the bit width of the source operand is different from that of the destination operand, there are two cases:
- The bit width ratio of the source operand to the destination operand is 1:2 or 2:1.
- The bit width ratio of the source operand to the destination operand is 1:4 or 4:1.
This data structure is used to determine the read or write position in the two cases. In case 1, a 256-byte RegTensor can be divided into two parts. For each byte, the index is the subscript i%2. In case 2, a 256-byte RegTensor can be divided into four parts. For each byte, the index is the subscript i%4. The options of RegLayout are as follows:
- RegLayout::ZERO: writes data to the position indexed by 0.
- RegLayout::ONE: writes data to the position indexed by 1.
- RegLayout::TWO: writes data to the position indexed by 2.
- RegLayout::THREE: writes data to the position indexed by 3.
enum class RegLayout {
UNKNOWN = -1,
ZERO,
ONE,
TWO,
THREE
};

As shown in the figure, RegLayout::ZERO and RegLayout::ONE can be used only when the bit width ratio is 1:2 or 2:1. For example, when float32 is converted to int16, the bit width ratio is 2:1. For a data type conversion with a bit width ratio of 2:1, you can use RegLayout to select the position where the data is written. When RegLayout::ZERO is used, data is written to the position with index 0. When RegLayout::ONE is used, data is written to the position with index 1.
RegLayout::ZERO, RegLayout::ONE, RegLayout::TWO, and RegLayout::THREE can be used only when the bit width ratio is 1:4 or 4:1. For example, when float32 is converted to int8, the bit width ratio is 4:1. For example, for a data type conversion with a bit width ratio of 4:1, when RegLayout::ZERO is used, data is written to the position with index 0; when RegLayout::ONE is used, data is written to the position with index 1; when RegLayout::TWO is used, data is written to the position with index 2; when RegLayout::THREE is used, data is written to the position with index 3.