High performance multiplier-accumulator, multiplication-accumulation method and electronic device
By grouping designing multipliers in the logical operation unit of the microprocessor, the utilization rate of the multiplier is improved and the hardware overhead is reduced, and the idle problem of multipliers in single-precision and half-precision floating-point number multiplication operations is solved. A more efficient floating-point number multiplication and addition operation is realized.
Patent Information
- Application Number
- CN202210832162.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-07-15
AI Technical Summary
In the logic operation unit of the microprocessor, the utilization rate of the multiplier is not high, resulting in an increase in hardware overhead, especially when single-precision and half-precision floating-point number multiplication operations, some multipliers are in idle state.
Design a high-performance multiplier, by grouping 2n half-precision multiplier into n single-precision multiplier, or forming n half-precision multiplier and single-precision multiplier, It can effectively participate in the operation during single-precision and half-precision floating-point number multiplication and addition operations, improve the utilization rate of the multiplier and addition device and save hardware overhead.
The utilization rate of half-precision and single-precision multiplier is improved, the hardware overhead is reduced, and more efficient floating-point number multiplication and addition operations are achieved.
Smart Images

Figure CN117435164B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a high-performance multiplier-adder, a multiplication-addition method and an electronic device. Background Art
[0002] In the logic operation unit of a microprocessor, a multiplier-adder is usually used to implement the multiplication and addition of floating-point numbers. Usually, the design scheme of the multiplier-adder in the logic operation unit is: set n single-precision multipliers and 2n half-precision multipliers. When the logic operation unit performs single-precision floating-point multiplication and addition operations, n single-precision multipliers and adders work at the same time, and n single-precision multiplication and addition results can be obtained; when the logic operation unit performs half-precision floating-point multiplication and addition operations, 2n half-precision multipliers and adders work at the same time, and 2n half-precision multiplication and addition results can be obtained.
[0003] However, when the logic operation unit performs single-precision floating-point multiplication and addition operations, 2n half-precision multipliers and adders are idle, and when the logic operation unit performs half-precision floating-point multiplication and addition operations, n single-precision multipliers and adders are idle. The utilization rate of the multipliers and adders is not high, and the design of a large number of multipliers and adders also increases the hardware overhead. Summary of the invention
[0004] Based on this, it is necessary to provide a high-performance multiplier-adder, a multiplication-addition method and an electronic device that can improve the utilization rate of the multiplier-adder in order to address the above technical problems.
[0005] In a first aspect, the present application provides a high-performance multiplier-adder, the high-performance multiplier-adder comprising: N single-precision multiply-add units, each single-precision multiply-add unit comprising: two half-precision multiply-adders;
[0006] When the high-performance multiplier-adder performs a single-precision floating-point multiplication-addition operation, the two half-precision multipliers-adders in each single-precision multiplication-addition unit are used to combine and perform a multiplication-addition operation on the single-precision floating-point number to be processed, and obtain a corresponding single-precision multiplication-addition result, and a total of N multiplication-addition results are obtained;
[0007] When the high-performance multiplier-adder performs half-precision floating-point multiplication and addition operations, each half-precision multiplier-adder is used to perform multiplication and addition operations on the half-precision floating-point numbers to be processed to obtain corresponding half-precision multiplication and addition results, and a total of 2N multiplication and addition results are obtained.
[0008] In a second aspect, the present application also provides a multiplication and addition method, the method comprising:
[0009] When the high-performance multiplier-adder performs a single-precision floating-point multiplication-addition operation, the two half-precision multipliers-adders in each single-precision multiplication-addition unit are combined to perform a multiplication-addition operation on the single-precision floating-point number to be processed, and obtain the corresponding single-precision multiplication-addition result, and a total of N multiplication-addition results are obtained;
[0010] When the high-performance multiplier-adder performs multiplication and addition operations on half-precision floating-point numbers, each half-precision multiplier-adder performs multiplication and addition operations on the half-precision floating-point numbers to be processed to obtain corresponding half-precision multiplication and addition results, and a total of 2N multiplication and addition results are obtained.
[0011] In a third aspect, the present application further provides an asymmetric multiplier-adder, the asymmetric multiplier-adder comprising: N multiplication-addition units, each multiplication-addition unit comprising: a single-precision multiplier-adder and a half-precision multiplier-adder;
[0012] When the asymmetric multiplier-adder performs a multiplication-addition operation of a half-precision floating-point number, the single-precision multiplier-adder and the half-precision multiplier-adder each perform a multiplication-addition operation on the half-precision floating-point number to be processed, and obtain the corresponding half-precision multiplication-addition result, and a total of 2N half-precision multiplication-addition results are obtained;
[0013] When the asymmetric multiplier-adder performs a single-precision floating-point multiplication and addition operation, the single-precision multiplier-adder performs a multiplication and addition operation on the single-precision floating-point number to be processed to obtain a corresponding single-precision multiplication and addition result, thereby obtaining a total of N single-precision multiplication and addition results.
[0014] In a fourth aspect, the present application further provides a multiplication-addition method, the method comprising:
[0015] When the asymmetric multiplier-adder performs a multiplication-addition operation of a half-precision floating-point number, the single-precision multiplier-adder and the half-precision multiplier-adder each perform a multiplication-addition operation on the half-precision floating-point number to be processed, and obtain the corresponding half-precision multiplication-addition result, and a total of 2N half-precision multiplication-addition results are obtained;
[0016] When the asymmetric multiplier-adder performs a single-precision floating-point multiplication and addition operation, the single-precision multiplier-adder performs a multiplication and addition operation on the single-precision floating-point number to be processed to obtain a corresponding single-precision multiplication and addition result, thereby obtaining a total of N single-precision multiplication and addition results.
[0017] In a fifth aspect, the present application further provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the method provided in the second aspect or the method provided in the fourth aspect when executing the computer program.
[0018] In a sixth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method provided in the second aspect or the method provided in the fourth aspect is implemented.
[0019] In a seventh aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the method provided in the second aspect or the method provided in the fourth aspect is implemented.
[0020] The above-mentioned multiplication and addition method, device, processor and computer program product provide two design ideas. One design idea is to set 2n half-precision multipliers and adders in the logic operation unit. The 2n half-precision multipliers and adders are grouped in pairs to obtain n groups in total. When performing single-precision floating-point multiplication and addition operations, the half-precision multipliers and adders also participate in the operation and are not idle, which improves the utilization rate of the half-precision multipliers and adders. Moreover, the scheme of the present application saves n single-precision multipliers and adders and reduces hardware overhead. Another design idea is to set n half-precision multipliers and adders in the logic operation unit, n single-precision multipliers and adders, a half-precision multiplier and adder and a single-precision multiplier and adder form a group, and obtain n groups in total. When performing half-precision floating-point multiplication and addition operations, the single-precision multipliers and adders also participate in the operation and are not idle, which improves the utilization rate of the single-precision multipliers and adders. Moreover, the scheme of the present application saves n half-precision multipliers and adders and reduces hardware overhead. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of a data format of a single-precision floating-point number in one embodiment;
[0022] Figure 2 A schematic diagram of a data format of a half-precision floating point number in one embodiment;
[0023] Figure 3 is a schematic diagram of a design structure of a logic operation unit in an embodiment;
[0024] Figure 4 is a schematic diagram of a design structure of a logic operation unit in another embodiment;
[0025] Figure 5 is a schematic diagram of a design structure of a logic operation unit in another embodiment;
[0026] Figure 6 A schematic diagram of a flow chart of a multiplication and addition method in one embodiment;
[0027] Figure 7 A schematic diagram of the internal structure of a multiplier-adder in one embodiment;
[0028] Figure 8 A schematic diagram of a flow chart of a single-precision floating-point multiplication and addition operation in one embodiment;
[0029] Fig. 9 A schematic diagram of the internal structure of a multiplier-accumulator in another embodiment;
[0030] Fig.10 A schematic diagram of a flow chart of a half-precision floating-point multiplication and addition operation in one embodiment;
[0031] Fig.11 A schematic flow chart of a multiplication and addition method in another embodiment;
[0032] Fig.12 A schematic diagram of the internal structure of a multiplier-accumulator in another embodiment;
[0033] Fig.13 It is a flowchart of half-precision floating-point multiplication and addition operation in another embodiment;
[0034] Fig.14 A schematic diagram of the internal structure of a multiplier-accumulator in another embodiment;
[0035] Fig.15 The figure is a flowchart of single-precision floating-point multiplication and addition operations in another embodiment. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0037] For ease of understanding, the terms used in the embodiments of the present application are explained below:
[0038] Single-precision floating point number: The binary floating point arithmetic standard (IEEE 754) stipulates that a single-precision floating point number consists of 32 bits of binary data. The data format of a single-precision floating point number is as follows: Figure 1 As shown,
[0039] S: Sign bit, S=0 indicates that the value represented by the single-precision floating-point number is a positive number, and S=1 indicates that the value represented by the single-precision floating-point number is a negative number.
[0040] Exponent: The exponent part, 8 bits of binary data.
[0041] Mantissa: The part after the decimal point, 23 bits of binary data.
[0042] Normalization: refers to the exponent that is not all 1 and not all 0, and the number 1 before the decimal point is omitted.
[0043] Denormal: refers to the exponent being all 0, the mantissa not all 0, and the digit 0 before the decimal point is omitted.
[0044] Bias: The bias of a normal single-precision floating point number is 0x7F, and the bias of a denormal single-precision floating point number is 0x7E.
[0045] Normal single-precision floating-point numbers represent values of:
[0046] data=(-1) S *2exponent-0x7F *(1.mantissa)
[0047] The value represented by the denormal single-precision floating-point number is:
[0048] data=(-1) S *2 exponent-0x7E *(0.mantissa)
[0049] Half-precision floating point number: Half-precision floating point number consists of 16 bits of binary data. The data format of half-precision floating point number is as follows: Figure 2 As shown, where S is the sign bit, S=0 indicates that the value represented by the half-precision floating point number is a positive number, and S=1 indicates that the value represented by the half-precision floating point number is a negative number.
[0050] Exponent: exponent part, 5 bits of binary data;
[0051] Mantissa: The part after the decimal point, 10 bits of binary data;
[0052] Normal: refers to the exponent that is neither entirely 1 nor entirely 0, and the number 1 before the decimal point is omitted.
[0053] Denormal: refers to the exponent being all 0, the mantissa not all 0, and the number 0 before the decimal point is omitted.
[0054] Bias: Normal half-precision floating point number bias = 0xF, Denormal half-precision floating point number bias = 0xE.
[0055] Normal half-precision floating point values are:
[0056] data=(-1) S *2 exponent-0xF *(1.mantissa)
[0057] Denormal half-precision floating point values are:
[0058] data=(-1) S *2 exponent-0xE *(0.mantissa)
[0059] In the logic operation unit of the microprocessor, a multiplier-adder is usually used to implement the multiplication and addition operation of floating-point numbers. Figure 3As shown, the design scheme of the multiplier-adder in the logic operation unit is: set n single-precision multipliers and 2n half-precision multipliers. When the logic operation unit performs single-precision floating-point multiplication and addition operations, n single-precision multipliers and adders work simultaneously, and n single-precision multiplication and addition results can be obtained; when the logic operation unit performs half-precision floating-point multiplication and addition operations, 2n half-precision multipliers and adders work simultaneously, and 2n half-precision multiplication and addition results can be obtained. The problem with this method is that when the logic operation unit performs single-precision floating-point multiplication and addition operations, 2n half-precision multipliers and adders are idle, and when the logic operation unit performs half-precision floating-point multiplication and addition operations, n single-precision multipliers and adders are idle, the utilization rate of the multipliers and adders is not high, and the design of a large number of multipliers and adders also increases the hardware overhead.
[0060] To this end, the present application embodiment proposes two other design ideas. One design idea is to refer to Figure 4 As shown, a high-performance multiplier and adder is provided, in which 2n half-precision multipliers and adders are still arranged. The 2n half-precision multipliers and adders are grouped in pairs to obtain n groups in total. When the high-performance multiplier and adder performs single-precision floating-point multiplication and addition operations, the two half-precision multipliers and adders in each group are combined to perform multiplication and addition operations on the single-precision floating-point numbers to be processed, and obtain corresponding single-precision multiplication and addition results. A total of n single-precision multiplication and addition results can be obtained. For the convenience of explanation, in the embodiment of the present application, each group is referred to as a single-precision multiplication and addition unit. When the high-performance multiplier and adder performs half-precision floating-point multiplication and addition operations, the 2n half-precision multipliers and adders work independently, that is, each half-precision multiplier and adder performs multiplication and addition operations on the half-precision floating-point numbers to be processed, and obtains corresponding half-precision multiplication and addition results. A total of 2n half-precision multiplication and addition results can be obtained. In the scheme of the embodiment of the present application, when performing single-precision floating-point multiplication and addition operations, the half-precision multipliers and adders also participate in the operations and are not idle, thereby improving the utilization rate of the half-precision multipliers and adders, and, Figure 3 Compared with the design scheme shown, the scheme of the embodiment of the present application saves n single-precision multipliers and adds, reducing hardware overhead.
[0061] Another design idea is to see Figure 5As shown, an asymmetric multiplier and adder is provided, in which n half-precision multipliers and adders and n single-precision multipliers and adders are arranged. A half-precision multiplier and adder and a single-precision multiplier and adder form a group, and a total of n groups are obtained. For the convenience of explanation, in the embodiment of the present application, each group is called a multiplication and addition unit. When the asymmetric multiplier and adder performs single-precision floating-point multiplication and addition operations, the n single-precision multipliers and adders work independently, that is, each single-precision multiplier and adder performs multiplication and addition operations on the single-precision floating-point number to be processed, and obtains the corresponding single-precision multiplication and addition results, and a total of n single-precision multiplication and addition results can be obtained. When the asymmetric multiplier and adder performs half-precision floating-point multiplication and addition operations, the n half-precision multipliers and adders work independently, and n half-precision multiplication and addition results are obtained, and each single-precision multiplier and adder converts the half-precision floating-point number to be processed into a single-precision floating-point number, and then performs multiplication and addition operations, and finally converts the result into half-precision, and n half-precision multiplication and addition results can also be obtained, and a total of 2n half-precision multiplication and addition results are obtained. In the solution of the embodiment of the present application, when performing half-precision floating-point multiplication and addition operations, the single-precision multiplier and adder also participates in the operation and is not idle, thereby improving the utilization rate of the single-precision multiplier and adder. Figure 3 Compared with the design scheme shown, the scheme of the embodiment of the present application saves n half-precision multipliers and adds, reducing hardware overhead.
[0062] It should be noted that: Figure 4 The high performance multiplier-accumulator shown can be applied to any type of processor that needs to perform floating-point multiplication and addition operations. Figure 5 The asymmetric multiplier-adder shown can also be applied to any type of processor that needs to perform floating-point multiplication and addition operations. The embodiment of the present application does not limit the type of processor.
[0063] The following are Figure 4 The high performance multiplier and Figure 5 The asymmetric multiplier-accumulator shown is described in detail.
[0064] First of all, Figure 4 The high performance multiplier-accumulator shown is described in detail.
[0065] In one embodiment, the high-performance multiplier-adder includes: N single-precision multiplication-addition units, each single-precision multiplication-addition unit includes: two half-precision multipliers; when the high-performance multiplier-adder performs single-precision floating-point multiplication-addition operations, the two half-precision multipliers in each single-precision multiplication-addition unit are used to combine and perform multiplication-addition operations on the single-precision floating-point numbers to be processed to obtain corresponding single-precision multiplication-addition results, and a total of N multiplication-addition results are obtained; when the high-performance multiplier-adder performs half-precision floating-point multiplication-addition operations, each half-precision multiplier is used to perform multiplication-addition operations on the half-precision floating-point numbers to be processed to obtain corresponding half-precision multiplication-addition results, and a total of 2N multiplication-addition results are obtained.
[0066] The two half-precision multipliers and adders include: a first half-precision multiplier and adder and a second half-precision multiplier and adder, and the single-precision floating-point numbers to be processed include: a first single-precision multiplier, a second single-precision multiplier and a single-precision addend.
[0067] When the high-performance multiplier-adder performs single-precision floating-point multiplication and addition operations, the first half-precision multiplier-adder is specifically used to perform a first part of the multiplication operation to obtain a first multiplication operation result, and transmit the first multiplication operation result to the second half-precision multiplier-adder; the second half-precision multiplier-adder is specifically used to perform a second part of the multiplication operation to obtain a second multiplication operation result, the first part of the multiplication operation and the second part of the multiplication operation are based on the decimal of the first single-precision multiplier and the decimal of the second single-precision multiplier, and are divided according to a preset rule; the second half-precision multiplier-adder is also used to determine the decimal of the multiplication operation result according to the first multiplication operation result and the second multiplication operation result; the single-precision multiplication and addition result is determined according to the decimal of the multiplication operation result, the exponent of the first single-precision multiplier, the exponent of the second single-precision multiplier, the sign of the first single-precision multiplier, the sign of the second single-precision multiplier, the decimal of the single-precision addend, the exponent of the single-precision addend, and the sign of the single-precision addend.
[0068] Among them, the second half-precision multiplier includes: an exponent addition operation module, a decimal addition module and a determination module; the exponent addition operation module is used to determine the exponent of the multiplication result according to the exponent of the first single-precision multiplier and the exponent of the second single-precision multiplier; the decimal addition module is used to determine the sign of the multiplication result according to the sign of the first single-precision multiplier and the sign of the second single-precision multiplier; the determination module is used to determine the decimal of the multiplication result, the sign of the multiplication result, the sign of the single-precision addend, the decimal of the multiplication result and the decimal of the single-precision addend, and determine the single-precision multiplication result according to the decimal of the multiplication result, the sign of the multiplication result and the decimal of the single-precision addend; determine the single-precision multiplication result according to the decimal of the multiplication result, the sign of the multiplication result and the exponent of the multiplication result.
[0069] Among them, the determination module includes: a first exponent subtraction operation module, a first shift operation module, a first addition operation module and a first multiplication and addition result exponent determination module; the first exponent subtraction operation module is used to determine the absolute value of the exponent difference according to the exponent of the multiplication operation result and the exponent of the single-precision addend; the first shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the single-precision addend according to the exponent of the multiplication operation result, the exponent of the single-precision addend and the absolute value of the exponent difference, so as to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the first addition operation module is used to determine the decimal of the multiplication and addition result and the sign of the multiplication and addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the first multiplication and addition result exponent determination module is used to determine the exponent of the multiplication and addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
[0070] Specifically, the exponential addition operation module is specifically used for:
[0071] The exponent of the multiplication result is determined using the following formula:
[0072] op01.exp=op0.exp+op1.exp-bias
[0073] Among them, op01.exp is the exponent of the multiplication result, op0.exp is the exponent of the first single-precision multiplier, op1.exp is the exponent of the second single-precision multiplier, and bias is the exponent deviation.
[0074] Specifically, the decimal addition module is used for:
[0075] An XOR operation is performed on the sign of the first single-precision multiplier and the sign of the second single-precision multiplier to obtain the sign of the multiplication result.
[0076] Specifically, the first shift operation module is specifically used for:
[0077] Compare the exponent of the multiplication result with the exponent of the single-precision addend; if the exponent of the multiplication result is greater than or equal to the exponent of the single-precision addend, shift the decimal of the single-precision addend right by the number of bits corresponding to the absolute value; if the exponent of the multiplication result is less than the exponent of the single-precision addend, shift the decimal of the multiplication result right by the number of bits corresponding to the absolute value.
[0078] Specifically, the first addition operation module is specifically used for:
[0079] If the sign of the multiplication result is different from the sign of the single-precision addend, the decimal of the single-precision addend after the shift operation is inverted and added by one to obtain the decimal of the single-precision addend after the inversion and addition; and the decimal of the multiplication result after the shift operation and the decimal of the single-precision addend after the inversion and addition are summed, and the sum result is used as the decimal of the multiplication and addition result; if the sign of the multiplication result is the same as the sign of the single-precision addend, the decimal of the multiplication result after the shift operation and the decimal of the single-precision addend after the shift operation are summed, and the sum result is used as the decimal of the multiplication and addition result.
[0080] Specifically, the first multiplication-addition result order determination module is specifically used for:
[0081] If the exponent of the multiplication result is greater than or equal to the exponent of the single-precision addend, the exponent of the multiplication result is used as the exponent of the multiplication-addition result; if the exponent of the multiplication result is less than the exponent of the single-precision addend, the exponent of the single-precision addend is used as the exponent of the multiplication-addition result.
[0082] In one embodiment, the half-precision floating-point number to be processed includes: a first half-precision multiplier, a second half-precision multiplier, and a half-precision addend.
[0083] When the high-performance multiplier and adder performs half-precision floating-point multiplication and addition operations, the half-precision multiplier and adder is specifically used to determine the decimal of the multiplication result according to the decimal of the first half-precision multiplier and the decimal of the second half-precision multiplier; determine the exponent of the multiplication result according to the exponent of the first half-precision multiplier and the exponent of the second half-precision multiplier; determine the sign of the multiplication result according to the sign of the first half-precision multiplier and the sign of the second half-precision multiplier; determine the decimal of the multiplication result, the sign of the multiplication result, the exponent of the half-precision addend, the sign of the half-precision addend and the decimal of the half-precision addend, and determine the half-precision multiplication result according to the decimal of the multiplication result, the sign of the multiplication result and the exponent of the multiplication result.
[0084] Among them, the half-precision multiplier and adder includes a second exponent subtraction operation module, a second shift operation module, a second addition operation module and a second multiplication and addition result exponent determination module: the second exponent subtraction operation module is used to determine the absolute value of the exponent difference according to the exponent of the multiplication operation result and the exponent of the half-precision addend; the second shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the half-precision addend according to the exponent of the multiplication operation result, the exponent of the half-precision addend and the absolute value of the exponent difference, so as to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the half-precision addend after the shift operation; the second addition operation module is used to determine the decimal of the multiplication and addition result and the sign of the multiplication and addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation and the decimal of the half-precision addend after the shift operation; the second multiplication and addition result exponent determination module is used to determine the exponent of the multiplication and addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
[0085] In one embodiment, Figure 6 As shown, a multiplication and addition method is provided, which is applied to Figure 4 The high performance multiplier-adder shown in the figure, the multiplication-addition method comprises the following steps:
[0086] S602, when the high-performance multiplier-adder performs single-precision floating-point multiplication and addition operations, the two half-precision multipliers-adders in each single-precision multiplication and addition unit are used to combine and perform multiplication and addition operations on the single-precision floating-point numbers to be processed to obtain corresponding single-precision multiplication and addition results, and a total of N multiplication and addition results are obtained.
[0087] For the convenience of explanation, for each single-precision multiplication-addition unit, the two half-precision multipliers and adders contained in the single-precision multiplication-addition unit can be respectively referred to as: a first half-precision multiplier and adder and a second half-precision multiplier and adder. As the name implies, the multiplication-addition operation includes both multiplication and addition. Therefore, the single-precision floating-point number to be processed includes two single-precision multipliers and one single-precision addend. For the convenience of explanation, the two single-precision multipliers are respectively referred to as a first single-precision multiplier and a second single-precision multiplier.
[0088] The expression of multiplication and addition operation is:
[0089] dst = op0 * op1 + op2
[0090] Among them, op0 is the first single-precision multiplier, op1 is the second single-precision multiplier, op2 is the single-precision addend, and dst is the multiplication and addition result.
[0091] The following is a description of the variables used in the multiplication and addition process:
[0092] op0.mant: the decimal of op0. When op0 is a normalized single-precision floating point number, op0.mant=1.mantissa. When op0 is a denormalized single-precision floating point number, op0.mant=0.mantissa.
[0093] op1.mant: the decimal of op1. When op1 is a normalized single-precision floating point number, op1.mant=1.mantissa. When op1 is a denormalized single-precision floating point number, op1.mant=0.mantissa.
[0094] op2.mant: the decimal of op2. When op2 is a normalized single-precision floating point number, op2.mant=1.mantissa. When op2 is a denormalized single-precision floating point number, op2.mant=0.mantissa.
[0095] op01.mant: the decimal of the result of the multiplication of op0*op1;
[0096] dst.mant: decimal of dst;
[0097] op0.exp: the exponent of op0;
[0098] op1.exp: the exponent of op1;
[0099] op2.exp: the exponent of op2;
[0100] op01.exp: the exponent of the result of the multiplication of op0*op1, op01.exp=op0.exp+op1.exp-bias;
[0101] dst.exp: exponent of dst;
[0102] op0.S: the sign of op0;
[0103] op1.S: the symbol of op1;
[0104] op2.S: the symbol of op2;
[0105] op01.S: the sign of the result of the multiplication of op0*op1. op0.S and op1.S are XORed to obtain op01.S.
[0106] dst.S : The sign of dst.
[0107] Optionally, when performing multiplication and addition operations on the single-precision floating-point numbers to be processed, op0.mant*op1.mant can be divided into two parts based on op0.mant and op1.mant according to a preset rule. For the convenience of explanation, the two multiplication operations obtained by the division are referred to as the first part of the multiplication operation and the second part of the multiplication operation.
[0108] For example: Because,
[0109] op0.mant[23:0]*op1.mant[23:0]=op0.mant[23:0]*op1.mant[11:0]+op0.mant[23:0]*op1.mant[23:12]
[0110] Then op0.mant[23:0]*op1.mant[23:0] can be divided into two parts of multiplication operation, the first part of multiplication operation is op0.mant[23:0]*op1.mant[11:0], and the second part of multiplication operation is op0.mant[23:0]*op1.mant[23:12]. Alternatively, the first part of multiplication operation is op0.mant[23:0]*op1.mant[23:12], and the second part of multiplication operation is op0.mant[23:0]*op1.mant[11:0].
[0111] It should be noted that the above-mentioned method of dividing the multiplication operation is only an example, and the embodiments of the present application are not limited to this. Other division methods may also be used, such as: dividing op0.mant[23:0]*op1.mant[23:0] into op0.mant[23:0]*op1.mant[12:0] and op0.mant[23:0]*op1.mant[23:13], etc.
[0112] Optionally, the first half-precision multiplier-adder may perform a first part of the multiplication operation to obtain a first multiplication operation result, and transmit the first multiplication operation result to the second half-precision multiplier-adder; the second half-precision multiplier-adder performs a second part of the multiplication operation to obtain a second multiplication operation result, and the second half-precision multiplier-adder determines op01.mant according to the first multiplication operation result and the second multiplication operation result. Specifically, the second half-precision multiplier-adder may add the first multiplication operation result and the second multiplication operation result to obtain op01.mant. When performing single-precision floating-point multiplication and addition operations, the embodiment of the present application divides the multiplication operation into two parts, and the two half-precision multipliers each perform a part, and then add them together, so that two half-precision multipliers can perform single-precision floating-point multiplication and addition operations, thereby improving the utilization rate of the half-precision multipliers and adders, and reducing the hardware overhead because no additional single-precision multipliers and adders are required.
[0113] Optionally, after the two half-precision multipliers and adders work together to obtain op01.mant, the second half-precision multiplier and adder can determine the corresponding single-precision multiplication and addition result according to op01.mant, op0.exp, op1.exp, op0.S, op1.S, op2.mant, op2.exp and op2.S. Specifically, the second half-precision multiplier and adder can determine op01.exp according to op0.exp and op1.exp; can determine op01.S according to op0.S and op1.S; can determine dst.mant, dst.S and dst.exp according to op01.exp, op2.exp, op01.S, op2.S, op01.mant and op2.mant; and then, based on dst.mant, dst.S and dst.exp, standardize them into the data format of single-precision floating-point numbers to obtain a single-precision multiplication and addition result.
[0114] Optionally, the two operands of the addition operation are op01 and op2. In order to make the exponents of the two numbers the same, the decimals need to be shifted. The second half-precision multiplier and adder can determine the absolute value of the exponent difference based on op01.exp and op2.exp; perform a shift operation on op01.mant or op2.mant based on op01.exp, op2.exp and the absolute value of the exponent difference to obtain op01.mant after the shift operation and op2.mant after the shift operation; the second half-precision multiplier and adder can determine dst.mant and dst.S based on op01.S, op2.S, op01.mant after the shift operation and op2.mant after the shift operation; and determine dst.exp based on op01.exp and op2.exp.
[0115] The structures of the first half-precision multiplier and the second half-precision multiplier are described below:
[0116] In a possible implementation, the first half-precision multiplier-adder and the second half-precision multiplier-adder can be designed as Figure 7 The schematic structure is as follows: Figure 7As shown, the first half-precision multiplier-adder includes: a fractional multiplication operation module 10, an exponent addition operation module 11, an exponent subtraction operation module 12, a shift operation module 13, an addition operation module 14, a standardization module 15, and a multiplication-addition result exponent determination module 16. Similarly, the second half-precision multiplier-adder includes: a fractional multiplication operation module 20, an exponent addition operation module 21, an exponent subtraction operation module 22, a shift operation module 23, an addition operation module 24, a standardization module 25, and a multiplication-addition result exponent determination module 26. It should be noted that: compared with the first half-precision multiplier and adder, the second half-precision multiplier and adder also includes: a decimal addition module 27, which is connected to the decimal multiplication module 10 in the first half-precision multiplier and adder. After the decimal multiplication module 10 in the first half-precision multiplier and adder obtains the multiplication result, the multiplication result is transmitted to the decimal addition module 27. The decimal addition module 27 is used to add the multiplication result obtained by the first single-precision multiplier and adder and the multiplication result obtained by the second single-precision multiplier and adder to obtain op01.mant.
[0117] It should be noted that: Figure 7 The dotted box in the middle indicates that when the high-performance multiplier-adder performs single-precision floating-point multiplication and addition operations, only the decimal multiplication module 10 participates in the operation in the first half-precision multiplier-adder, and the other operation processes are executed in the second half-precision multiplier-adder.
[0118] Combine the following Figure 7 The structure shown in the figure details the process of single-precision floating-point multiplication and addition. Figure 8 As shown, the process specifically includes:
[0119] S801, the decimal multiplication module 10 performs a first part of multiplication operation to obtain a first multiplication operation result, and transmits the first multiplication operation result to the decimal addition module 27. The decimal multiplication module 20 performs a second part of multiplication operation to obtain a second multiplication operation result, and transmits the second multiplication operation result to the decimal addition module 27. The decimal addition module 27 adds the first multiplication operation result and the second multiplication operation result to obtain op01.mant.
[0120] Specifically, the division method of the multiplication operation is as mentioned above, and the embodiments of the present application will not be repeated here.
[0121] S802, the exponent addition operation module 21 calculates op01.exp using the following formula:
[0122] op01.exp=op0.exp+op1.exp-bias
[0123] Among them, bias is the bias of the Normal single-precision floating point number, that is, bias = 0x7F.
[0124] S803. The decimal addition module 27 performs an exclusive OR operation on op0.S and op1.S to obtain op01.S.
[0125] Optionally, op0.S and op1.S can be input into the decimal addition module 27, enabling the decimal addition module 27 to perform an exclusive OR operation.
[0126] S804. The exponent subtraction operation module 22 calculates the absolute value of the exponent difference between op01.exp and op2.exp.
[0127] Optionally, after the exponent subtraction operation module 22 calculates the absolute value of the exponent difference, it can pass op01.exp, op2.exp, and this absolute value to the shift operation module 23.
[0128] S805. The shift operation module 23 compares op01.exp and op2.exp and performs a shift operation based on the comparison result.
[0129] Specifically, if op01.exp is greater than or equal to op2.exp, then shift op2.mant to the right by the number of bits corresponding to the above absolute value; if op01.exp is less than op2.exp, then shift op01.mant to the right by the number of bits corresponding to the above absolute value to obtain the shifted op01.mant and op2.mant.
[0130] Specifically, if op01.exp >= op2.exp, then shift op2.mant to the right by |op01.exp - op2.exp|;
[0131] if op01.exp < op2.exp, then shift op01.mant to the right by |op01.exp - op2.exp|.
[0132] Optionally, two selectors a and b can be set between the decimal addition module 27 and the shift operation module 23. If the shift operation module 23 determines that op01.exp >= op2.exp, it selects op2.mant from selector b for the shift operation, and at this time selector a passes op01.mant to the addition operation module 24; if the shift operation module 23 determines that op01.exp < op2.exp, it selects op01.mant from selector b for the shift operation, and at this time selector a passes op2.mant to the addition operation module 24.
[0133] S806. The addition operation module 24 compares op01.S and op2.S and performs a summation operation based on the comparison result.
[0134] If op01.S and op2.S are different, then take the one's complement of op2.mant after the shift operation of S805 and add one to it to obtain the one's complement plus one of op2.mant; and sum the one's complement plus one of op2.mant and op01.mant after the shift operation of S806, and use the sum result as dst.mant. Moreover, set dst.S equal to op01.S;
[0135] If op01.S and op2.S are the same, then directly sum op2.mant and op01.mant after the shift operation of S805, and use the sum result as dst.mant. Moreover, set dst.S equal to op01.S.
[0136] Optionally, the fractional addition module 27 can pass op01.S to the addition operation module 24 through the shift operation module 23, and can input op2.S to the addition operation module 24, so that the addition operation module 24 can determine whether op01.S and op2.S are the same. Or, directly input op0.S, op1.S, and op2.S into the addition operation module 24, so that the addition operation module 24 performs an exclusive OR operation to obtain op01.S, and makes the above judgment based on op01.S and op2.S.
[0137] S807. The multiply-accumulate result exponent determination module 26 determines dst.exp according to op01.exp and op2.exp.
[0138] Specifically, if op01.exp >= op2.exp, then dst.exp = op01.exp;
[0139] If op01.exp < op2.exp, then dst.exp = op02.exp.
[0140] Optionally, after obtaining dst.exp, the dst.exp can be normalized to obtain the 8-bit binary exponent of the normalized single-precision floating-point number.
[0141] S808. The normalization module 25 normalizes the dst.mant obtained by S806 to obtain the 23-bit binary mantissa of the normalized single-precision floating-point number.
[0142] Optionally, the addition operation module 24 can pass dst.S to the normalization module 25. In this case, in addition to outputting the 23-bit binary mantissa, the normalization module 25 also outputs the sign bit. The sign bit, the 8-bit binary exponent obtained by S807, and the 23-bit binary mantissa obtained by S808 constitute the single-precision multiply-accumulate result.
[0143] The above multiplication and addition method divides the multiplication operation into two parts, and two half-precision multipliers and adders each perform a part, so that the two half-precision multipliers and adders can be combined to complete the multiplication and addition operation of single-precision floating-point numbers, thereby improving the utilization rate of the half-precision multipliers and adders, and there is no need to set up additional single-precision multipliers and adders, thereby reducing hardware overhead.
[0144] S604. When the high-performance multiplier-adder performs a multiplication-addition operation on a half-precision floating-point number, each half-precision multiplier-adder performs a multiplication-addition operation on the half-precision floating-point number to be processed to obtain a corresponding half-precision multiplication-addition result, and a total of 2N multiplication-addition results are obtained.
[0145] The half-precision floating-point number to be processed includes two half-precision multipliers and one half-precision addend. For the convenience of explanation, the two half-precision multipliers are respectively referred to as a first half-precision multiplier and a second half-precision multiplier.
[0146] The expression of multiplication and addition operation is:
[0147] dst = op0 * op1 + op2
[0148] Among them, op0 is the first half-precision multiplier, op1 is the second half-precision multiplier, op2 is the half-precision addend, and dst is the multiplication and addition result.
[0149] It should be noted that, unlike the single-precision floating-point multiplication and addition process, since a single half-precision multiplier-adder supports half-precision floating-point multiplication and addition operations, there is no need to divide the multiplication operations.
[0150] Optionally, the half-precision multiplier and adder may determine op01.mant based on op1.mant and op2.mant; determine op01.exp based on op0.exp and op1.exp; determine op01.S based on op0.S and op1.S; determine dst.mant, dst.exp and dst.S based on op01.mant, op01.exp, op01.S, op2.mant, op2.exp and op2.S; and further, based on dst.mant, dst.exp and dst.S, standardize them into the data format of half-precision floating-point numbers to obtain a half-precision multiplication and addition result.
[0151] Similarly, the two operands of the addition operation are op01 and op2. In order to make the exponents of these two numbers the same, the decimals need to be shifted. The half-precision multiplier and adder can determine the absolute value of the exponent difference based on op01.exp and op2.exp; perform a shift operation on op01.mant or op2.mant based on op01.exp, op2.exp and the absolute value of the exponent difference to obtain op01.mant after the shift operation and op2.mant after the shift operation; determine dst.mant and dst.S based on op01.S, op2.S, op01.mant after the shift operation and op2.mant after the shift operation; and determine dst.exp based on op01.exp and op2.exp.
[0152] Combine the following Fig. 9 The structure shown in the figure details the process of half-precision floating-point multiplication and addition, taking the second half-precision multiplier as an example, see Fig.10 As shown, the process specifically includes:
[0153] S1001. The decimal multiplication module 20 calculates the product of op0.mant and op1.mant.
[0154] Specifically, op1.mant and op2.mant are both 11-bit binary data, and the calculated op01.mant is 22-bit binary data. Since the decimal multiplication module 10 is connected to the decimal addition module 27, and each half-precision multiplier is performing multiplication and addition operations of half-precision floating-point numbers, that is, the first half-precision multiplier is also performing multiplication and addition operations of half-precision floating-point data, in order to avoid the influence of the data transmitted by the decimal multiplication module 10, the decimal addition module 27 can set the transmitted data to zero by the decimal multiplication module 10, so that the output result of the decimal addition module 27 is the calculation result of the decimal multiplication module 20.
[0155] S1002, the exponent addition operation module 21 calculates op01.exp.
[0156] S1003, the decimal addition module 27 performs an XOR operation on op0.S and op1.S to obtain op01.S.
[0157] S1004 , the exponent subtraction module 22 calculates the absolute value of the exponent difference between op01.exp and op2.exp.
[0158] S1005 , the shift operation module 23 compares op01.exp and op2.exp, and performs a shift operation according to the comparison result.
[0159] S1006, the addition operation module 24 compares op01.S and op2.S, and performs a sum operation according to the comparison result to obtain dst.mant.
[0160] S1007. The multiplication-addition result exponent determination module 26 determines dst.exp according to op01.exp and op2.exp.
[0161] After obtaining dst.exp, the dst.exp may be standardized to obtain a 5-bit binary exponent of a standardized single-precision floating point number.
[0162] S1008. The standardization module 25 standardizes the dst.mant obtained in S1006 to obtain a 10-bit binary mantissa of a standardized single-precision floating point number.
[0163] The implementation process of S1001-S1008 is similar to that of S801-S808, and will not be described in detail in the present embodiment. The sign bit, the 5-bit binary exponent obtained in S1007, and the 10-bit binary mantissa obtained in S1008 constitute the half-precision multiplication and addition result.
[0164] In the multiplication and addition method of the embodiment of the present application, when the high-performance multiplier and adder performs single-precision floating-point multiplication and addition operations, the two half-precision multiplier and adders in each single-precision multiplication and addition unit are combined to perform multiplication and addition operations on the single-precision floating-point numbers to be processed, and obtain corresponding single-precision multiplication and addition results, and a total of N multiplication and addition results are obtained. When the high-performance multiplier and adder performs half-precision floating-point multiplication and addition operations, each half-precision multiplier and adder performs multiplication and addition operations on the half-precision floating-point numbers to be processed, and obtains corresponding half-precision multiplication and addition results, and a total of 2N multiplication and addition results are obtained. In the scheme of the embodiment of the present application, when performing single-precision floating-point multiplication and addition operations, the half-precision multiplier and adder also participates in the operation and is not idle, thereby improving the utilization rate of the half-precision multiplier and adder, and, Figure 3 Compared with the design scheme shown, the scheme of the embodiment of the present application saves n single-precision multipliers and adds, reducing hardware overhead.
[0165] Next, Figure 5 The asymmetric multiplier-accumulator shown is described in detail.
[0166] In one embodiment, the asymmetric multiplier-adder includes: N multiplication-addition units, each of which includes: a single-precision multiplier-adder and a half-precision multiplier-adder; when the asymmetric multiplier-adder performs half-precision floating-point multiplication-addition operations, the single-precision multiplier-adder and the half-precision multiplier-adder each perform multiplication-addition operations on the half-precision floating-point numbers to be processed, and obtain corresponding half-precision multiplication-addition results, and a total of 2N half-precision multiplication-addition results are obtained; when the asymmetric multiplier-adder performs single-precision floating-point multiplication-addition operations, the single-precision multiplier-adder performs multiplication-addition operations on the single-precision floating-point numbers to be processed, and obtains corresponding single-precision multiplication-addition results, and a total of N single-precision multiplication-addition results are obtained.
[0167] The half-precision floating-point numbers to be processed include: a first half-precision multiplier, a second half-precision multiplier and a half-precision adder, and the single-precision multiplier and adder include: a first conversion unit, a determination module and a second conversion unit; the first conversion unit is used to convert the first half-precision multiplier, the second half-precision multiplier and the half-precision adder into single precision to obtain the first single-precision multiplier, the second single-precision multiplier and the single-precision adder; the determination module is used to determine the single-precision multiplication and addition result according to the decimal of the first single-precision multiplier, the exponent of the first single-precision multiplier, the sign of the first single-precision multiplier, the decimal of the second single-precision multiplier, the exponent of the second single-precision multiplier, the sign of the second single-precision multiplier, the decimal of the single-precision adder, the exponent of the single-precision adder and the sign of the single-precision adder; the second conversion unit is used to convert the single-precision multiplication and addition result to obtain the half-precision multiplication and addition result.
[0168] Among them, the determination module includes: a decimal multiplication operation module, an exponent addition operation module, an addition operation module and a determination unit; the decimal multiplication operation module is used to determine the decimal of the multiplication operation result according to the decimal of the first single-precision multiplier and the decimal of the second single-precision multiplier; the exponent addition operation module is used to determine the exponent of the multiplication operation result according to the exponent of the first single-precision multiplier and the exponent of the second single-precision multiplier; the addition operation module is used to determine the sign of the multiplication operation result according to the sign of the first single-precision multiplier and the sign of the second single-precision multiplier; the determination unit is used to determine the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result according to the decimal of the multiplication and addition result, the exponent of the multiplication and addition result, the sign of the multiplication and addition result, the exponent of the single-precision addend, the sign of the single-precision addend and the decimal of the single-precision addend; determine the single-precision multiplication and addition result according to the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result.
[0169] Among them, the determination unit includes: a first exponent subtraction operation module, a first shift operation module, a first addition operation module and a first multiplication and addition result exponent determination module; the first exponent subtraction operation module is used to determine the exponent difference according to the exponent of the multiplication operation result and the exponent of the single-precision addend; the first shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the single-precision addend according to the exponent of the multiplication operation result, the exponent of the single-precision addend and the exponent difference, so as to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the first addition operation module is used to determine the decimal of the multiplication and addition result and the sign of the multiplication and addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the first multiplication and addition result exponent determination module is used to determine the exponent of the multiplication and addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
[0170] Specifically, the exponential addition operation module is specifically used for:
[0171] The exponent of the multiplication result is determined using the following formula:
[0172] op01.exp=op0.exp+op1.exp-bias
[0173] Among them, op01.exp is the exponent of the multiplication result, op0.exp is the exponent of the first single-precision multiplier, op1.exp is the exponent of the second single-precision multiplier, and bias is the exponent deviation.
[0174] Specifically, the addition operation module is specifically used for:
[0175] An XOR operation is performed on the sign of the first single-precision multiplier and the sign of the second single-precision multiplier to obtain the sign of the multiplication result.
[0176] Specifically, the first shift operation module is specifically used for:
[0177] Compare the exponent of the multiplication result with the exponent of the single-precision addend; if the exponent of the multiplication result is greater than or equal to the exponent of the single-precision addend, shift the decimal of the single-precision addend right by the number of bits corresponding to the difference in exponents; if the exponent of the multiplication result is less than the exponent of the single-precision addend, shift the decimal of the multiplication result right by the number of bits corresponding to the difference in exponents.
[0178] Specifically, the first addition operation module is specifically used for: if the sign of the multiplication operation result is different from the sign of the single-precision addend, then the decimal of the single-precision addend after the shift operation is inverted and added by one to obtain the decimal of the single-precision addend after the inversion and addition; and the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the inversion and addition are summed, and the sum result is used as the decimal of the multiplication and addition result; if the sign of the multiplication operation result is the same as the sign of the single-precision addend, then the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation are summed, and the sum result is used as the decimal of the multiplication and addition result.
[0179] Specifically, the first multiplication-addition result order determination module is specifically used for:
[0180] If the exponent of the multiplication result is greater than or equal to the exponent of the single-precision addend, the exponent of the multiplication result is used as the exponent of the multiplication-addition result; if the exponent of the multiplication result is less than the exponent of the single-precision addend, the exponent of the single-precision addend is used as the exponent of the multiplication-addition result.
[0181] In one embodiment, the single-precision floating-point number to be processed includes: a first single-precision multiplier, a second single-precision multiplier and a single-precision adder; the single-precision multiplier and adder is specifically used to determine the decimal of the multiplication result according to the decimal of the first single-precision multiplier and the decimal of the second single-precision multiplier; determine the exponent of the multiplication result according to the exponent of the first single-precision multiplier and the exponent of the second single-precision multiplier; determine the sign of the multiplication result according to the sign of the first single-precision multiplier and the sign of the second single-precision multiplier; determine the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result according to the decimal of the multiplication and addition result, the exponent of the multiplication and addition result, the sign of the multiplication and addition result, the exponent of the single-precision adder, the sign of the single-precision adder and the decimal of the single-precision adder; determine the single-precision multiplication and addition result according to the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result.
[0182] Among them, the single-precision multiplier and adder includes a second exponent subtraction operation module, a second shift operation module, a second addition operation module and a second multiplication and addition result exponent determination module: the second exponent subtraction operation module is used to determine the exponent difference according to the exponent of the multiplication operation result and the exponent of the single-precision addend; the second shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the single-precision addend according to the exponent of the multiplication operation result, the exponent of the single-precision addend and the exponent difference, so as to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the second addition operation module is used to determine the decimal of the multiplication and addition result and the sign of the multiplication and addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; the second multiplication and addition result exponent determination module is used to determine the exponent of the multiplication and addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
[0183] In one embodiment, Fig.11 As shown, a multiplication and addition method is provided, which is applied to Figure 5 The asymmetric multiplier-adder shown in FIG. 1 comprises the following steps:
[0184] S1102. When the asymmetric multiplier-adder performs multiplication and addition operations on half-precision floating-point numbers, the single-precision multiplier-adder and the half-precision multiplier-adder each perform multiplication and addition operations on the half-precision floating-point numbers to be processed to obtain corresponding half-precision multiplication and addition results, and a total of 2N half-precision multiplication and addition results are obtained.
[0185] It should be noted that the process of performing half-precision floating-point multiplication and addition operations by a half-precision multiplier and adder can be referred to in the prior art, and the present embodiment will not be repeated here. The following focuses on the process of performing half-precision floating-point multiplication and addition operations by a single-precision multiplier and adder.
[0186] The half-precision floating-point number to be processed includes: two half-precision multipliers and one half-precision addend. For the convenience of description, the two half-precision multipliers are respectively referred to as a first half-precision multiplier and a second half-precision multiplier.
[0187] Optionally, the single-precision multiplier and adder may convert the first half-precision multiplier, the second half-precision multiplier and the half-precision addend into single precision to obtain a first single-precision multiplier, a second single-precision multiplier and a single-precision addend, and then perform multiplication and addition operations on the first single-precision multiplier, the second single-precision multiplier and the single-precision addend.
[0188] The expression of multiplication and addition operation is:
[0189] dst = op0 * op1 + op2
[0190] Among them, op0 is the first single-precision multiplier after conversion, op1 is the second single-precision multiplier after conversion, op2 is the single-precision addend after conversion, and dst is the single-precision multiplication and addition result.
[0191] Optionally, after the above conversion, the single-precision multiplier-adder can determine the single-precision multiplication-addition result according to op0.mant, op1.mant, op2.mant, op0.exp, op1.exp, op2.exp, op0.S, op1.S and op2.S; the single-precision multiplication-addition result is converted to obtain a half-precision multiplication-addition result. In this way, the single-precision multiplier-adder can also perform multiplication-addition operations of half-precision floating-point numbers, thereby improving the utilization rate of the single-precision multiplier-adder. The solution of the embodiment of the present application can set up n fewer half-precision multipliers and adders, thereby reducing hardware overhead.
[0192] Optionally, the process of converting a half-precision floating point number into a single-precision floating point number can be referred to in the prior art, and will not be described in detail in the embodiments of the present application.
[0193] Optionally, the single-precision multiplier and adder may determine op01.mant based on op0.mant and op1.mant; determine op01.exp based on op0.exp and op2.exp; determine op01.S based on op0.S and op1.S; determine dst.mant, dst.S and dst.exp based on op01.mant, op01.exp, op01.S, op2.exp, op2.S and op2.mant; and based on dst.mant, standardize them into the data format of single-precision floating-point numbers to obtain a single-precision multiplication and addition result.
[0194] Similarly, the two operands of the addition operation are op01 and op2. In order to make the exponents of these two numbers the same, the decimals need to be shifted. The half-precision multiplier and adder can determine the absolute value of the exponent difference based on op01.exp and op2.exp; perform a shift operation on op01.mant or op2.mant based on op01.exp, op2.exp and the absolute value of the exponent difference to obtain op01.mant after the shift operation and op2.mant after the shift operation; determine dst.mant and dst.S based on op01.S, op2.S, op01.mant after the shift operation and op2.mant after the shift operation; and determine dst.exp based on op01.exp and op2.exp.
[0195] The structures of single-precision multipliers and half-precision multipliers are described below:
[0196] In one possible implementation, the single-precision multiplier-adder and the half-precision multiplier-adder can be designed as Fig.12 The schematic structure is as follows: Fig.12 As shown, the half-precision multiplier-adder includes: a fractional multiplication operation module 30, an exponent addition operation module 31, an exponent subtraction operation module 32, a shift operation module 33, an addition operation module 34, a standardization module 35, and a multiplication-addition result exponent determination module 36. The single-precision multiplier-adder includes: a fractional multiplication operation module 40, an exponent addition operation module 41, an exponent subtraction operation module 42, a shift operation module 43, an addition operation module 44, a standardization module 45, and a multiplication-addition result exponent determination module 46. It should be noted that compared with the half-precision multiplier-adder, the single-precision multiplier-adder further includes: a first conversion unit 47 and a second conversion unit 48. When the single-precision multiplier performs multiplication and addition operations of half-precision floating-point numbers, the first half-precision multiplier, the second half-precision multiplier and the half-precision addend are first converted into single precision through the first conversion unit 47 to obtain op0, op1 and op2, and then dst=op0*op1+op2 is calculated to obtain the single-precision multiplication and addition result, and then the single-precision multiplication and addition result is converted to obtain the half-precision multiplication and addition result.
[0197] Combine the following Fig.12 The structure shown in the figure details the process of single-precision multiplier-adder performing half-precision floating-point multiplication and addition operations. Fig.13 As shown, the process specifically includes:
[0198] S1301 , the first conversion unit 47 converts the first half-precision multiplier, the second half-precision multiplier, and the half-precision addend into single precision to obtain op0 , op1 , and op2 .
[0199] Optionally, the process of converting half-precision floating point numbers to single-precision floating point numbers can be referred to in the prior art, and the present embodiment will not be repeated here. After the first conversion unit 47 converts op0, op1 and op2, it transmits op0.mant and op1.mant to the decimal multiplication module 40.
[0200] S1302. The decimal multiplication module 40 calculates the product op01.mant of op0.mant and op1.mant.
[0201] Specifically, op0.mant and op1.mant are both 24-bit binary data, and the calculated op01.mant is 48-bit binary data.
[0202] S1303, the exponent addition module 41 calculates op01.exp.
[0203] S1304 , the addition module 44 performs an XOR operation on op0.S and op1.S to obtain op01.S.
[0204] Optionally, op0.S, op1.S and op2.S may be input to the addition operation module 44, so that the addition operation module 44 may perform an XOR operation to obtain op01.S.
[0205] S1305 , the exponent subtraction module 42 calculates the absolute value of the exponent difference between op01.exp and op2.exp.
[0206] S1306. The shift operation module 43 compares op01.exp and op2.exp, and performs a shift operation according to the comparison result.
[0207] S1307. The addition operation module 44 compares op01.S and op2.S, and performs a sum operation according to the comparison result to obtain dst.mant.
[0208] S1308. The multiplication-addition result exponent determination module 26 determines dst.exp according to op01.exp and op2.exp.
[0209] After obtaining dst.exp, the dst.exp may be standardized to obtain an 8-bit binary exponent of a standardized single-precision floating point number.
[0210] S1309, the standardization module 45 standardizes the dst.mant obtained in S1307 to obtain a 23-bit binary mantissa of a standardized single-precision floating point number.
[0211] S1310, the second conversion unit converts the 48-bit binary mantissa into a 10-bit binary mantissa, and converts the 8-bit binary exponent into a 5-bit binary exponent.
[0212] Optionally, the addition module 44 may transmit dst.S to the standardization module 45. In this case, the standardization module 45 outputs a sign bit in addition to a 23-bit binary mantissa. The sign bit, the 10-bit binary mantissa obtained in S1310, and the 5-bit binary exponent obtained in S1310 constitute a half-precision multiplication and addition result.
[0213] The above multiplication and addition method converts half-precision floating-point numbers into single-precision. In this way, the single-precision multiplier and adder can also perform multiplication and addition operations of half-precision floating-point numbers, thereby improving the utilization rate of the single-precision multiplier and adder. The solution of the embodiment of the present application can set up n fewer half-precision multipliers and adders, thereby reducing hardware overhead.
[0214] It should be noted that: Fig.12 The process of performing half-precision floating-point operations in the half-precision multiplier-accumulator, and Fig.13 Compared with the process shown in the figure, since no conversion is required, S1201 and S1210 are omitted, and other processes are similar, and the embodiments of the present application will not be described in detail here.
[0215] S1104. When the asymmetric multiplier-adder performs a single-precision floating-point multiplication-addition operation, each single-precision multiplier-adder performs a multiplication-addition operation on the single-precision floating-point number to be processed to obtain a corresponding single-precision multiplication-addition result, and a total of N single-precision multiplication-addition results are obtained.
[0216] The single-precision floating-point number to be processed includes two single-precision multipliers and one single-precision addend. For the convenience of description, the two single-precision multipliers are respectively referred to as a first single-precision multiplier and a second single-precision multiplier.
[0217] The expression of multiplication and addition operation is:
[0218] dst = op0 * op1 + op2
[0219] Among them, op0 is the first single-precision multiplier, op1 is the second single-precision multiplier, op2 is the single-precision addend, and dst is the multiplication and addition result.
[0220] It should be noted that: unlike the half-precision floating-point multiplication and addition process, since the single-precision multiplier-adder supports single-precision floating-point multiplication and addition operations, no conversion is required when the single-precision multiplier-adder performs single-precision floating-point multiplication and addition operations.
[0221] Optionally, the single-precision multiplier and adder may determine op01.mant based on op1.mant and op2.mant; determine op01.exp based on op0.exp and op1.exp; determine op01.S based on op0.S and op1.S; determine dst.mant, dst.exp and dst.S based on op01.mant, op01.exp, op01.S, op2.mant, op2.exp and op2.S; and further, based on dst.mant, dst.exp and dst.S, standardize them into the data format of single-precision floating-point numbers to obtain a single-precision multiplication and addition result.
[0222] Similarly, the two operands of the addition operation are op01 and op2. In order to make the exponents of these two numbers the same, the decimals need to be shifted. The single-precision multiplier and adder can determine the absolute value of the exponent difference based on op01.exp and op2.exp; perform a shift operation on op01.mant or op2.mant based on op01.exp, op2.exp and the absolute value of the exponent difference to obtain op01.mant after the shift operation and op2.mant after the shift operation; determine dst.mant and dst.S based on op01.S, op2.S, op01.mant after the shift operation and op2.mant after the shift operation; and determine dst.exp based on op01.exp and op2.exp.
[0223] Combine the following Fig.14 The structure shown in the figure details the process of performing single-precision floating-point multiplication and addition operations by the single-precision multiplier-accumulator. Fig.15 As shown, the process specifically includes:
[0224] S1501. The decimal multiplication module 40 calculates the product of op0.mant and op1.mant.
[0225] Specifically, since no conversion is required when performing single-precision floating-point multiplication and addition operations, the first conversion unit 47 and the second conversion unit 48 are in an invalid state at this time, and only have the function of transparent transmission. op1.mant and op2.mant are both 24-bit binary data, and the calculated op01.mant is 48-bit binary data.
[0226] S1502, the exponent addition operation module 41 calculates op01.exp.
[0227] S1503 , the addition module 44 performs an XOR operation on op0.S and op1.S to obtain op01.S.
[0228] S1504 , the exponent subtraction module 42 calculates the absolute value of the exponent difference between op01.exp and op2.exp.
[0229] S1505 , the shift operation module 43 compares op01.exp and op2.exp, and performs a shift operation according to the comparison result.
[0230] S1506, the addition operation module 44 compares op01.S and op2.S, and performs a sum operation according to the comparison result to obtain dst.mant.
[0231] S1507. The multiplication-addition result exponent determination module 46 determines dst.exp according to op01.exp and op2.exp.
[0232] After obtaining dst.exp, the dst.exp may be standardized to obtain an 8-bit binary exponent of a standardized single-precision floating point number.
[0233] S1508. The standardization module 25 standardizes the dst.mant obtained in S1506 to obtain a 23-bit binary mantissa of a standardized single-precision floating point number.
[0234] The implementation process of S1501-S1508 is similar to S1302-S1309, and the present embodiment will not be repeated here. The sign bit, the 8-bit binary exponent obtained by S1507, and the 23-bit binary mantissa obtained by S1508 constitute the single-precision multiplication and addition result.
[0235] In the multiplication and addition method of the embodiment of the present application, when the asymmetric multiplier and adder performs a half-precision floating-point multiplication and addition operation, each single-precision multiplier and adder and each half-precision multiplier and adder perform a multiplication and addition operation on the half-precision floating-point number to be processed, and obtain a corresponding half-precision multiplication and addition result, and a total of 2N half-precision multiplication and addition results are obtained; when the asymmetric multiplier and adder performs a single-precision floating-point multiplication and addition operation, each single-precision multiplier and adder performs a multiplication and addition operation on the single-precision floating-point number to be processed, and obtains a corresponding single-precision multiplication and addition result, and a total of N single-precision multiplication and addition results are obtained. In the scheme of the embodiment of the present application, when performing a half-precision floating-point multiplication and addition operation, the single-precision multiplier and adder also participates in the operation and is not idle, thereby improving the utilization rate of the single-precision multiplier and adder, and Figure 3 Compared with the design scheme shown, the scheme of the embodiment of the present application saves n half-precision multipliers and adds, reducing hardware overhead.
[0236] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps. The steps executed by each module in the above-mentioned device embodiment can refer to the description in the method embodiment.
[0237] Each module in the multiplication and addition device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0238] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0239] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0240] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. The protection scope of the present application shall be subject to the attached claims.
Claims
1. A high performance multiplier-accumulator, characterized in that: The high-performance multiplier-adder comprises: N single-precision multiply-add units, each of which comprises: two half-precision multiply-adders; When the high-performance multiplier-adder performs a single-precision floating-point multiplication-addition operation, the two half-precision multipliers-adders in each single-precision multiplication-addition unit are used to combine and perform a multiplication-addition operation on the single-precision floating-point number to be processed, and obtain a corresponding single-precision multiplication-addition result, and a total of N multiplication-addition results are obtained; When the high-performance multiplier-adder performs a half-precision floating-point multiplication-addition operation, each half-precision multiplier-adder is used to perform a multiplication-addition operation on the half-precision floating-point number to be processed to obtain a corresponding half-precision multiplication-addition result, and a total of 2N multiplication-addition results are obtained; The two half-precision multipliers and adders include: a first half-precision multiplier and adder and a second half-precision multiplier and adder, and the single-precision floating-point number to be processed includes: a first single-precision multiplier, a second single-precision multiplier and a single-precision addend; When the high-performance multiplier-adder performs single-precision floating-point multiplication and addition operations, the first half-precision multiplier-adder is specifically used to perform a first part of the multiplication operation to obtain a first multiplication operation result, and transmit the first multiplication operation result to the second half-precision multiplier-adder; the second half-precision multiplier-adder is specifically used to perform a second part of the multiplication operation to obtain a second multiplication operation result, the first part of the multiplication operation and the second part of the multiplication operation are based on the decimal of the first single-precision multiplier and the decimal of the second single-precision multiplier, and are divided according to a preset rule; the second half-precision multiplier-adder is also used to determine the decimal of the multiplication operation result according to the first multiplication operation result and the second multiplication operation result; the single-precision multiplication and addition result is determined according to the decimal of the multiplication operation result, the exponent of the first single-precision multiplier, the exponent of the second single-precision multiplier, the sign of the first single-precision multiplier, the sign of the second single-precision multiplier, the decimal of the single-precision addend, the exponent of the single-precision addend, and the sign of the single-precision addend.
2. The high performance multiplier-adder according to claim 1, characterized in that: The second half-precision multiplier-adder comprises: an exponent addition operation module, a decimal addition module and a determination module; The exponent addition module is used for determining the exponent of the multiplication result according to the exponent of the first single-precision multiplier and the exponent of the second single-precision multiplier; The decimal addition module is used to determine the sign of the multiplication result according to the sign of the first single-precision multiplier and the sign of the second single-precision multiplier; The determination module is used to determine the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result according to the exponent of the multiplication operation result, the exponent of the single-precision addend, the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result and the decimal of the single-precision addend; and determine the single-precision multiplication and addition result according to the decimal of the multiplication and addition result, the sign of the multiplication and addition result and the exponent of the multiplication and addition result.
3. The high performance multiplier-adder according to claim 2, characterized in that: The determination module includes: a first order code subtraction operation module, a first shift operation module, a first addition operation module and a first multiplication and addition result order code determination module; The first exponent subtraction operation module is used to determine the absolute value of the exponent difference according to the exponent of the multiplication operation result and the exponent of the single-precision addend; The first shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the single-precision addend according to the exponent of the multiplication operation result, the exponent of the single-precision addend, and the absolute value of the exponent difference, to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the shift operation; The first addition operation module is used to determine the decimal of the multiplication-addition result and the sign of the multiplication-addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation, and the decimal of the single-precision addend after the shift operation; The first multiplication-addition result exponent determination module is used to determine the exponent of the multiplication-addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
4. The high performance multiplier-adder according to claim 2, characterized in that: The order code addition operation module is specifically used for: The exponent of the multiplication result is determined using the following formula: ; in, is the exponent of the multiplication result, is the exponent of the first single-precision multiplier, is the exponent of the second single-precision multiplier, is the order deviation.
5. The high performance multiplier-accumulator according to claim 2, characterized in that: The decimal addition module is specifically used for: An XOR operation is performed on the sign of the first single-precision multiplier and the sign of the second single-precision multiplier to obtain a sign of the multiplication result.
6. The high performance multiplier-adder according to claim 3, characterized in that: The first shift operation module is specifically used for: Comparing the exponent of the multiplication result with the exponent of the single-precision addend; If the exponent of the multiplication result is greater than or equal to the exponent of the single-precision addend, the decimal of the single-precision addend is right-shifted by the number of bits corresponding to the absolute value; If the exponent of the multiplication result is less than the exponent of the single-precision addend, the decimal of the multiplication result is right-shifted by the number of bits corresponding to the absolute value.
7. The high performance multiplier-accumulator according to claim 3, characterized in that: The first addition operation module is specifically used for: If the sign of the multiplication operation result is different from the sign of the single-precision addend, the decimal of the single-precision addend after the shift operation is inverted and added by one to obtain the decimal of the single-precision addend after the inversion and addition; and the decimal of the multiplication operation result after the shift operation and the decimal of the single-precision addend after the inversion and addition are summed, and the sum result is used as the decimal of the multiplication and addition result; If the sign of the multiplication result is the same as the sign of the single-precision addend, the decimal of the multiplication result after the shift operation and the decimal of the single-precision addend after the shift operation are summed, and the sum is used as the decimal of the multiplication-addition result.
8. The high performance multiplier-adder according to claim 3, characterized in that: The first multiplication-addition result order determination module is specifically used for: If the exponent of the multiplication operation result is greater than or equal to the exponent of the single-precision addend, the exponent of the multiplication operation result is used as the exponent of the multiplication-addition result; If the exponent of the multiplication result is smaller than the exponent of the single-precision addend, the exponent of the single-precision addend is used as the exponent of the multiplication-addition result.
9. The high performance multiplier-accumulator according to claim 1, characterized in that: The half-precision floating-point number to be processed includes: a first half-precision multiplier, a second half-precision multiplier and a half-precision addend; When the high-performance multiplier performs half-precision floating-point multiplication and addition operations, the half-precision multiplier is specifically used to determine the decimal of the multiplication result according to the decimal of the first half-precision multiplier and the decimal of the second half-precision multiplier; determine the exponent of the multiplication result according to the exponent of the first half-precision multiplier and the exponent of the second half-precision multiplier; determine the sign of the multiplication result according to the sign of the first half-precision multiplier and the sign of the second half-precision multiplier; determine the decimal of the multiplication result, the sign of the multiplication result, the exponent of the half-precision addend, the sign of the half-precision addend and the decimal of the half-precision addend, and determine the half-precision multiplication result according to the decimal of the multiplication result, the sign of the multiplication result and the exponent of the multiplication result.
10. The high performance multiplier-adder according to claim 9, characterized in that: The half-precision multiplier-adder comprises a second order code subtraction operation module, a second shift operation module, a second addition operation module and a second multiplication-addition result order code determination module: The second exponent subtraction operation module is used to determine the absolute value of the exponent difference according to the exponent of the multiplication operation result and the exponent of the half-precision addend; The second shift operation module is used to perform a shift operation on the decimal of the multiplication operation result or the decimal of the half-precision addend according to the exponent of the multiplication operation result, the exponent of the half-precision addend and the absolute value of the exponent difference, so as to obtain the decimal of the multiplication operation result after the shift operation and the decimal of the half-precision addend after the shift operation; The second addition operation module is used to determine the decimal of the multiplication-addition result and the sign of the multiplication-addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation, and the decimal of the half-precision addend after the shift operation; The second multiplication-addition result exponent determination module is used to determine the exponent of the multiplication-addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
11. A multiplication and addition method, characterized in that: Applied to the high performance multiplier-adder according to any one of claims 1 to 10, the method comprising: When the high-performance multiplier-adder performs a single-precision floating-point multiplication-addition operation, the two half-precision multipliers-adders in each single-precision multiplication-addition unit are combined to perform a multiplication-addition operation on the single-precision floating-point number to be processed, and a corresponding single-precision multiplication-addition result is obtained, and a total of N multiplication-addition results are obtained; When the high-performance multiplier-adder performs a half-precision floating-point multiplication-addition operation, each half-precision multiplier-adder performs a multiplication-addition operation on the half-precision floating-point number to be processed to obtain a corresponding half-precision multiplication-addition result, and a total of 2N multiplication-addition results are obtained; The two half-precision multipliers and adders include: a first half-precision multiplier and adder and a second half-precision multiplier and adder, and the single-precision floating-point number to be processed includes: a first single-precision multiplier, a second single-precision multiplier and a single-precision addend; The two half-precision multipliers and adders are combined to perform multiplication and addition operations on the single-precision floating-point numbers to be processed to obtain corresponding single-precision multiplication and addition results, including: The first half-precision multiplier-adder performs a first partial multiplication operation to obtain a first multiplication operation result, and transmits the first multiplication operation result to the second half-precision multiplier-adder; The second half-precision multiplier-adder performs a second partial multiplication operation to obtain a second multiplication operation result, wherein the first partial multiplication operation and the second partial multiplication operation are divided according to a preset rule based on the decimal of the first single-precision multiplier and the decimal of the second single-precision multiplier; The second half-precision multiplier-adder determines a decimal of a multiplication result according to the first multiplication result and the second multiplication result; The second half-precision multiplier and adder determines the single-precision multiplication and addition result according to the decimal of the multiplication operation result, the exponent of the first single-precision multiplier, the exponent of the second single-precision multiplier, the sign of the first single-precision multiplier, the sign of the second single-precision multiplier, the decimal of the single-precision addend, the exponent of the single-precision addend, and the sign of the single-precision addend.
12. The method according to claim 11, characterized in that The second half-precision multiplier-adder determines the single-precision multiplication-addition result according to the decimal of the multiplication operation result, the exponent of the first single-precision multiplier, the exponent of the second single-precision multiplier, the sign of the first single-precision multiplier, the sign of the second single-precision multiplier, the decimal of the single-precision addend, the exponent of the single-precision addend, and the sign of the single-precision addend, including: The second half-precision multiplier-adder determines the exponent of the multiplication result according to the exponent of the first single-precision multiplier and the exponent of the second single-precision multiplier; The second half-precision multiplier-adder determines the sign of the multiplication result according to the sign of the first single-precision multiplier and the sign of the second single-precision multiplier; The second half-precision multiplier-adder determines the decimal of the multiplication-addition result, the sign of the multiplication-addition result and the exponent of the multiplication-addition result according to the exponent of the multiplication operation result, the exponent of the single-precision addend, the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result and the decimal of the single-precision addend; The second half-precision multiplier-adder determines the single-precision multiplication-addition result according to the decimal of the multiplication-addition result, the sign of the multiplication-addition result, and the exponent of the multiplication-addition result.
13. The method according to claim 12, characterized in that The second half-precision multiplier-adder determines the decimal of the multiplication-addition result, the sign of the multiplication-addition result, and the exponent of the multiplication-addition result according to the exponent of the multiplication operation result, the exponent of the single-precision addend, the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result, and the decimal of the single-precision addend, including: The second half-precision multiplier-adder determines an absolute value of an exponent difference according to an exponent of the multiplication operation result and an exponent of the single-precision addend; The second half-precision multiplier-adder performs a shift operation on the decimal of the multiplication result or the decimal of the single-precision addend according to the exponent of the multiplication result, the exponent of the single-precision addend, and the absolute value of the exponent difference to obtain the decimal of the multiplication result after the shift operation and the decimal of the single-precision addend after the shift operation; The second half-precision multiplier-adder determines the decimal of the multiplication-addition result and the sign of the multiplication-addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation, and the decimal of the single-precision addend after the shift operation; The second half-precision multiplier-adder determines the exponent of the multiplication-addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
14. The method according to claim 11, characterized in that The half-precision floating-point number to be processed includes: a first half-precision multiplier, a second half-precision multiplier and a half-precision addend; Each half-precision multiplier-adder performs multiplication and addition operations on the half-precision floating-point numbers to be processed to obtain corresponding half-precision multiplication and addition results, including: The half-precision multiplier-adder determines the decimal of the multiplication result according to the decimal of the first half-precision multiplier and the decimal of the second half-precision multiplier; The half-precision multiplier-adder determines the exponent of the multiplication result according to the exponent of the first half-precision multiplier and the exponent of the second half-precision multiplier; The half-precision multiplier-adder determines the sign of the multiplication result according to the sign of the first half-precision multiplier and the sign of the second half-precision multiplier; The half-precision multiplier-adder determines the decimal of the multiplication-addition result, the sign of the multiplication-addition result and the exponent of the multiplication-addition result according to the decimal of the multiplication operation result, the exponent of the multiplication operation result, the sign of the multiplication operation result, the exponent of the half-precision addend, the sign of the half-precision addend and the decimal of the half-precision addend; The half-precision multiplier-adder determines the half-precision multiplication-addition result according to the decimal of the multiplication-addition result, the sign of the multiplication-addition result and the exponent of the multiplication-addition result.
15. The method according to claim 14, characterized in that The half-precision multiplier-adder determines the decimal of the multiplication-addition result, the sign of the multiplication-addition result, and the exponent of the multiplication-addition result according to the decimal of the multiplication operation result, the exponent of the multiplication operation result, the sign of the multiplication operation result, the exponent of the half-precision addend, the sign of the half-precision addend, and the decimal of the half-precision addend, including: The half-precision multiplier-adder determines the absolute value of the exponent difference according to the exponent of the multiplication operation result and the exponent of the half-precision addend; The half-precision multiplier-adder performs a shift operation on the decimal of the multiplication result or the decimal of the half-precision addend according to the exponent of the multiplication result, the exponent of the half-precision addend, and the absolute value of the exponent difference, to obtain the decimal of the multiplication result after the shift operation and the decimal of the half-precision addend after the shift operation; The half-precision multiplier-adder determines the decimal of the multiplication-addition result and the sign of the multiplication-addition result according to the sign of the multiplication operation result, the sign of the single-precision addend, the decimal of the multiplication operation result after the shift operation, and the decimal of the half-precision addend after the shift operation; The half-precision multiplier-adder determines the exponent of the multiplication-addition result according to the exponent of the multiplication operation result and the exponent of the single-precision addend.
16. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 11 to 15 are implemented.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 11 to 15 are implemented.
