Multiplication device and method, electronic device and computer readable storage medium
By designing a multiplication operation device, using data type conversion and a combination of multiple multiplication units, the problem of different calculation speed and accuracy differences in the neural network in different data types is solved, and efficient and low-power neural network operations are realized.
Patent Information
- Application Number
- CN202411052542.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-12-03
AI Technical Summary
In the process of neural network computing, different data types have different impacts on computing speed and accuracy, and how to be compatible with operations of different data types has become an urgent problem.
A multiplication operation device is designed, including a plurality of first multiplication units, a receiving unit and a control unit. Through data type conversion, the operations of different data types are converted into a unified data type, and the multiplication operation is performed in multiple multiplication units. Generate intermediate results and finally obtain compatible calculation results.
On the premise of ensuring computing accuracy, improve computing speed, reduce power and resource consumption, and is suitable for a variety of data types of neural network algorithms to promote its application and development in more fields.
Smart Images

Figure CN119065631A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a multiplication operation device and method, an electronic device, and a computer-readable storage medium. Background Art
[0002] During the neural network operation process, different data types have different effects on the calculation speed and accuracy of the neural network. How to make neural network operations compatible with different data types has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] At least one embodiment of the present disclosure provides a multiplication operation device, including: a plurality of first multiplication units, configured to perform multiplication operations of a first data type; a receiving unit, configured to obtain a first operand and a second operand of a second data type for multiplication operations; and a control unit, configured to convert the first operand to obtain at least one first conversion operand of the first data type, and convert the second operand to obtain at least one second conversion operand of the first data type according to the second data type, and control the plurality of first multiplication units to perform multiplication operations on the at least one first conversion operand and the at least one second conversion operand, respectively, to obtain at least one intermediate result of the first data type, and obtain a calculation result of the second data type from the at least one intermediate result.
[0004] For example, in a multiplication operation device provided in an embodiment of the present disclosure, the first operand includes a first mantissa and a first exponent, and the second operand includes a second mantissa and a second exponent; the multiplication operation device also includes: an addition unit, configured to perform an addition operation on the first exponent and the second exponent to obtain an intermediate exponent, wherein the control unit is further configured to convert the first mantissa corresponding to the first operand to obtain the at least one first conversion operand, convert the second mantissa of the second operand to obtain the at least one second conversion operand, obtain an intermediate mantissa based on the at least one intermediate result, and obtain the calculation result based on the intermediate mantissa and the intermediate exponent.
[0005] For example, in a multiplication operation device provided in an embodiment of the present disclosure, the first data type includes n bits; the at least one first conversion operand includes p first conversion operands, and the p first conversion operands respectively correspond to the p n bits of the first mantissa of the first operand from low to high; the at least one second conversion operand includes q second conversion operands, and the q second conversion operands respectively correspond to the q n bits of the second mantissa of the second operand from low to high, the p first conversion operands and the q second conversion operands are respectively multiplied to obtain p×q intermediate results, and the intermediate mantissa is obtained by combining the p×q intermediate results, wherein n, p and q are integers greater than or equal to 2.
[0006] For example, in the multiplication operation device provided in an embodiment of the present disclosure, at least one of the plurality of first multiplication units is repeatedly used for the multiplication operation performed on the at least one first conversion operand and the at least one second conversion operand.
[0007] For example, in the multiplication operation device provided in one embodiment of the present disclosure, the receiving unit is further configured to preprocess the first initial operand and the second initial operand of the second data type to obtain the first operand and the second operand of the second data type for the multiplication operation.
[0008] For example, in a multiplication operation device provided in an embodiment of the present disclosure, the first data type is INT4 or INT8; and the plurality of first multiplication units include INT4 multiplication units or INT8 multiplication units.
[0009] For example, in a multiplication operation device provided in an embodiment of the present disclosure, the second data type includes a fixed-point type or a floating-point type.
[0010] For example, in a multiplication operation device provided in an embodiment of the present disclosure, the floating point type includes FP64, FP32, TF32, BF16, FP16 or FP8.
[0011] At least one embodiment of the present disclosure provides a multiplication method, including: obtaining a first operand and a second operand of a second data type for multiplication operation; according to the second data type, converting the first operand to obtain at least one first conversion operand of the first data type, converting the second operand to obtain at least one second conversion operand of the first data type, and controlling multiple first multiplication units that perform multiplication operation of the first data type, respectively performing multiplication operation on the at least one first conversion operand and the at least one second conversion operand to obtain at least one intermediate result of the first data type, and obtaining a calculation result of the second data type from the at least one intermediate result.
[0012] For example, in a multiplication method provided in an embodiment of the present disclosure, the first operand includes a first mantissa and a first exponent, and the second operand includes a second mantissa and a second exponent; the method further includes: performing an addition operation on the first exponent and the second exponent to obtain an intermediate exponent; wherein the first mantissa corresponding to the first operand is converted to obtain the at least one first conversion operand, the second mantissa of the second operand is converted to obtain the at least one second conversion operand, an intermediate mantissa is obtained based on the at least one intermediate result, and the calculation result is obtained based on the intermediate mantissa and the intermediate exponent.
[0013] At least one embodiment of the present disclosure provides a multiplication operation device, comprising: at least one storage unit, configured to store computer-executable instructions; at least one processing unit, configured to execute the computer-executable instructions, wherein the computer-executable instructions, when executed by the processing unit, implement the multiplication operation method provided by any embodiment of the present disclosure.
[0014] At least one embodiment of the present disclosure provides an electronic device, including the multiplication operation device provided by any embodiment of the present disclosure.
[0015] At least one embodiment of the present disclosure provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processing unit, the multiplication method provided by any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.
[0017] Figure 1 A schematic block diagram of a multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0018] Figure 2 A diagram showing an application example of a multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0019] Figure 3 A diagram showing an application example of another multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0020] Figure 4 A diagram showing an application example of another multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0021] Figure 5 A diagram showing an application example of another multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0022] Figure 6 A diagram showing an application example of another multiplication operation device provided by at least one embodiment of the present disclosure is shown;
[0023] Figure 7 A schematic flow chart of a multiplication operation method provided by at least one embodiment of the present disclosure is shown;
[0024] Figure 8 A schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown;
[0025] Fig. 9 A schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown; and
[0026] Fig.10 A schematic block diagram of a computer-readable storage medium provided by at least one embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0028] Unless otherwise defined, the technical terms or scientific terms used in the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, similar words such as "one", "one" or "the" do not indicate quantity restrictions, but indicate that there is at least one. Similar words such as "include" or "comprise" mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Similar words such as "connect" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0029] In order to keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits detailed descriptions of some known functions or components.
[0030] Floating-point data plays a vital role in the field of data processing. For example, in the field of neural networks, floating-point numbers can provide a large dynamic range and high precision, which is essential for simulating complex nonlinear relationships and processing a large number of weight and activation value changes. Therefore, in the training, optimization or inference stage of deep learning models, there is a high demand for high-precision floating-point data types.
[0031] Floating point numbers are used to represent real numbers in computers. They represent data where the decimal point can float. They are usually expressed as N = M × R. E , including a sign bit, an exponent field E and a mantissa M, where R is the base (base) of the order (for example, 2, 8, 16, etc.).
[0032] For example, in the IEEE 754 standard, a single-precision floating-point number (such as FP32) has a total of 32 bits, including 1 sign bit, 8-bit exponent, and 23-bit mantissa (i.e., the sign bit occupies 1 bit, the exponent part occupies 8 bits, and the mantissa part occupies 23 bits); a double-precision floating-point number (such as FP64) has a total of 64 bits, including 1 sign bit, 11-bit exponent part, and 52-bit mantissa part. For example, FP8 is an 8-bit floating-point format. Due to the very limited number of bits, FP8 has lower precision, but the calculation speed is very fast. FP8 may include a sign bit, several exponent bits, and the remaining mantissa bits. The specific bit allocation of FP8 depends on the specific implementation.
[0033] The sign bit is used to indicate the sign of the operand, for example, 0 represents a positive number and 1 represents a negative number. The exponent part is used to store the exponent value, and the exponent part determines the position of the decimal point relative to the mantissa part. The mantissa part represents the decimal part of the operand, for example, the mantissa is a binary decimal, for example, it can be assumed that there is a hidden highest bit "1" (the highest bit may not be explicitly saved when stored to save storage space). In binary floating point numbers, these bits represent the digits after the binary decimal point.
[0034] For example, TF32 is a floating point format defined by TensorFlow. TF32 is designed to provide accuracy close to FP32, but with higher computing performance. TF32 can use exponent and mantissa structures similar to FP32, for example. TF32 has a total of 32 bits, including 1 sign bit, 8-bit exponent, 10-bit mantissa, and 13-bit remainder (the remaining 13 bits in the TF32 format are not used to represent the actual value, but are ignored).
[0035] For example, BF16 is a 16-bit floating point format. BF16 includes a sign bit, a 5-bit exponent, and a 10-bit mantissa. BF16 can provide similar computational accuracy to FP32, but with higher computational performance and lower memory bandwidth requirements.
[0036] For integer data, for example, INT12 is a 12-bit integer data type. INT12 can be used in situations where a larger range than an 8-bit integer is required but a full 16-bit or larger range is not required. INT12 can represent integers from 0 to 4095 (unsigned), or from -2048 to 2047 (signed, assuming the highest bit is used as the sign bit). In hardware design, INT12, for example, can be directly mapped to 12 consecutive binary bits without an additional sign bit or exponent bit.
[0037] For example, INT8 is an 8-bit integer data type. INT8 can represent integers from 0 to 255 (unsigned) or from -128 to 127 (signed, with the highest bit being the sign bit).
[0038] For example, INT4 is a 4-bit integer data type. INT4 can represent integers from 0 to 15 (unsigned) or from -8 to 7 (signed, with the highest bit being the sign bit).
[0039] For example, W4A8 is a mixed precision format where weights (W) are represented using 4-bit integers (INT4) and activations (A) are represented using 8-bit integers (INT8). The W4A8 format can significantly reduce memory usage and bandwidth requirements in deep learning inference while maintaining sufficient accuracy. By using a smaller number of bits to represent weights, W4A8 can significantly reduce the size of neural network models, allowing them to run on embedded and mobile devices.
[0040] During the operation of the neural network algorithm, different data types may affect the calculation speed, calculation accuracy and resource consumption of the neural network. Therefore, the selection of different data types is crucial to the training and reasoning process of the neural network.
[0041] For example, in the model training stage of the neural network, FP32 can provide higher computing accuracy, but correspondingly FP32 also increases the computational complexity and resource consumption of the neural network; although FP16 can reduce the computational complexity and resource consumption of the neural network by reducing the number of data bits, it may sacrifice a certain degree of computing accuracy.
[0042] In order to maintain the calculation accuracy of the neural network while improving the calculation speed, for the selection of data types, the inventors of the present disclosure noticed that TF32 can provide a neural network calculation accuracy similar to FP32, and TF32 also has a faster calculation speed than FP 32. INT8 and INT4 also have a faster calculation speed due to their smaller number of data bits. W4A8 (i.e., weight is INT4, activation is INT8) can achieve a good balance between the calculation speed and reasoning accuracy of the neural network, and also has good application prospects. BF16 and FP8 can also improve the calculation speed of the neural network and reduce resource consumption. BF16 can provide a larger dynamic range than FP16 so that it can be used in scenarios where FP16 precision is insufficient; FP8 further reduces the number of data bits to improve the calculation speed, but correspondingly FP8 will also sacrifice a certain degree of precision.
[0043] In addition, the inventors of the present disclosure also noticed that if there is no dedicated hardware to support neural network operations of different data types, some low-precision data types still need to call high-precision operation units when performing multiplication operations, which may cause these low-precision data types to lose their own advantages of high computing speed. Therefore, it is urgent to design a multiplication operation device that can be compatible with multiple data types (such as TF32, BF16, FP16, FP8, INT8, INT4), and the hardware area should be as small as possible to meet the needs of resource-constrained environments such as embedded systems and mobile devices.
[0044] At least one embodiment of the present disclosure provides a multiplication operation device and a corresponding multiplication operation method, an electronic device and a computer-readable storage medium. The multiplication operation device includes a plurality of first multiplication units, a receiving unit and a control unit. The plurality of first multiplication units are configured to perform a multiplication operation of a first data type; the receiving unit is configured to obtain a first operand and a second operand of a second data type for multiplication operation; the control unit is configured to convert the first operand to obtain at least one first conversion operand of the first data type, convert the second operand to obtain at least one second conversion operand of the first data type according to the second data type, and control the plurality of first multiplication units to perform multiplication operations on at least one first conversion operand and at least one second conversion operand respectively, obtain at least one intermediate result of the first data type, and obtain a calculation result of the second data type from the at least one intermediate result.
[0045] The multiplication device and multiplication method of this embodiment are compatible with a variety of data types, and can improve the calculation speed, reduce power consumption and reduce resource consumption while ensuring the calculation accuracy, thereby promoting the application and development of neural network algorithms in more fields.
[0046] Figure 1 A schematic block diagram of a multiplication operation device provided by at least one embodiment of the present disclosure is shown.
[0047] like Figure 1 As shown, the multiplication operation device 100 includes a plurality of first multiplication units 110 , a receiving unit 120 , and a control unit 130 .
[0048] The multiplication operation device 100 can be used to implement a fixed-point multiplication operation or a floating-point multiplication operation.
[0049] The plurality of first multiplication units 110 are configured to perform a multiplication operation of a first data type.
[0050] The receiving unit 120 is configured to obtain a first operand and a second operand of a second data type for a multiplication operation.
[0051] The control unit 130 is configured to convert the first operand into at least one first conversion operand of the first data type, convert the second operand into at least one second conversion operand of the first data type, and control multiple first multiplication units to perform multiplication operations on at least one first conversion operand and at least one second conversion operand respectively to obtain at least one intermediate result of the first data type, and obtain a calculation result of the second data type from the at least one intermediate result.
[0052] For the embodiments of the present disclosure, for example, if the mantissa of TF32 / FP16 is 10 bits, a 12-bit INT data is formed by adding implicit integer bits and sign bits, which can be expressed by INT12; the mantissa of BF16 is 7 bits, which is equivalent to 9 bits of INT data, which can also be expressed by INT12; similarly, the mantissa of floating-point data in other formats can also be expressed using corresponding INT data. Since the data volume of BF16 and FP16 is the same under the same bandwidth conditions, BF16 can be directly processed by INT12; the situation of FP8 and INT8 is similar, and can be directly processed by INT8. In summary, the multiplication operation device implements operations on various fixed-point data and / or floating-point data by supporting INT12, INT8, and INT4.
[0053] For example, the first data type may include an integer data type, which may include INT4, INT8, or INT12, etc., which is not limited in the embodiments of the present disclosure.
[0054] For example, the first multiplication unit 110 may include at least one of an INT4 multiplication unit, an INT8 multiplication unit, or an INT12 multiplication unit to support a variety of different integer data types. The INT4 multiplication unit is, for example, configured to perform a multiplication operation of two INT4 data types. The INT8 multiplication unit is, for example, configured to perform a multiplication operation of two INT8 data types.
[0055] The multiplication operation device 100 performs data type conversion so that the plurality of first multiplication units 110 can be flexibly configured to implement multiplication calculations of different data types as a whole to meet different computing requirements. In some embodiments, the multiplication operation device 100 can also expand computing power by adding more multiplication units or adjusting the configuration of existing multiplication units.
[0056] Under the control of the control unit 130 , the first multiplication unit 110 enables the multiplication operation to be performed in a correct timing and synchronization.
[0057] For example, the receiving unit 120 may serve as an interface component between the multiplication operation device 100 and an external device or between the multiplication operation device 100 and other units inside the multiplication operation device 100 to receive or obtain operands or other data.
[0058] The receiving unit 120 may be configured to receive or obtain operands of multiple second data types, for example. The second data type may include, for example, a fixed-point type or a floating-point type. The fixed-point type may include, for example, INT12, INT8, or INT4, and the floating-point type may include, for example, FP64, FP32, TF32, BF16, FP16, or FP8, etc., and the embodiments of the present disclosure are not limited to this.
[0059] For example, the receiving unit 120 may also have the function of receiving and buffering data so that the multiplication device can continuously and stably receive operands.
[0060] For example, the receiving unit 120 may further include a storage unit (such as a register or a buffer, etc.) for temporarily storing the received operands.
[0061] For example, the receiving unit 120 may support different communication protocols and data transmission modes to adapt to different application scenarios and requirements, which is not limited in the embodiments of the present disclosure.
[0062] The control unit 130 may be configured to coordinate and manage the entire multiplication process in the multiplication device 100 so that different data types can be processed correctly and obtain accurate results.
[0063] For example, the control unit 130 may be configured to identify the data types of the first operand and the second operand obtained by the receiving unit 120. According to the identified data type, the control unit 130 may convert these operands into data types (such as the first data type, such as INT4 or INT8, etc.) that can be processed by the first multiplication unit 110.
[0064] For example, the control unit 130 may be configured to control the plurality of first multiplication units 110 to perform multiplication operations. The control unit 130 may configure the first multiplication units 110 to perform corresponding multiplication operations according to the converted first conversion operands and the second conversion operands.
[0065] For example, the control unit 130 may also be configured to manage the timing signals required for the multiplication operation, so that each first multiplication unit 110 can complete the multiplication operation in the correct order and time.
[0066] For example, after the multiplication operation is completed, the control unit 130 may also be configured to receive at least one intermediate result output by the first multiplication unit 110, and further process the at least one intermediate result as needed to obtain the calculation result to be output. For example, the control unit 130 may also output the calculation result to an external device or an internal memory. In addition, the calculation result may also be used in a multiplication-accumulation operation, as an operand for the next round of multiplication-accumulation operation.
[0067] For example, during the multiplication operation, various abnormal conditions (such as data overflow or division by zero error, etc.) may occur. The control unit 130 may also be configured to detect and handle abnormal conditions, so that the multiplication operation device can operate stably and output the correct calculation result. For example, in the case of detecting an abnormality or error, the control unit 130 may take corresponding remedial measures, such as stopping the operation, outputting an error code, or attempting to resume the operation.
[0068] For example, the control unit 130 may also be configured to parse instructions from an internal program in the multiplication device 100 or an external controller to determine parameters such as the type of multiplication operation, operands, and required precision. The control unit 130 may convert the received operands into a data format that can be processed by the first multiplication unit 110 according to the requirements of the instruction and the identified data type. After the conversion is completed, the control unit 130 may assign these data to the corresponding first multiplication unit 110 for processing.
[0069] For example, the control unit 130 may also implement functions such as instruction parsing, data conversion, timing control, or exception handling through electronic circuits, and the embodiments of the present disclosure do not limit the specific implementation method.
[0070] For example, the control unit 130 can be interfaced with the receiving unit 120, multiple first multiplication units 110, and other possible units or modules to meet requirements such as data transmission rate, data bandwidth, or synchronization mechanism, so that various components, units, or modules can communicate and collaborate efficiently and accurately. The embodiments of the present disclosure do not limit the specific interface design.
[0071] In an embodiment of the present disclosure, the control unit 130 is configured to perform functions such as data type identification and conversion, multiplication operation control, intermediate result processing and calculation result generation. For example, in complex applications such as neural networks, the performance and reliability of the control unit 130 have an impact on the performance and stability of the multiplication operation device 100.
[0072] In some embodiments of the present disclosure, for multiplication operations between floating-point operands, the multiplication operation device 100 is decomposed according to the mantissa and the exponent, the multiplication operation between the mantissas is performed by the first multiplication unit 110 implemented as a fixed-point multiplication unit, and the addition operation between the exponents is completed by the addition unit, and then the final calculation result is obtained by combining; while for multiplication operations between fixed-point operands, it is directly performed by the first multiplication unit 110 implemented as a fixed-point multiplication unit. Correspondingly, in some embodiments of the present disclosure, the multiplication operation device 100 may also include an addition unit 140.
[0073] In these embodiments, the first operand includes a first mantissa and a first exponent, and the second operand includes a second mantissa and a second exponent. The adding unit 140 can be configured to perform an addition operation on the first exponent and the second exponent to obtain an intermediate exponent. Correspondingly, the control unit 130 can also be further configured to convert the first mantissa corresponding to the first operand to obtain at least one first conversion operand, convert the second mantissa of the second operand to obtain at least one second conversion operand, obtain an intermediate mantissa according to at least one intermediate result, and obtain a calculation result according to the intermediate mantissa and the intermediate exponent.
[0074] The adding unit 140 may be configured to perform addition operations on exponent portions of operands.
[0075] For example, the addition unit 140 may be configured to receive the exponents of two operands as input, perform an addition operation on the two exponents, and generate an intermediate exponent as output, which is then used to construct a final calculation result.
[0076] In these embodiments, the control unit 130 may be configured to, for example, identify the data type input by the receiving unit 120 and convert the mantissa corresponding to the operand into a conversion operand of the first data type according to the second data type.
[0077] For example, the control unit 130 may also be configured to perform necessary concatenation or formatting processing on at least one intermediate result output by the first multiplication unit 110 to obtain an intermediate mantissa.
[0078] For example, the control unit 130 may also be configured to combine the obtained intermediate mantissa with the intermediate exponent obtained by the aforementioned adding unit 140 to obtain a calculation result of the multiplication operation.
[0079] As mentioned above, for example, the mantissa of TF32 / FP16 data can be expressed by INT12, so the multiplication operation of two TF32 / FP16 data can be converted into the multiplication of two INT12 data corresponding to the mantissa and the addition operation corresponding to the exponent, and then combined to obtain the corresponding operation result.
[0080] For example, in some embodiments of the present disclosure, the first data type includes n bits, at least one first conversion operand includes p first conversion operands, and the p first conversion operands correspond to the p n bits of the first mantissa of the first operand from the low bit to the high bit, respectively. At least one second conversion operand includes q second conversion operands, and the q second conversion operands correspond to the q n bits of the second mantissa of the second operand from the low bit to the high bit, respectively. The p first conversion operands and the q second conversion operands are multiplied respectively to obtain p×q intermediate results, and the intermediate mantissa is obtained by combining the p×q intermediate results.
[0081] Here, n, p and q may be integers greater than or equal to 2. n may be used to represent the bit width of each conversion operand, and p and q may be used to represent the number of conversion operands into which the mantissas corresponding to the two operands are split.
[0082] In binary or fixed-point numbers, low to high bits can refer to the order from the least significant bit (LSB) to the most significant bit (MSB) of the value. For example, in an 8-bit binary number, the bits to the right are low bits and the bits to the left are high bits. In a multiplication operation, when a large number is split into multiple small numbers for operation, for example, the splitting and processing can be carried out in the order from low bits to high bits.
[0083] Here, p n bits may refer to, for example, splitting the mantissa of the first operand from the lower bit to the higher bit into p n-bit numbers. For example, if the mantissa of the first operand is a 32-bit number and n=8, then the mantissa may be split into four 8-bit fixed-point numbers (i.e., p=4).
[0084] For example, q n-bits may refer to splitting the mantissa of the second operand into q n-bit fixed-point numbers from low bits to high bits, and the splitting method may be the same as the aforementioned p n-bit splitting method.
[0085] Such bit splitting can make the conversion operand further adapt to the data bit width of the first multiplication unit 110 in the multiplication device 100 .
[0086] For example, the control unit 130 may be configured to convert the mantissa parts corresponding to the first operand and the second operand into first converted operands and second converted operands of the first data type, respectively, according to the second data type.
[0087] The first converted operand after conversion includes p n-bit numbers, which may correspond to the p n-bit segments of the mantissa of the first operand from the low bit to the high bit. Similarly, the second converted operand includes q n-bit numbers, which may correspond to the q n-bit segments of the mantissa of the second operand from the low bit to the high bit.
[0088] Each of the p first conversion operands is multiplied with each of the q second conversion operands, respectively, and a total of p×q multiplication operations are performed.
[0089] These p×q multiplication operations may be performed, for example, by a plurality of first multiplication units 110 , each of which may be configured to process a multiplication operation of one pair of converted operands and generate a corresponding intermediate result.
[0090] The p×q multiplication operations may generate p×q intermediate results, which may be fixed-point numbers having n bits, for example.
[0091] For example, the control unit 130 may be configured to combine the p×q intermediate results to form an intermediate mantissa. Here, the combination of the p×q intermediate results may be determined, for example, according to the data type of the operands or the required precision.
[0092] In some embodiments of the present disclosure, the receiving unit is further configured to pre-process the first initial operand and the second initial operand of the second data type to obtain the first operand and the second operand of the second data type for the multiplication operation.
[0093] For example, the receiving unit 120 may be configured to receive a first initial operand and a second initial operand of a second data type from other units or modules outside or inside the multiplication operation device 100 .
[0094] Here, preprocessing may include, for example, adjustment of data width, extraction of mantissa and exponent of initial operand, mantissa alignment, exponent alignment, bit supplementation, etc., which are not limited by the embodiments of the present disclosure. For example, when the data width of the first initial operand or the second initial operand is less than the requirement of the first multiplication unit 110, the receiving unit 120 may be configured to add padding bits (such as 0) to the low or high bits of the first initial operand or the second initial operand, so that the data width matches the requirement of the first multiplication unit 110. For example, the receiving unit 120 may also be configured to perform an alignment operation on the first operand or the second operand of the obtained second data type, so that the number of bits of the first operand and the second operand is the same or arranged in a specific alignment manner. Preprocessing may also include, for example, converting the initial operand into a format suitable for the first multiplication unit 110 to perform multiplication.
[0095] This preprocessing is used to achieve the correctness and consistency of the input data and provide a reliable basis for the subsequent multiplication operation. Through preprocessing, the multiplication operation device can efficiently process data of different types and formats to meet the diverse needs of the neural network algorithm.
[0096] In some embodiments of the present disclosure, the control unit 130 may be configured to perform data type conversion on a first operand and a second operand according to a second data type, converting the first operand to obtain at least one first converted operand of the first data type, and converting the second operand to obtain at least one second converted operand of the first data type.
[0097] For example, when the data type of the first operand and / or the second operand is a floating point number (such as FP32, FP16, etc.), the control unit 130 can be configured to convert these operands into a fixed point format for use in a subsequent multiplication operation.
[0098] For example, when the data type corresponding to the first operand and / or the second operand is TF32 or FP16, the control unit 130 may be configured to convert the data types of the first operand and the second operand to INT12 by adding implicit integer bits and sign bits to the first mantissa and the second mantissa corresponding to the first operand and the second operand, respectively.
[0099] For example, when the data type corresponding to the first operand and the second operand is BF16, the control unit 130 may be configured to supplement the number of bits of the first mantissa and the second mantissa corresponding to the first operand and the second operand, respectively, so as to make the data type of the first operand and the second operand equivalent to INT12.
[0100] For example, when the data type corresponding to the first operand and the second operand is FP8, the control unit 130 may be configured to supplement the number of bits of the first mantissa and the second mantissa corresponding to the first operand and the second operand, respectively, so as to make the data type of the first operand and the second operand equivalent to INT8.
[0101] Through the flexible data type conversion method, the control unit 130 can achieve the correctness and consistency of the multiplication operation data and provide a reliable basis for subsequent multiplication operations.
[0102] In some embodiments of the present disclosure, at least one of the plurality of first multiplication units 110 is repeatedly used for multiplication operations on at least one first conversion operand and at least one second conversion operand.
[0103] In the multiplication operation device 100, a plurality of first multiplication units 110 are used to perform a multiplication operation of the first data type. On the other hand, in order to improve the utilization of hardware resources in the multiplication operation device 100 and reduce the hardware deployment area of the multiplication unit, at least one first multiplication unit 110 can be repeatedly used for the multiplication operation of the first conversion operand and the second conversion operand.
[0104] For example, when an operand of a second data type (such as FP32, FP16, BF16, etc.) is converted to a conversion operand of a first data type (such as INT4, INT8, etc.), the mantissa portion can be divided into multiple n-bit segments. For example, if the first data type is INT4, and n=4, then the mantissa of an FP16 (for example, 10 bits or more, plus the implicit integer bit and sign bit to form a 12-bit int data) can be divided into multiple 4-bit segments. Each divided segment (i.e., multiple first conversion operands and multiple second conversion operands) can be provided to the first multiplication unit 110 for multiplication operations respectively. In order to reduce the number of multiplication units required, at least one first multiplication unit 110 can be reused for the multiplication operations of these conversion operands.
[0105] For example, the multiplexing of at least one first multiplication unit 110 may be implemented by time multiplexing. Here, time multiplexing may mean that the same first multiplication unit 110 may process different conversion operands at different time points.
[0106] After all the multiplication operations of the converted operands are completed, the intermediate results obtained can be combined to form an intermediate mantissa. For example, the intermediate results can be added or combined in other forms to obtain the same result as the multiplication of the original first mantissa and the second mantissa.
[0107] In addition, the control unit 130 can also be configured to optimize and schedule the multiplication operations of these conversion operands. For example, the control unit 130 can determine how to split the operands to form multiple conversion operands, how to schedule and reuse multiple first multiplication units 110, and how to combine multiple intermediate results to form intermediate mantissas.
[0108] In the embodiment of the present disclosure, at least one of the plurality of first multiplication units 110 can be effectively reused to perform multiplication operations on at least one first conversion operand and at least one second conversion operand, thereby improving the utilization of hardware resources and reducing the hardware deployment area of the multiplication unit. The multiplication operation device 100 can be compatible with multiplication operations of multiple data types, while maintaining high precision and high computing efficiency, achieving a smaller hardware area and lower power consumption.
[0109] For example, the first multiplication unit 110, the receiving unit 120, the control unit 130, and the adding unit 140 may be hardware, software, firmware, or any feasible combination thereof. For example, the first multiplication unit 110, the receiving unit 120, the control unit 130, and the adding unit 140 may be a dedicated or general circuit, chip, or device, etc. The embodiments of the present disclosure do not limit the specific implementation forms of the above-mentioned units.
[0110] It should be noted that Figure 1 The components and structures of the multiplication device 100 shown are merely exemplary and non-limiting. The multiplication device 100 may further include other components and structures as required.
[0111] The following takes the first multiplication unit as an INT4 multiplication unit as an example to exemplarily describe the multiplication operation device provided in the embodiment of the present disclosure.
[0112] Figure 2 to Figure 6 A diagram showing an application example of a multiplication operation device provided in some embodiments of the present disclosure.
[0113] For example, Figure 2 to Figure 6 In the example shown, each circle represents an INT4 multiplication unit.
[0114] In some embodiments of the present disclosure, Figure 2 As shown, the multiplication operation device includes 9 INT4 multiplication units.
[0115] Exemplarily, the values of p and q are both 3, which is used to perform a multiplication operation on a set of INT12×INT12 operands. The mantissas of the first operand and the second operand are expressed as data in INT12 format, and the data in INT12 format can be divided into three 4-bit (i.e., INT4) first conversion operands and second conversion operands, i.e., the 0th, 1st, and 2nd first conversion operands and the 0th, 1st, and 2nd second conversion operands, wherein the 0th first conversion operand X0 represents X0×1(16 0 ), the first conversion operand X1 represents X1×16 1 , the second first conversion operand X2 represents X2×16 2 , corresponding to the three columns from right to left in the figure; the 0th second conversion operand Y0 represents Y0×1(16 0 ), the first second conversion operand Y1 represents Y1×16 1 , the second conversion operand Y2 represents Y2×16 2 , corresponding to the three rows from top to bottom in the figure.
[0116] Figure 2 The number in each INT4 multiplication unit can represent the multiplication of p first conversion operands and q second conversion operands, that is, (0,0) can be used to represent the multiplication of the 0th first conversion operand and the 0th second conversion operand, (0,1) can be used to represent the multiplication of the 0th first conversion operand and the 1st second conversion operand, and so on, thereby obtaining p×q, that is, 9 intermediate results. These 9 intermediate results are as follows Figure 2As shown, the numbers are aligned from low to high (i.e., from right to left) in the vertical arithmetic form of multiplication, and then added vertically and whether to carry to the next position is determined based on the calculation result. That is, (0,0) in the first column from right to left corresponds to 16 0 The sum of (0,1) and (1,0) in the second column corresponds to 16. 1 The sum of (0,2), (1,1) and (2,0) in the third column corresponds to 16. 2 The sum of (1,2) and (2,1) in the fourth column corresponds to 16. 3 The result above, (2,1) in the fifth column corresponds to 16 4 The above results.
[0117] For example, when the multiplication operation device of the above-mentioned 9 INT4 multiplication units is used to perform the multiplication operation of INT12×INT12 operands, each INT4 multiplication unit is used exactly once; in another embodiment, for example, the multiplication device has 6 INT4 multiplication units, then only 6 INT4×INT4 operations can be executed at a time, and 3 INT4 multiplication units can be used to execute the remaining 3 INT4×INT4 operations, thereby obtaining 9 INT4×INT4 results, that is, these 3 INT4 multiplication units are reused in this calculation.
[0118] In some embodiments of the present disclosure, Figure 3 As shown, the multiplication operation device can use, for example, 4 INT4 multiplication units (eg, 4 of the 9 INT4 multiplication units). For example, the multiplication operation device uses 4 of the INT4 multiplication units for a multiplication operation of a set of INT8×INT8 operands.
[0119] In some embodiments of the present disclosure, Figure 4 As shown, the multiplication operation device uses, for example, two INT4 multiplication units (for example, two of the nine INT4 multiplication units). For example, the multiplication operation device uses two of the INT4 multiplication units for a multiplication operation of a set of INT4×INT8 operands.
[0120] In some embodiments of the present disclosure, Figure 5 As shown, the multiplication operation device uses, for example, 5 INT4 multiplication units (e.g., 5 of 9 INT4 multiplication units), or uses 4 INT4 multiplication units, at least one of which is multiplexed. For example, the multiplication operation device can be used for multiplication operations of operands compatible with INT4 and INT8 data types.
[0121] In this example, the first row corresponds to an INT12×INT4 multiplication, and the second row corresponds to an INT8×INT4 multiplication. For example, this method can also be used to implement two INT8×INT4 multiplications (thus being compatible with INT12×INT4 and INT8×INT4). In this case, only the lower 8 bits of the INT12 operand used by the INT12×INT4 multiplication in the first row can be used (thus using two multiplication units (0,0) and (0,1)), and for example, in order to further implement the addition of the two multiplication results, the lower bits of the (0,0) multiplication unit in the first row can be filled with bits, such as 4 bits of "0", as shown in FIG. Figure 5 The multiplication unit is indicated by the shaded area.
[0122] In some embodiments of the present disclosure, Figure 6 As shown, the multiplication operation device may include, for example, 10 INT4 multiplication units, or 9 multiplication units, at least one of which is multiplexed. For example, the multiplication operation device may be used for multiplication operations of operands compatible with INT4, INT8, and INT12 data types.
[0123] The multiplication device can be regarded as, for example, Figure 2 An expansion of the multiplication device shown.
[0124] For example, the high bit of the INT4 multiplication unit represented by (1, 2) may be filled with a sign bit, such as 4 bits of "0".
[0125] For example, when the multiplication operation device is used to perform a multiplication operation of two sets of INT8×INT8 operands, Figure 6 The non-shaded INT4 multiplication units can be configured to perform a set of INT8×INT8 operand multiplication operations. Figure 6 The INT4 multiplication unit in the shaded part can be reused for multiplication operations of another set of INT8×INT8 operands, and the intermediate results of the two sets of operations are combined to obtain two operation results, which are output separately.
[0126] Figure 7 A flowchart of a multiplication operation method provided by at least one embodiment of the present disclosure is shown.
[0127] like Figure 7 As shown, the multiplication method may include steps S200 to S230. The multiplication method corresponds to the multiplication device 100 provided in the above embodiment, for example.
[0128] Step S200: Obtain a first operand and a second operand of a second data type for a multiplication operation.
[0129] Step S210: According to the second data type, convert the first operand to obtain at least one first converted operand of the first data type, and convert the second operand to obtain at least one second converted operand of the first data type.
[0130] Step S220: Control multiple first multiplication units that perform multiplication operations of the first data type to perform multiplication operations on at least one first conversion operand and at least one second conversion operand, respectively, to obtain at least one intermediate result of the first data type.
[0131] Step S230: Obtain a calculation result of the second data type from at least one intermediate result.
[0132] In the multiplication operation method provided in some embodiments of the present disclosure, the first operand includes a first mantissa and a first exponent, the second operand includes a second mantissa and a second exponent, and the multiplication operation method may further include step S240.
[0133] Step S240: performing an addition operation on the first index and the second index to obtain an intermediate index.
[0134] Step S210 may also include, for example: converting a first mantissa corresponding to the first operand to obtain at least one first converted operand, and converting a second mantissa of the second operand to obtain at least one second converted operand.
[0135] Step S230 may also include, for example: obtaining an intermediate mantissa according to at least one intermediate result, and obtaining a calculation result of the second data type according to the intermediate mantissa and the intermediate exponent.
[0136] In the multiplication operation method provided in some embodiments of the present disclosure, the first data type includes n bits; at least one first conversion operand includes p first conversion operands, and the p first conversion operands respectively correspond to the p n bits from low to high of the first mantissa of the first operand; at least one second conversion operand includes q second conversion operands, and the q second conversion operands respectively correspond to the q n bits from low to high of the second mantissa of the second operand.
[0137] Step S230 may also include, for example: performing multiplication operations on the p first conversion operands and the q second conversion operands respectively to obtain p×q intermediate results, and combining the p×q intermediate results to obtain an intermediate mantissa, wherein n, p and q are integers greater than or equal to 2.
[0138] In the multiplication operation method provided in some embodiments of the present disclosure, the multiplication operation method also includes: controlling at least one first multiplication unit among multiple first multiplication units to repeatedly perform multiplication operations on at least one first conversion operand and at least one second conversion operand.
[0139] In the multiplication operation method provided in some embodiments of the present disclosure, step S200 may further include: preprocessing the first initial operand and the second initial operand of the second data type to obtain the first operand and the second operand of the second data type for the multiplication operation.
[0140] In the multiplication operation method provided in some embodiments of the present disclosure, the first data type may be, for example, INT4 or INT8, and the plurality of first multiplication units may include, for example, INT4 multiplication units or INT8 multiplication units.
[0141] In the multiplication operation methods provided in some embodiments of the present disclosure, the second data type may include, for example, a fixed-point type or a floating-point type.
[0142] In the multiplication operation methods provided in some embodiments of the present disclosure, the floating point type may include, for example, FP64, FP32, TF32, BF16, FP16, or FP8.
[0143] It should be noted that the functions, specific descriptions and technical effects of each step in the multiplication method provided in the embodiments of the present disclosure can be referred to in the aforementioned description of the multiplication device, and will not be repeated here.
[0144] It should be noted that the functions, specific descriptions and technical effects of each step in the multiplication method provided in the embodiments of the present disclosure can be referred to in the aforementioned description of the multiplication device, and will not be repeated here.
[0145] At least some embodiments of the present disclosure also provide another multiplication operation device, which includes at least one processing unit and at least one storage unit, wherein the storage unit is configured to store computer-executable instructions, and the processing unit is configured to run the computer-executable instructions, wherein the computer-executable instructions, when executed by the processing unit, can implement the multiplication operation method provided by any embodiment of the present disclosure.
[0146] At least some embodiments of the present disclosure also provide an electronic device. Figure 8 A schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown.
[0147] like Figure 8As shown, the electronic device 300 includes a processor (not shown in the figure), and the processor includes a multiplication device 301 according to any embodiment of the present disclosure as a multiplier in the execution unit. For example, the structure, function and technical effect of the multiplication device 301 can refer to the aforementioned description of the multiplication device, which will not be repeated here. The electronic device can be, for example, a central processing unit (CPU), a graphics processing unit (GPU), an AI accelerator (such as a tensor processing unit (TPU)), etc.
[0148] For example, the electronic device 300 may further include a memory (not shown in the figure). For example, the memory may be configured to receive and store relevant data for the multiplication operation device 301 .
[0149] For example, the memory may include any storage device having any structure capable of storing data, such as a memory or a cache.
[0150] According to actual needs, the electronic device 300 may also include more other components for performing subsequent processing of the calculation results, and the present disclosure does not impose specific limitations on this.
[0151] At least some embodiments of the present disclosure also provide an electronic device. Fig. 9 A schematic block diagram of an electronic device provided by at least one embodiment of the present disclosure is shown.
[0152] For example, Fig. 9 As shown, the electronic device 400 includes a memory 410 and a processor 420. For example, the memory 410 is used to non-temporarily store computer executable instructions, and the processor 420 is used to run the computer executable instructions. The processor 420, for example, includes an electronic device of any embodiment of the present invention, so that data of various data types including floating point data and integer data can be processed. For example, the electronic device 400 can be any device such as a mobile phone, a tablet computer, a laptop computer, an e-book, a game console, a television, a digital photo frame, a navigator, a server, etc., and can also be any combination of data processing devices and hardware, and the embodiments of the present disclosure are not limited to this.
[0153] For example, the memory 410 and the processor 420 may communicate with each other directly or indirectly. Fig. 9 As shown, the electronic device 400 may further include a system bus 430, and the memory 410 and the processor 420 may communicate with each other through the system bus 430. For example, the processor 420 may access the memory 410 through the system bus 1006. For example, in other examples, components such as the memory 410 and the processor 420 may communicate through a network on chip (NOC) connection.
[0154] For example, processor 420 may be a central processing unit (CPU), a tensor processing unit (TPU), a network processor (NP), or a graphics processing unit (GPU), etc., which have data processing capabilities and / or program execution capabilities, or may be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0155] For example, the memory 410 may include any combination of one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), compact disk read-only memory (CD-ROM), USB memory, flash memory, etc.
[0156] For example, one or more computer instructions may be stored in the memory 410, and the processor 420 may execute the one or more computer instructions to implement various functions. Various applications and various data may also be stored in the computer-readable storage medium, such as instruction processing codes and various data used and / or generated by the application.
[0157] For example, Fig. 9 As shown, the electronic device 400 may further include an input interface 440 that allows an external device to communicate with the electronic device 400. For example, the input interface 440 may be used to receive instructions from an external computer device, from a user, etc. The electronic device 400 may further include an output interface 450 that interconnects the electronic device 400 and one or more external devices. For example, the electronic device 400 may communicate with the external device through the output interface 450, etc.
[0158] At least some embodiments of the present disclosure also provide a computer-readable storage medium. Fig.10 A schematic block diagram of a computer-readable storage medium provided by at least one embodiment of the present disclosure is shown.
[0159] For example, Fig.10 As shown, the storage medium 500 non-temporarily stores computer executable instructions 510, and when the computer executable instructions 510 are executed by a processing unit (a device or unit with instruction processing capabilities), the multiplication method provided by any embodiment of the present disclosure can be executed.
[0160] For example, one or more computer instructions may be stored on the storage medium 500. Some of the computer instructions stored on the storage medium 500 may be, for example, instructions for implementing one or more steps in the multiplication method described above.
[0161] For example, the storage medium may be a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a compact disk read-only memory (CD-ROM), a flash memory, or any combination of the above storage media, or other applicable storage media.
[0162] At least some embodiments of the present disclosure also provide a computer program product. The computer program product includes computer program instructions, which are stored in a computer-readable storage medium. A processing unit of a computer device can read the computer program instructions from the computer-readable storage medium. When the computer program instructions are executed by the processing unit, the computer device can perform the multiplication method provided in any embodiment of the present disclosure. The processing unit is a circuit unit with instruction processing capability.
[0163] The technical effects of the computer program product provided by the embodiments of the present disclosure can be, for example, referred to the relevant description about the multiplication operation device in the aforementioned embodiments, which will not be repeated here.
[0164] There are a few points to note:
[0165] (1) The drawings of the embodiments of the present disclosure only relate to the structures involved in the embodiments of the present disclosure, and other structures may refer to the general design.
[0166] (2) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to obtain new embodiments.
[0167] The above description is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A multiplication device, comprising: a plurality of first multiplication units configured to perform multiplication operations of a first data type; A receiving unit configured to obtain a first operand and a second operand of a second data type for a multiplication operation; as well as A control unit is configured to, according to the second data type, convert the first operand to obtain at least one first converted operand of the first data type, convert the second operand to obtain at least one second converted operand of the first data type, and control the plurality of first multiplication units to perform multiplication operations on the at least one first converted operand and the at least one second converted operand, respectively, to obtain at least one intermediate result of the first data type, and obtain a calculation result of the second data type from the at least one intermediate result.
2. The multiplication device according to claim 1, wherein: The first operand includes a first mantissa and a first exponent, and the second operand includes a second mantissa and a second exponent; The multiplication operation device also includes: an adding unit configured to perform an addition operation on the first index and the second index to obtain an intermediate index, The control unit is further configured to convert the first mantissa corresponding to the first operand to obtain the at least one first conversion operand, convert the second mantissa of the second operand to obtain the at least one second conversion operand, obtain an intermediate mantissa based on the at least one intermediate result, and obtain the calculation result based on the intermediate mantissa and the intermediate exponent.
3. The multiplication device according to claim 2, wherein: The first data type comprises n bits; The at least one first conversion operand includes p first conversion operands, and the p first conversion operands respectively correspond to p n bits from a low bit to a high bit of a first mantissa of the first operand; The at least one second conversion operand includes q second conversion operands, and the q second conversion operands respectively correspond to q n bits from a low bit to a high bit of the second mantissa of the second operand, The p first conversion operands and the q second conversion operands are multiplied respectively to obtain p×q intermediate results, and the intermediate mantissa is obtained by combining the p×q intermediate results, wherein n, p and q are integers greater than or equal to 2.
4. The multiplication device according to claim 1, wherein: At least one of the plurality of first multiplication units is repeatedly used for the multiplication operation performed on the at least one first conversion operand and the at least one second conversion operand.
5. The multiplication device according to claim 1, wherein: The receiving unit is further configured to pre-process the first initial operand and the second initial operand of the second data type to obtain the first operand and the second operand of the second data type for the multiplication operation.
6. The multiplication device according to any one of claims 1 to 5, wherein: The first data type is INT4 or INT8; The plurality of first multiplication units include INT4 multiplication units or INT8 multiplication units.
7. The multiplication device according to claim 6, wherein: The second data type includes a fixed-point type or a floating-point type.
8. The multiplication device according to claim 7, wherein: Floating point types include FP64, FP32, TF32, BF16, FP16, or FP8.
9. A multiplication method, comprising: obtaining a first operand and a second operand of a second data type for a multiplication operation; converting the first operand to obtain at least one first converted operand of the first data type, converting the second operand to obtain at least one second converted operand of the first data type, and Control multiple first multiplication units that perform multiplication operations on the first data type, respectively perform multiplication operations on the at least one first conversion operand and the at least one second conversion operand to obtain at least one intermediate result of the first data type, and obtain the calculation result of the second data type from the at least one intermediate result.
10. The multiplication method according to claim 9, wherein: The first operand includes a first mantissa and a first exponent, and the second operand includes a second mantissa and a second exponent; The method further comprises: performing an addition operation on the first index and the second index to obtain an intermediate index; Among them, the first mantissa corresponding to the first operand is converted to obtain the at least one first conversion operand, the second mantissa of the second operand is converted to obtain the at least one second conversion operand, the intermediate mantissa is obtained according to the at least one intermediate result, and the calculation result is obtained according to the intermediate mantissa and the intermediate exponent.
11. A multiplication operation device, comprising: at least one storage unit configured to store computer executable instructions; as well as at least one processing unit configured to execute the computer executable instructions, Wherein, when the computer executable instructions are executed by the processing unit, the multiplication method described in any one of claims 9-10 is implemented.
12. An electronic device comprising the multiplication device according to any one of claims 1 to 8 or claim 11.
13. A computer-readable storage medium, wherein: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by the processing unit, the multiplication method described in any one of claims 9-10 is implemented.
