Data processing method and device, processor, electronic device, and storage medium
By converting the mantissa part of floating point numbers into integer types for multiplication operations, the problem of precision errors in floating point and integer multiplication is solved, high-precision floating point multiplication is achieved, calculation accuracy is improved and scaling errors are reduced.
Patent Information
- Application Number
- CN202410720964.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-05
AI Technical Summary
The existing technology has accuracy errors in the multiplication calculations of floating point numbers and integers. Especially during bilinear interpolation operations in artificial intelligence chips, insufficient floating point number multiplication in FP32 leads to scaling errors and affects calculation accuracy.
By converting the mantissa part of the floating point number into an integer type for multiplication operations, using the wider integer type bit width for calculation, the mantissa multiplication result is obtained, and the mantissa and exponent part of the destination operand are determined based on the result to achieve high-precision floating point numbers. multiplication.
It reduces the precision error of integer and floating-point multiplication and improves the calculation accuracy. For example, scaling errors are avoided in the application of the Resize operator and the accuracy of the operator is improved.
Smart Images

Figure CN118312130B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a data processing method, a processor, an electronic device, and a non-transitory computer-readable storage medium. Background Art
[0002] Floating point (FP) is mainly used to represent decimals, and usually consists of three parts, namely the sign bit, the exponent part, and the mantissa part. The exponent part can also be called the exponent part. For example, a floating point number V can usually be expressed as follows:
[0003]
[0004] Among them, the sign bit s can be 1 bit, which determines whether the floating-point number V is negative or positive; M represents the mantissa part, which can include multiple bits, which is in the form of a binary decimal and defines the precision of the floating-point number; E represents the exponent (also called the exponent value), which is used to weight the floating-point number, reflects the position of the decimal point in the floating-point number V, and defines the value range of the floating-point number. Summary of the invention
[0005] At least one embodiment of the present disclosure provides a data processing method, comprising: receiving a first source operand and a second source operand as input parameters, wherein the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type; using a first intermediate operand of the second integer type to represent a mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; converting the second source operand to the second integer type to obtain a second intermediate operand; performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; and obtaining a destination operand as an output parameter according to the mantissa multiplication result.
[0006] For example, in the data processing method provided by at least one embodiment of the present disclosure, a first intermediate operand of a second integer type is used to represent the mantissa part of the first source operand, including: filling in the hidden bits in the mantissa part of the first source operand to obtain a valid mantissa part; using L bits of the valid mantissa part as the 1st to Lth bits of the first intermediate operand, wherein the 1st bit of the first intermediate operand is the least significant bit.
[0007] For example, in the data processing method provided by at least one embodiment of the present disclosure, the destination operand is represented by three independent integer parameters, and the three independent integer parameters include a first integer parameter representing the mantissa part of the destination operand, a second integer parameter representing the sign bit of the destination operand, and a third integer parameter representing the exponent part of the destination operand. According to the mantissa multiplication result, the destination operand is obtained, including: directly using the mantissa multiplication result as the first integer parameter; determining the second integer parameter according to the sign bit of the first source operand and the sign bit of the second operand; and using the exponent part of the first source operand as the third integer parameter.
[0008] For example, in the data processing method provided by at least one embodiment of the present disclosure, the destination operand is a floating point number, and the destination operand is obtained according to the mantissa multiplication result, including: determining the mantissa part and the exponent part of the destination operand according to the mantissa multiplication result;
[0009] The sign bit of the destination operand is determined according to the sign bit of the first source operand and the sign bit of the second operand.
[0010] For example, in the data processing method provided by at least one embodiment of the present disclosure, the mantissa part and the exponent part of the destination operand are determined according to the mantissa multiplication result, including: determining a valid part from the mantissa multiplication result, wherein the starting point of the valid part is the first 1 appearing in the mantissa multiplication result along a preset direction, and the preset direction is the direction from high bits to low bits in the mantissa multiplication result; determining a mantissa intermediate result according to the valid part, wherein the bit width of the mantissa intermediate result is less than or equal to L; shifting the mantissa intermediate result according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0011] For example, in the data processing method provided by at least one embodiment of the present disclosure, the end point of the valid part is the last 1 that appears in the mantissa multiplication result along the preset direction, or the end point of the valid part is the lowest bit in the mantissa multiplication result, and the mantissa intermediate result is determined based on the valid part, including: rounding the valid part according to a preset rounding rule to obtain the mantissa intermediate result.
[0012] For example, in the data processing method provided in at least one embodiment of the present disclosure, the effective part is rounded according to a preset rounding rule to obtain the mantissa intermediate result, including: in response to the length N of the effective part being less than or equal to L, directly taking the effective part as the mantissa intermediate result; in response to the length N of the effective part being greater than L, determining the mantissa intermediate result according to the L+1th bit in the effective part, wherein when the length N of the effective part is greater than L, the bit width of the mantissa intermediate result is equal to L, the highest bit in the effective part is taken as the 1st bit, and the L+1th bit in the effective part is the L+1th bit starting from the 1st bit along the preset direction.
[0013] For example, in the data processing method provided in at least one embodiment of the present disclosure, the intermediate result of the mantissa is determined according to the L+1th bit in the effective part, including: in response to the L+1th bit in the effective part being the first value, discarding the L+1th bit to the Nth bit in the effective part, and taking the 1st bit to the Lth bit in the effective part as the intermediate result of the mantissa; in response to the L+1th bit in the effective part being the second value, and at least one bit among the L+2th bit to the Nth bit in the effective part is not the first value, discarding the L+1th bit to the Nth bit in the effective part, and performing a carry operation on the Lth bit of the effective part to obtain the intermediate result of the mantissa; in response to the L+1th bit in the effective part being the second value, and the L+2th bit to the Nth bit in the effective part are all the first value, determining the intermediate result of the mantissa according to the Lth bit of the effective part.
[0014] For example, in the data processing method provided by at least one embodiment of the present disclosure, determining the valid part from the mantissa multiplication result includes: starting from the starting point, continuously selecting up to L bits from the mantissa multiplication result along the preset direction as the valid part; determining the mantissa intermediate result according to the valid part includes: taking the valid part as the mantissa intermediate result.
[0015] For example, in the data processing method provided in at least one embodiment of the present disclosure, the destination operand is the product of the first source operand and the second source operand, and the shift processing includes shifting the mantissa intermediate result according to the value of the exponent part of the first source operand.
[0016] For example, in the data processing method provided by at least one embodiment of the present disclosure, the destination operand is the rounding result after further rounding operation is performed on the product result of the first source operand and the second source operand, and in response to the rounding operation instruction, a floor operation is performed on the product result, and the shift processing includes shifting the mantissa intermediate result according to the numerical value of the exponent part of the first source operand.
[0017] For example, in the data processing method provided by at least one embodiment of the present disclosure, the destination operand is the rounding result after further rounding operation is performed on the product result of the first source operand and the second source operand, and in response to the rounding operation instruction, a rounding-up operation is performed on the product result, and the shift processing includes: shifting the mantissa intermediate result according to the numerical value of the exponent part of the first source operand to obtain the shift result and the overflow mantissa part generated by the shift; in response to the overflow mantissa part being the first value, obtaining the mantissa part and the exponent part of the destination operand according to the shift result; in response to the overflow mantissa part not being all the first value, performing a carry operation on the shift result and obtaining the mantissa part and the exponent part of the destination operand according to the carry result.
[0018] For example, in the data processing method provided by at least one embodiment of the present disclosure, the sign bit of the destination operand is determined according to the sign bit of the first source operand and the sign bit of the second operand, including: in response to the sign bit of the first source operand and the sign bit of the second source operand being the same, determining the sign bit of the destination operand to be a positive sign bit, wherein the positive sign bit indicates that the destination operand is a positive number; in response to the sign bit of the first source operand and the sign bit of the second source operand being different, determining the sign bit of the destination operand to be a negative sign bit, wherein the negative sign bit indicates that the destination operand is a negative number.
[0019] At least one embodiment of the present disclosure provides a data processing method, comprising: receiving a data processing instruction indicating to perform at least floating-point and integer multiplication, wherein the data processing instruction comprises a first source operand and a second source operand as input parameters, and a destination operand as an output parameter, the type of the first source operand is a floating-point type, and the type of the second source operand is a first integer type; after parsing the data processing instruction, using an operation unit to execute the data processing instruction, wherein using the operation unit to execute the data processing instruction comprises: using a first intermediate operand of a second integer type to represent a mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; converting the second source operand to the second integer type to obtain a second intermediate operand; performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; and obtaining a destination operand as an output parameter according to the mantissa multiplication result.
[0020] At least one embodiment of the present disclosure provides a processor, including an instruction parsing unit and an operation unit, wherein the instruction parsing unit is used to receive and parse the data processing instruction, wherein the data processing instruction includes a first source operand and a second source operand as input parameters, and a destination operand as an output parameter, the first source operand is a floating point type, and the second source operand is a first integer type, and the operation unit executes the data processing instruction after the instruction parsing unit parses the data processing instruction, wherein the operation unit executes the data processing instruction, including performing the following operations: using a first source operand of a second integer type to execute the data processing instruction; An intermediate operand represents the mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; the second source operand is converted to the second integer type to obtain a second intermediate operand; integer multiplication of the second integer type is performed on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; according to the mantissa multiplication result, a destination operand as an output parameter is obtained.
[0021] At least one embodiment of the present disclosure provides a data processing device, including: an acquisition module, configured to receive a first source operand and a second source operand as input parameters, the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type; a first conversion module, configured to use a first intermediate operand of the second integer type to represent the mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; a second conversion module, configured to convert the second source operand into the second integer type to obtain a second intermediate operand; a multiplication calculation module, configured to perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; an output module, configured to obtain a destination operand as an output parameter according to the mantissa multiplication result.
[0022] At least one embodiment of the present disclosure provides an electronic device, comprising: a memory, which non-transitorily stores computer-executable instructions; and a processor, which is configured to execute the computer-executable instructions, wherein the computer-executable instructions, when executed by the processor, implement the data processing method according to any embodiment of the present disclosure.
[0023] At least one embodiment of the present disclosure provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the data processing method according to any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] 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.
[0025] Figure 1 The process of scaling the image by the Resize operator;
[0026] Figure 2 A schematic flow chart of a data processing method provided for at least one embodiment of the present disclosure;
[0027] Figure 3 A schematic diagram of the relationship between a first source operand and a first intermediate operand provided for at least one embodiment of the present disclosure;
[0028] Figure 4A and Figure 4B A schematic diagram of an effective part provided for at least one embodiment of the present disclosure;
[0029] Figure 5 A schematic flow chart of a data processing method provided for at least one embodiment of the present disclosure;
[0030] Figure 6 A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure;
[0031] Figure 7 A schematic structural diagram of a processor provided for at least one embodiment of the present disclosure;
[0032] Figure 8 A schematic block diagram of an electronic device provided in accordance with an embodiment of the present disclosure;
[0033] Fig. 9 A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] 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.
[0035] 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. "Include" or "comprise" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words 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. In order to keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits the detailed description of some known functions and known components.
[0036] Traditional floating-point numbers generally include three formats, namely half-precision floating-point numbers (FP16), single-precision floating-point numbers (FP32), and double-precision floating-point numbers (FP64), and their exponent and mantissa parts have different numbers of bits.
[0037] AI (Artificial Intelligence) accelerators have been widely used in deep learning model training. For the common convolution operations in deep learning models, special optimizations have been made in the design of software and hardware to accelerate calculations. For example, a variety of floating-point data formats have been optimized and developed for fields such as artificial intelligence or deep learning, such as BF16 (brain floating point 16, bit width is 16 bits), BF24 (brain floating point 24, bit width is 24 bits), TF32 (Tensor Float 32, bit width is 19 bits), etc. These data formats can greatly reduce the computing processing, especially the computing resources and power consumption required for matrix multiplication or convolution multiplication operations. In addition, the processor also supports some conventional floating-point types, such as half-precision floating point (FP16, bit width is 16 bits) or single-precision floating point (FP32, bit width is 32 bits).
[0038] Table 1 below shows the data formats of several floating point precision types.
[0039] Table 1 Data format
[0040]
[0041] As shown in Table 1, for the floating point precision type FP32, the total number of bits is 32 bits, including 1 sign bit, the exponent part (that is, the exponent code) includes 8 bits, the mantissa part includes 23 bits, and the mantissa effective bit width is 23+1=24 bits. For FP64, the total number of bits is 64 bits, including 1 sign bit, the exponent part (that is, the exponent code) includes 11 bits, the mantissa part includes 52 bits, and the mantissa effective bit width is 52+1=53 bits. For BF16, the total number of bits is 16 bits, including 1 sign bit, the exponent part (that is, the exponent code) includes 8 bits, the mantissa part includes 7 bits, and the mantissa effective bit width is 7+1=8 bits. For BF24, the total number of bits is 24 bits, including 1 sign bit, the exponent part (that is, the exponent code) includes 8 bits, the mantissa part includes 15 bits, and the mantissa effective bit width is 15+1=16 bits.
[0042] In order to represent the most effective data bits in the mantissa and make the floating-point number have a fixed representation method, the encoding of floating-point numbers should adopt certain specifications, which stipulate that the mantissa part is given as a pure decimal, and the absolute value of the mantissa should be greater than or equal to 1 / R (usually 2) and less than or equal to 1, that is, the first digit after the decimal point is not zero. Floating-point numbers that do not meet this requirement can be made to meet this specification by modifying the exponent and moving the mantissa at the same time. Therefore, for a normalized floating-point number, the highest bit of its mantissa is 1, and the number of its mantissa effective bits is the number of mantissa bits plus 1. For example, for a single-precision floating-point number, its mantissa part includes 23 bits, its mantissa effective bits are 24 bits, and the highest bit is 1.
[0043] The Resize operator is a common operator used to resize input data through interpolation methods to obtain output data of the desired size.
[0044] In PyTorch, the Resize operator is a function in the torchvision library, which is mainly used to adjust the size of an image. It accepts two main parameters: size and interpolation. The size parameter specifies the size of the target image, which can be an integer or a tuple; the interpolation parameter is used to specify the interpolation method, which defaults to bilinear interpolation.
[0045] In the field of deep learning, TensorRT is a performance-optimized deep learning inference engine, in which the Resize operator plays an important role in image processing and model deployment. It processes the input data using an interpolation algorithm to achieve image scaling and cropping.
[0046] Common interpolation methods include nearest neighbor interpolation, bilinear interpolation, bicubic interpolation, etc. The choice of these interpolation methods will affect the performance of the Resize operator and the quality of the output image.
[0047] Take the Resize operator in bilinear interpolation mode as an example. Figure 1 This section describes the process of using the Resize operator to scale an image.
[0048] like Figure 1 The bilinear interpolation diagram shown in FIG. 1 corresponds a pixel point D in the scaled image to the image before scaling according to the scaling relationship. The point found is usually not an integer pixel point (i.e., a position falling between 4 pixels), such as Figure 1 As shown in point S.
[0049] The bilinear interpolation mode defines the value of point S as Figure 1 The result of bilinear interpolation of the four points P11, P12, P21 and P22 around the middle point S. First, linearly interpolate P11 and P21 to get Q1, linearly interpolate P12 and P22 to get Q2, and then linearly interpolate Q1 and Q2 to get the value of S, that is:
[0050]
[0051] in, floor (*) indicates floor rounding function, X frac Represents the scaling ratio, that is, the size of the image after scaling divided by the size of the image before scaling. x D Indicates the coordinates of the element on the image before scaling.
[0052] Obviously, the accuracy of the Resize operator depends mainly on whether the calculation of the linear interpolation coordinates is accurate, and the accuracy of the interpolation coordinates depends on X frac ·x D , that is, the data precision used in the multiplication calculation of floating-point numbers and integers.
[0053] Many current artificial intelligence chips usually do not support FP64 high-precision floating-point numbers. Bilinear interpolation generally uses FP32 floating-point multiplication, namely: X fracUsing FP32 type, x D Convert from integer to FP32 type, and then X frac and x D Do FP32 multiplication to get the result x Finally, round down the result x to get x 1 This calculation method will produce scaling errors due to insufficient precision. This is because the calculation results of floating-point numbers are very similar due to precision errors, but they will differ greatly after rounding operations such as flooring, resulting in large scaling errors.
[0054] At least one embodiment of the present disclosure provides a data processing method, a processor, an electronic device, and a non-transitory computer-readable storage medium. The data processing method includes: receiving a first source operand and a second source operand as input parameters, wherein the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type; using a first intermediate operand of the second integer type to represent the mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; converting the second source operand to the second integer type to obtain a second intermediate operand; performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; and obtaining a destination operand according to the mantissa multiplication result.
[0055] In at least one embodiment, the method can simulate high-precision integer and floating-point multiplication, improve calculation accuracy, reduce the precision error of integer and floating-point multiplication, improve the accuracy of operators applying the method, such as the Resize operator, and avoid scaling errors.
[0056] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings, but the present disclosure is not limited to these specific embodiments.
[0057] Figure 2 A schematic flowchart of a data processing method provided for at least one embodiment of the present disclosure.
[0058] like Figure 2 As shown, the data processing method provided by at least one embodiment of the present disclosure includes steps S101 to S105.
[0059] In step S101 , a first source operand and a second source operand are received as input parameters.
[0060] For example, the type of the first source operand is a floating point number type, and the type of the second source operand is a first integer type.
[0061] For example, the first source operand and the second source operand may be input parameters provided by an instruction or microinstruction.
[0062] For example, the first source operand and the second source operand may be intermediate parameters in a data processing process, such as intermediate parameters generated during an instruction execution process.
[0063] Depending on different application fields, the first source operand and the second source operand may have different physical meanings.
[0064] For example, in the field of speech processing, the first source operand and the second source operand can be any parameters used, input, or generated in tasks such as feature extraction, speech enhancement, and speech recognition that require floating-point and integer multiplication, such as speech feature vectors, filtering parameters, etc.
[0065] For example, in the field of image processing, the first source operand and the second source operand can be any parameters that require floating point and integer multiplication, used, input, or generated in tasks such as image preprocessing, feature extraction, image segmentation, and target detection, such as image feature vectors, various edge detection operators (such as Sobel operator, Canny operator, Prewitt operator, etc.), image filtering operators (such as Gaussian filtering, median filtering, bilateral filtering, etc.), morphological operators (such as corrosion, expansion, opening operation, closing operation, etc.), etc. For example, in a specific example, the first source operand can be the Resize operator in X frac , indicating the scaling ratio, the second source operand can be the x D , which represents the coordinates of the element on the image before scaling.
[0066] For example, in the field of text processing, the first source operand and the second source operand can be any parameters that require floating-point and integer multiplication, such as the semantic feature vector of the text, used, input, or generated in tasks such as text classification, sentiment analysis, and text generation.
[0067] For example, in the field of video processing, the first source operand and the second source operand may be parameters in the field of image processing as described above, or parameters used, inputted, or generated by methods specific to the field of video processing, such as an optical flow operator (used to estimate motion between video frames) or a target tracking operator (used to track a specific target in a video).
[0068] Of course, the present disclosure is not limited to this. For other application scenarios or fields, as long as multiplication calculations of floating-point numbers and integers are required, the data processing method described in at least one embodiment of the present disclosure can be applied, and will not be described in detail here.
[0069] In step S102, a first intermediate operand of a second integer type is used to represent a mantissa portion of a first source operand.
[0070] For example, the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, where L is a positive integer.
[0071] For example, in one example, the second integer type may be selected according to the effective bit width L and the bit width of the first integer type, for example, the bit width of the second integer type is greater than the sum of the effective bit width L and the bit width of the first integer type.
[0072] For example, in another example, the second integer type to be used may be determined first, for example, the second integer type needs to be larger than the effective bit width L, and then the bit width of the maximum value of the second source operand may be determined based on the bit width of the second integer type and the effective bit width L. Specifically, in a specific example, the first source operand is FP64, and the effective bit width L of its mantissa is 53. Based on factors such as integer multiplication supported by the processor or computing power balance, it is determined that the second integer type to be used is UINT64 (64-bit unsigned integer), so the upper limit of the bit width of the second source operand (that is, the bit width of the maximum value of the second source operand) is 10 bits. This is because if the value of the second source operand is less than 2048, that is, it occupies a maximum of 10 bits, and the result of UINT64 multiplication of 10 bits and 53 bits will not exceed 64 bits.
[0073] For example, the bit width of the maximum value of the second source operand may be the difference between the bit width of the second integer type and the effective bit width L of the mantissa portion of the first source operand minus one.
[0074] For example, in order to use as many bits as possible to calculate the mantissa multiplication result, and the mantissa multiplication process does not consider the influence of the sign bit, the second integer type can be set to an unsigned integer.
[0075] In step S103 , the second source operand is converted to a second integer type to obtain a second intermediate operand.
[0076] In step S104, integer multiplication of the second integer type is performed on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result.
[0077] For example, the mantissa multiplication result is of the second integer type.
[0078] In step S105, the destination operand is obtained according to the mantissa multiplication result.
[0079] In at least one embodiment of the present disclosure, the multiplication of floating-point numbers and integers is converted to the multiplication of integers and integers. Specifically, the mantissa part of the floating-point number is converted to an integer and the integer multiplication is performed with the integer, so that as many mantissa digits as possible can be retained, the calculation accuracy can be improved, the precision error of integer and floating-point multiplication can be reduced, the accuracy of operators applying the method, such as the Resize operator, can be improved, and scaling errors can be avoided. For example, in some processors or chips that do not support high-precision floating-point numbers or high-precision floating-point multiplication, the data processing method provided by at least one embodiment of the present disclosure can be used to perform high-precision floating-point multiplication.
[0080] For example, step S102 may include: completing the hidden bits in the mantissa part of the first source operand to obtain the effective mantissa part; using L bits of the effective mantissa part as the first to Lth bits of the first intermediate operand, wherein the first bit of the first intermediate operand is the least significant bit. The Lth bit of the first intermediate operand is the Lth bit in the direction from the low bit to the high bit.
[0081] For normalized floating-point numbers, the highest bit of the mantissa is always 1, so in order to represent the most valid data bits in the mantissa, it is usually hidden, also called a hidden bit.
[0082] For example, for a normalized floating-point number, at least the hidden bits of the mantissa are filled in the padding operation, that is, a 1 is added before the highest bit of the mantissa of the input parameter.
[0083] For example, using all bits of the first intermediate operand to represent the magnitude of the value of the significant part of the mantissa of the first source operand is equivalent to using all bits to encode the mantissa of the first source operand.
[0084] Figure 3 A schematic diagram of the relationship between a first source operand and a first intermediate operand provided for at least one embodiment of the present disclosure.
[0085] like Figure 3 As shown, first, the mantissa part (L-1 bits) of the first source operand is padded with hidden bits to obtain the effective mantissa part, as shown in Figure 3 As shown, the most significant bit of the effective mantissa is 1.
[0086] Afterwards, the first bit of the effective mantissa part is used as the first bit of the first intermediate operand, the second bit of the effective mantissa part is used as the second bit of the first intermediate operand, ..., the Lth bit of the effective mantissa part is used as the Lth bit of the first intermediate operand, and the L+1th bit to the highest bit of the first intermediate operand are all 0, thereby obtaining the first intermediate operand.
[0087] Here, the first bit of the effective mantissa part is the least significant bit, and the Lth bit of the effective mantissa part is the Lth bit in the direction from the low bit to the high bit.
[0088] For example, in step S104, since the first intermediate operand is of the second integer type and the second intermediate operand is also of the second integer type, integer multiplication of the second integer type can be directly performed on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, which is also of the second integer type.
[0089] For example, the integer multiplication of the first intermediate operand and the second intermediate operand may be performed using a multiplier of the second integer type, such as a U-bit multiplier, where U is a positive integer and the bit width of the second integer type.
[0090] The mantissa multiplication result reflects the relative magnitude of the product of the first source operand and the second source operand.
[0091] For example, the precision type of the destination operand is the same as the precision type of the first source operand, for example, the first source operand is FP64, and the type of the destination operand is also FP64. For example, the type of the destination operand is the same as the type of the first source operand, for example, both are floating point numbers, but the precision of the destination operand can be higher than the precision of the first source operand, for example, the mantissa significant bit width of the destination operand is greater than the mantissa significant bit width of the first source operand.
[0092] For example, a processor or chip cannot support FP64 multiplication and may not even be able to support the FP64 precision format. That is, it is very likely that in a processor or chip that applies the data processing method provided by at least one embodiment of the present disclosure, the destination operand cannot be directly represented in a high-precision floating-point format. At this time, the destination operand can be represented by three independent integer parameters, and the three independent integer parameters include a first integer parameter representing the mantissa part of the destination operand, a second integer parameter representing the sign bit of the destination operand, and a third integer parameter representing the exponent part of the destination operand.
[0093] For example, in this embodiment, step S204 may include: using the mantissa multiplication result directly as the first integer parameter; determining the second integer parameter according to the sign bit of the first source operand and the sign bit of the second operand; and using the exponent part of the first source operand as the third integer parameter.
[0094] Thus, three integers can be used to represent a multiplication result with higher precision, thereby enabling the processor or chip to support multiplication calculations of floating-point numbers and integers with higher precision.
[0095] For example, the first source operand and the second source operand may both be positive numbers. For example, in the Resize operator, the first source operand may beX frac , which is a positive floating point number, the second source operand is, for example, x D , which is a positive integer, the sign bit can be ignored at this time, and the default destination operand sign bit is a positive sign bit.
[0096] Of course, the present disclosure is not limited to this. The first source operand can be a positive number or a negative number, and the second source operand can also be a positive number or a negative number. In this case, the sign bit of the multiplication result (e.g., the destination operand) can be obtained based on the sign bit of the first source operand and the sign bit of the second source operand.
[0097] For example, determining the second integer parameter based on the sign bit of the first source operand and the sign bit of the second operand may include: in response to the sign bit of the first source operand and the sign bit of the second source operand being the same, determining the second integer parameter to be a first preset value, wherein the first preset value indicates that the destination operand is a positive number; in response to the sign bit of the first source operand and the sign bit of the second source operand being different, determining the second integer parameter to be a second preset value, wherein the second preset value indicates that the destination operand is a negative number.
[0098] For example, the first preset value may be 0, and the second preset value may be 1.
[0099] For example, in some embodiments, the destination operand is a normalized floating point number, such as a processor or chip that supports floating point numbers of the destination operand precision. In this case, the mantissa multiplication result representing the relative size of the multiplication result needs to be converted to a standard floating point format.
[0100] For example, in this embodiment, step S105 may include: determining the mantissa part and the exponent part of the destination operand according to the mantissa multiplication result; and determining the sign bit of the destination operand according to the sign bit of the first source operand and the sign bit of the second source operand.
[0101] For example, determining the mantissa part and the exponent part of the destination operand based on the mantissa multiplication result may include: determining the valid part from the mantissa multiplication result, wherein the starting point of the valid part is the first 1 appearing in the mantissa multiplication result along a preset direction, and the preset direction is the direction from high bits to low bits in the mantissa multiplication result; determining the mantissa intermediate result based on the valid part, wherein the bit width of the mantissa intermediate result is less than or equal to L; shifting the mantissa intermediate result according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0102] For example, there are the following three embodiments for determining the mantissa part and the exponent part of the destination operand.
[0103] For example, in some embodiments, determining the valid part from the mantissa multiplication result may include: starting from the starting point, continuously selecting at most L bits from the mantissa multiplication result along a preset direction as the valid part.
[0104] For example, in an embodiment, determining the mantissa intermediate result according to the valid part may include: using the valid part as the mantissa intermediate result.
[0105] For example, in this embodiment, up to L bits are selected from the mantissa multiplication result starting from the starting point as the mantissa intermediate result, and the remaining part is discarded. The implementation method is relatively simple.
[0106] For example, when the number of bits between the starting point and the lowest bit of the mantissa multiplication result is greater than or equal to L, L bits are selected continuously starting from the starting point as the mantissa intermediate result.
[0107] For example, when the number of bits from the starting point to the lowest bit of the mantissa multiplication result is less than L, for example, L', where L' is a positive integer and less than L, then L' bits are selected continuously from the starting point as the mantissa intermediate result.
[0108] Figure 4A A schematic diagram of an effective portion provided for at least one embodiment of the present disclosure.
[0109] For example, in other embodiments, Figure 4A As shown, the starting point of the effective part is the first 1 that appears in the mantissa multiplication result along the direction from high to low in the mantissa multiplication result, and the end point is the last 1 that appears in the mantissa multiplication result along the preset direction.
[0110] For example, in this embodiment, determining the mantissa intermediate result according to the valid part may include: performing a rounding operation on the valid part according to a preset rounding rule to obtain the mantissa intermediate result.
[0111] Since higher-order 0s have no effect on precision, selecting the effective part from the mantissa multiplication result first can more accurately obtain the part that has a substantial impact on precision; further, since the length of the effective part is not necessarily equal to L, when the length of the effective part is greater than L, the effective part is converted into an L-bit mantissa intermediate result through rounding operation, which can more accurately represent the mantissa part of the floating-point product result, and the mantissa intermediate result is closer to the mantissa multiplication result.
[0112] For example, in at least one embodiment of the present disclosure, in response to the length N of the effective part being less than or equal to L, the effective part is directly used as the mantissa intermediate result, wherein N is a positive integer greater than 1; in response to the length N of the effective part being greater than L, the mantissa intermediate result is determined according to the L+1th bit in the effective part, wherein when the length N of the effective part is greater than L, the bit width of the mantissa intermediate result is equal to L, the highest bit in the effective part is used as the 1st bit, and the L+1th bit in the effective part is the L+1th bit starting from the 1st bit along the preset direction.
[0113] For example, in at least one embodiment of the present disclosure, determining the intermediate result of the mantissa based on the L+1th bit in the effective part may include: in response to the L+1th bit being the first value, discarding the L+1th to Nth bits of the effective part, and taking the 1st to Lth bits in the effective part as the intermediate result of the mantissa; in response to the L+1th bit being the second value, and at least one bit from the L+2th to Nth bits of the effective part is not the first value, discarding the L+1th to Nth bits of the effective part, and performing a carry operation on the Lth bit of the effective part to obtain the intermediate result of the mantissa; in response to the L+1th bit being the second value, and the L+2th to Nth bits of the effective part are all the first value, determining the intermediate result of the mantissa based on the Lth bit of the effective part.
[0114] For example, determining the intermediate result of the mantissa based on the Lth bit of the effective part may include: in response to the Lth bit of the effective part being a first value, taking the 1st to Lth bits in the effective part as the intermediate result of the mantissa; in response to the Lth bit of the effective part being a second value, discarding the L+1th to Nth bits of the effective part, and performing a carry operation on the Lth bit of the effective part to obtain the intermediate result of the mantissa.
[0115] The length N of the valid part is the number of bits of the valid part including the start point and the end point.
[0116] For example, the preset rounding rule may stipulate that when N is less than or equal to L, the effective part can be directly used as the intermediate result of the mantissa; when N is greater than L, the effective part is rounded according to the L+1th bit in the effective part to obtain the intermediate result of the mantissa.
[0117] For example, the first value may be 0 and the second value may be 1.
[0118] For example, the preset rounding rule may stipulate that, when N is greater than L, if the L+1th bit is 0, the L+1th to Nth bits of the effective part are discarded, and the 1st to Lth bits in the effective part are used as the intermediate result of the mantissa; if the L+1th bit is 1, since the Nth bit must be 1, at least one bit from the L+2th to Nth bits of the effective part must be 1, then the L+1th to Nth bits of the effective part are discarded, and a carry operation is performed on the Lth bit, that is, 1 is added to the Lth bit to obtain the intermediate result of the mantissa.
[0119] Of course, the preset rounding rule can be set as needed. The present disclosure is not limited to the use of the rounding rules described in the above embodiment, which will not be described one by one here.
[0120] Figure 4B A schematic diagram of an effective portion provided for at least one embodiment of the present disclosure.
[0121] For example, in other embodiments, Figure 4B As shown, the starting point of the effective part is the first 1 that appears in the mantissa multiplication result from the high bit to the low bit in the mantissa multiplication result, and the end point is the lowest bit in the mantissa multiplication result.
[0122] For example, in this embodiment, determining the mantissa intermediate result according to the valid part may include: performing a rounding operation on the valid part according to a preset rounding rule to obtain the mantissa intermediate result.
[0123] Similar to the above embodiment, since higher-order 0s have no effect on precision, selecting the effective part from the mantissa multiplication result first can more accurately obtain the part that has a substantial impact on precision; further, since the length of the effective part is not necessarily equal to L, the effective part is converted into an L-bit mantissa intermediate result through rounding operation to more accurately represent the mantissa part of the floating-point product result.
[0124] For example, the preset rounding rule may stipulate that when the L+1th bit of the effective part is 0, the L+1th bit to the Nth bit of the effective part is discarded, and the 1st bit to the Lth bit in the effective part is used as the intermediate result of the mantissa; when the L+1th bit of the effective part is 1, if any bit from the L+2th bit to the Nth bit of the effective part is 1 at this time, a carry operation is performed, that is, 1 is added to the Lth bit, and the intermediate result of the mantissa is obtained. If the L+2th bit to the Nth bit of the effective part are all 0 and the Lth bit is 0 at this time, the L+1th bit to the Nth bit of the effective part are discarded, and the 1st bit to the Lth bit in the effective part are used as the intermediate result of the mantissa. If the L+2th bit to the Nth bit of the effective part are all 0 and the Lth bit is 1 at this time, the L+1th bit to the Nth bit of the effective part are discarded, and the 1st bit to the Lth bit in the effective part are used as the intermediate result of the mantissa.
[0125] For more information about “rounding the valid part according to the preset rounding rule to obtain the intermediate result of the mantissa”, please refer to the relevant description of the above embodiment, which will not be repeated here.
[0126] For example, in some embodiments, the destination operand is the product of the first source operand and the second source operand.
[0127] For example, in this embodiment, the mantissa intermediate result is shifted according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand, which may include: shifting the mantissa intermediate result according to the value of the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0128] For example, shifting the mantissa intermediate result according to the value E of the exponent part of the first source operand is equivalent to multiplying the mantissa intermediate result by 2 E The shifted result is normalized to obtain the mantissa and exponent of the destination operand.
[0129] For example, in some embodiments, the destination operand is the rounded result after further rounding operation is performed on the product result of the first source operand and the second source operand, for example, the rounding operation indicates to perform a floor operation on the product result. For example, the first source operand can be the scaling factor in the Resize operator. X frac The second source operand can be the coordinates of the element on the image before scaling in the Resize operator. x D , the rounding operation is performed on the product result floor (*).
[0130] For example, in this embodiment, the mantissa intermediate result is shifted according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand, which may include: shifting the mantissa intermediate result according to the value of the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0131] For the floor operation, when the value E of the exponent part is greater than 0, the intermediate result of the mantissa is enlarged, and the overflow mantissa will not appear; when the value E of the exponent part is less than 0, some bits may become the overflow mantissa (the least significant bit of the mantissa flows out from the right end of the mantissa field), but because it is a floor operation, these overflow mantissa parts are also discarded, so they have no effect on the accuracy. Therefore, when the further rounding operation is a floor operation, no additional operation is required for the product result of the first source operand and the second source operand.
[0132] For example, in some embodiments, the destination operand is a rounded result after a further rounding operation is performed on a product result of a first source operand and a second source operand, for example, the rounding operation indicates to perform a round-up operation on the product result.
[0133] For example, in this embodiment, the mantissa intermediate result is shifted according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand, which may include: shifting the mantissa intermediate result according to the value of the exponent part of the first source operand to obtain the shift result and the overflow mantissa part generated by the shift; in response to the overflow mantissa parts being all the first value, obtaining the mantissa part and the exponent part of the destination operand according to the shift result; in response to the overflow mantissa parts not being all the first value, performing a carry operation on the shift result and obtaining the mantissa part and the exponent part of the destination operand according to the carry result.
[0134] For the rounding up operation, when the value E of the exponent part is greater than 0, the intermediate result of the mantissa is enlarged, and the overflow mantissa will not appear. Therefore, the mantissa and exponent of the destination operand can be obtained according to the shift result, for example, the mantissa and exponent of the destination operand are obtained by normalizing the shift result. When the value E of the exponent part is less than 0, some bits may become the overflow mantissa (the least significant bit of the mantissa flows out from the right end of the mantissa field). If the overflow mantissa, that is, the bits flowing out from the right end of the mantissa field are all 0, the mantissa and exponent of the destination operand can be obtained according to the shift result, for example, the mantissa and exponent of the destination operand are obtained by normalizing the shift result; if the overflow mantissa is not all 0, a carry operation is performed on the shift result, for example, 1 is added to the lowest bit of the shift result and the mantissa and exponent of the destination operand are obtained according to the carry result.
[0135] Of course, in addition to rounding up and rounding down operations, other rounding operations can also be set, such as rounding to the nearest integer, rounding to zero, mean rounding, etc. Those skilled in the art can set them as needed, and the present disclosure does not make specific restrictions on this.
[0136] For example, determining the sign bit of the destination operand based on the sign bit of the first source operand and the sign bit of the second operand may include: in response to the sign bit of the first source operand and the sign bit of the second source operand being the same, determining the sign bit of the destination operand to be a positive sign bit, wherein the positive sign bit indicates that the destination operand is a positive number; in response to the sign bit of the first source operand and the sign bit of the second source operand being different, determining the sign bit of the destination operand to be a negative sign bit, wherein the negative sign bit indicates that the destination operand is a negative number.
[0137] For example, a positive sign bit can be represented by 0 and a negative sign bit can be represented by 1.
[0138] The following takes the case where the type of the first source operand is FP64, the type of the second source operand is INT32 (32-bit signed integer), and the second integer type is UINT64 as an example to specifically illustrate the execution process of the data processing method provided by at least one embodiment of the present disclosure.
[0139] As mentioned above, the effective bit width of the mantissa part of FP64 is 53. Since "the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L", the bit width of the maximum value of the second source operand is 10, and the value of the second source operand needs to be less than 2048.
[0140] First, referring to step S101, a first source operand and a second source operand are received. For example, the first source operand can be a scaling factor in a Resize operator. X frac The second source operand can be the coordinates of the element on the image before scaling in the Resize operator. x D .
[0141] Afterwards, referring to step S102, the mantissa part of the first source operand is represented by the first intermediate operand of type UINT64. Specifically, the hidden bits in the mantissa part of the first source operand can be filled first to obtain the effective mantissa part, and then the 53 bits of the effective mantissa part are used as the first to the 53rd bits of the first intermediate operand, for example, the lowest bit (the first bit) of the effective mantissa part is used as the lowest bit (the first bit) of the first intermediate operand, and the second bit of the effective mantissa part is used as the second bit of the first intermediate operand, and so on.
[0142] Referring to step S103, the second source operand is converted from INT32 type to UINT64. It should be noted that during the conversion, the numerical portion of the second source operand is retained in the second intermediate operand, and the sign bit of the second source operand can be stored separately for subsequent determination of the sign bit of the destination operand.
[0143] Referring to step S104, UINT64 multiplication is performed on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result n, which is also of UINT64 type.
[0144] Referring to step S105, the mantissa multiplication result n represents the relative size of the mantissa part, and some rounding, shifting and other operations need to be performed on it to obtain the absolute size of the product result of the first source operand and the second source operand.
[0145] For example, firstly, the effective part can be determined from the mantissa multiplication result n, and then the mantissa intermediate result can be determined according to the effective part. Specifically, any one of the above three implementation modes can be adopted.
[0146] Here, we take the starting point of the valid part as the first 1 appearing in the preset direction in the mantissa multiplication result n, and the end point of the valid part as the lowest bit of the mantissa multiplication result n as an example to illustrate the process of obtaining the mantissa intermediate result.
[0147] Table 2 shows the preset rounding rules for converting the effective part into the mantissa intermediate result provided by at least one embodiment of the present disclosure.
[0148] Table 2 Preset rounding rules
[0149]
[0150] As shown in Table 2, the preset rounding rule stipulates that if the length N of the effective part is less than or equal to 53, the effective part is directly used as the intermediate result of the mantissa. The preset rounding rule also stipulates that if the length N of the effective part is greater than 53, when the 54th bit is 0, the 54th to the Nth bit of the effective part are discarded and the first 53 bits are retained as the intermediate result of the mantissa; when the 54th bit is 1 and the 55th to the Nth bit are not all 0, the first 53 bits of the effective part are retained and the 53th bit is added by 1 as the intermediate result of the mantissa; when the 54th bit is 1 and the 55th to the Nth bit are all 0, if the 53rd bit is 0, the 54th to the Nth bit of the effective part are discarded and the first 53 bits are retained as the intermediate result of the mantissa, and if the 53rd bit is 1, the first 53 bits of the effective part are retained and the 53th bit is added by 1 as the intermediate result of the mantissa.
[0151] After obtaining the mantissa intermediate result, the mantissa intermediate result is shifted according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0152] For example, the mantissa intermediate result is shifted according to the value E of the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
[0153] For the specific shift processing process, reference may be made to the relevant description of the aforementioned embodiment, and repeated parts will not be repeated here.
[0154] In addition, if the first source operand and the second source operand are not restricted to positive integers, the sign bit of the destination operand needs to be determined based on the sign bit of the first source operand and the sign bit of the second operand. The specific process is as described above and will not be repeated here.
[0155] Therefore, through the above process, UINT64 multiplication can be used to simulate FP64 multiplication in software, to achieve high-precision multiplication, reduce the precision error of integer and floating-point multiplication, improve the accuracy of operators that apply this method, such as the Resize operator, and avoid scaling errors.
[0156] The data processing method provided by at least one embodiment of the present disclosure can be applied to different systems or devices, such as Figure 8 The electronic device 500 shown. The electronic device 500 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an AR device, a VR device, a vehicle terminal, etc., and can also be a server, etc. The data processing method provided in at least one embodiment of the present disclosure can be applied to the electronic device 500 involving CPU, high performance computing (High Performance Computing, referred to as HPC) and artificial intelligence (Artificial Intelligence, AI) and other scenarios related to floating point and integer multiplication, such as scalar calculation units, vector calculation units, matrix calculation units and tensor calculation units. Of course, the present disclosure is not limited to this, and any scenario, device, apparatus, etc. involving floating point and integer multiplication can adopt the data processing method provided by at least one embodiment of the present disclosure.
[0157] For example, refer to Figure 8 The electronic device 500 shown, when implementing the data processing method provided by at least one embodiment of the present disclosure, the processing device 501 performs various appropriate actions and processes according to the non-temporary computer-readable instructions stored in the memory to implement the data processing method. For example, the first source operand and the second source operand are stored in a memory, such as a register, a cache or a memory. When floating-point and integer multiplication is required, the first source operand and the second source operand are read from the memory, and the processing device 501 performs floating-point and integer multiplication and other processes on the first source operand and the second source operand according to the data processing method described in at least one embodiment of the present disclosure to obtain the destination operand. The destination operand can be transferred to the corresponding operator for use again, or transferred to the memory for storage.
[0158] At least one embodiment of the present disclosure further provides a data processing method. Figure 5 A schematic flowchart of a data processing method provided for at least one embodiment of the present disclosure.
[0159] like Figure 5 As shown, the data processing method provided by at least one embodiment of the present disclosure includes steps S201-S202.
[0160] For example, in step S201, a data processing instruction instructing to perform at least floating point and integer multiplication is received.
[0161] For example, a data processing instruction includes a first source operand and a second source operand as input parameters, and a destination operand as an output parameter.
[0162] For example, the type of the first source operand is a floating point number type, and the type of the second source operand is a first integer type.
[0163] For example, the data processing instruction may be used to perform only the calculation of floating point number and integer multiplication, and in this case the destination operand is the product result of the first source operand and the second source operand.
[0164] For example, in addition to performing the calculation of floating-point number and integer multiplication, the data processing instruction may also be superimposed with other operations, such as further calculation operations, such as rounding operations, on the multiplication result of floating-point number and integer multiplication.
[0165] For example, the data processing instruction may further perform a rounding operation on the multiplication result of the floating point number and the integer multiplication, and use the result after the rounding operation as the destination operand.
[0166] Of course, the data processing instructions may also include more or other computing operations, and the present disclosure does not impose specific limitations on this.
[0167] For example, the data processing instruction may be a machine instruction, or the data processing instruction may be a microinstruction. For example, the data processing instruction may be an instruction or microinstruction for performing floating point and integer multiplication. For example, the data processing instruction may be the Resize operator as described above, which performs floor ( X frac · x D ) microinstructions for operations.
[0168] For example, the first source operand is a tensor of a floating point number or a floating point precision type, such as FP32, FP64, etc. For example, the second source operand is an integer or an integer tensor, such as UINT32, UINT64, etc.
[0169] The types of the first source operand and the second source operand can be set as needed, and the present disclosure does not impose any specific limitation on this.
[0170] In step S202, after parsing the data processing instruction, the data processing instruction is executed using the operation unit.
[0171] For example, after receiving a data processing instruction, the processor parses the data processing instruction, such as decoding the data processing instruction, generates a microinstruction and sends the microinstruction to an instruction dispatch unit; the instruction dispatch unit sends the microinstruction to a corresponding scheduling queue according to the microinstruction category; in response to the microinstruction, when the first source operand and the second source operand (all or the required part) are prepared, the operation unit reads the data and executes the relevant operations of the data processing instruction.
[0172] For example, the operation unit may include hardware involved in executing data processing instructions, such as a multiplier, a register, a queue, an ALU (Arithmetic Logic Unit), etc.
[0173] For example, step S202 may include: using a first intermediate operand of a second integer type to represent the mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; converting the second source operand to the second integer type to obtain a second intermediate operand; performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; and obtaining a destination operand based on the mantissa multiplication result.
[0174] Regarding "using the first intermediate operand of the second integer type to represent the mantissa portion of the first source operand", reference may be made to the relevant contents of the aforementioned step S102, which will not be repeated here.
[0175] Regarding "converting the second source operand into a second integer type to obtain a second intermediate operand", reference may be made to the relevant contents of the aforementioned step S103, which will not be repeated here.
[0176] Regarding “performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result”, reference may be made to the relevant contents of the aforementioned step S104 and will not be repeated here.
[0177] Regarding "obtaining the destination operand according to the mantissa multiplication result", reference may be made to the relevant contents of the aforementioned step S105, which will not be repeated here.
[0178] The data processing method provided in at least one embodiment of the present disclosure can achieve technical effects similar to those of the aforementioned data processing method, and the repeated parts will not be repeated.
[0179] At least one embodiment of the present disclosure further provides a data processing device. Figure 6 A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure.
[0180] like Figure 6 As shown, the data processing device 300 includes an acquisition module 301 , a first conversion module 302 , a second conversion module 303 , a multiplication calculation module 304 and an output module 305 .
[0181] For example, the acquisition module 301 is configured to receive a first source operand and a second source operand as input parameters. For example, the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type.
[0182] For example, the first conversion module 302 is configured to represent the mantissa portion of the first source operand using a first intermediate operand of the second integer type.
[0183] For example, the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, where L is a positive integer.
[0184] For example, the second conversion module 303 is configured to convert the second source operand into a second integer type to obtain a second intermediate operand.
[0185] For example, the multiplication calculation module 304 is configured to perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type.
[0186] For example, the output module 305 is configured to obtain a destination operand as an output parameter according to the mantissa multiplication result.
[0187] For example, the destination operand can be directly output from the data processing device 300 and transmitted to other components that need to use the output parameter, such as a storage device or other computing device.
[0188] For example, the acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305 include codes and programs stored in the memory. The acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305 are implemented as a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities. The processing unit can be a general-purpose processor, and can also be a single-chip microcomputer, a microprocessor, a digital signal processor, a dedicated image processing chip, or a field programmable logic array, etc. The acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305 execute the code and program to implement some or all of the functions of the acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305 as described above. For example, the acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305 may be a circuit board or a combination of multiple circuit boards, for implementing the functions described above. In the embodiment of the present application, the circuit board or the combination of multiple circuit boards may include: (1) one or more processors; (2) one or more non-temporary memories connected to the processor; and (3) firmware stored in the memory and executable by the processor.
[0189] It should be noted that the acquisition module 301 can be used to implement Figure 2 In step S101 shown in FIG. 1 , the first conversion module 302 may be used to implement Figure 2 In step S102, the second conversion module 303 can be used to implement Figure 2 In step S103, the multiplication calculation module 304 can be used to implement Figure 2 In step S104, the output module 305 can be used to implement Figure 2 Step S105 shown. Therefore, for the specific description of the functions that can be implemented by the acquisition module 301, the first conversion module 302, the second conversion module 303, the multiplication calculation module 304 and the output module 305, reference can be made to the relevant description of steps S301 to S305 in the embodiment of the above-mentioned data processing method, and the repeated parts will not be repeated. In addition, the data processing device 300 can achieve technical effects similar to those of the above-mentioned data processing method, which will not be repeated here.
[0190] It should be noted that in at least one embodiment of the present disclosure, the data processing device 300 may include more or fewer circuits or units, and the connection relationship between the various circuits or units is not limited and can be determined according to actual needs. The specific configuration of each circuit or unit is not limited and can be composed of analog devices according to circuit principles, or can be composed of digital chips, or in other applicable ways.
[0191] For example, the data processing device 300 may be implemented in hardware, software, or a combination of hardware and software, and the present disclosure does not impose any specific limitations on this.
[0192] The data processing method provided by at least one embodiment of the present disclosure can achieve a technical effect similar to the data processing method described above, and will not be described in detail here.
[0193] Figure 7 A schematic structural diagram of a processor provided in at least one embodiment of the present disclosure. Figure 7 As shown, the processor 400 includes an instruction parsing unit 401 and an operation unit 402 .
[0194] For example, the instruction parsing unit 401 is used to receive and parse data processing instructions.
[0195] For example, the data processing instruction includes a first source operand and a second source operand as input parameters, and a destination operand as an output parameter, the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type.
[0196] For example, the operation unit 402 executes the data processing instruction after the instruction parsing unit parses the data processing instruction.
[0197] For example, when the operation unit 402 executes a data processing instruction, it includes performing the following operations: using a first intermediate operand of a second integer type to represent the mantissa part of the first source operand, wherein the bit width of the second integer type is greater than the effective bit width L of the mantissa part of the first source operand, and the bit width of the maximum value of the second source operand is less than the difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; converting the second source operand to the second integer type to obtain a second intermediate operand; performing integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; and obtaining the destination operand based on the mantissa multiplication result.
[0198] Specifically, when the upper-layer software based on the processor (for example, AI applications, HPC applications, and scientific computing applications, etc.) can send data processing instructions for computing processing to the processor (for example, CPU or GPU) through a uniformly encapsulated function library, the data processing instruction can carry a first source operand and a second source operand as input parameters; when the processor receives the data processing instruction, the instruction parsing unit 401 parses the data processing instruction to obtain the first source operand and the second source operand as input parameters, and the processor schedules the operation unit to perform the data processing task for the first source operand and the second source operand as input parameters. For example, after parsing the data processing instruction, the processor can store the first source operand and the second source operand in the data processing instruction into a register or memory, so that when the operation unit 402 performs computing processing, it can obtain the input parameters from the register or memory.
[0199] Regarding the specific process of using the operation unit 402 to execute the data processing instruction, reference may be made to steps S102 to S105 in the aforementioned data processing method, and the repeated parts will not be repeated here.
[0200] Figure 8 The following is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 8 As shown, the electronic device 500 is suitable for implementing the data processing method provided by the embodiment of the present disclosure. It should be noted that Figure 8 The components of the electronic device 500 shown are merely exemplary and non-limiting. The electronic device 500 may also have other components according to actual application requirements.
[0201] like Figure 8 As shown, the electronic device 500 may include a processing device (eg, a central processing unit, a graphics processing unit, etc.) 501, which may perform various appropriate actions and processes according to non-transitory computer-readable instructions stored in a memory to implement various functions.
[0202] For example, when the computer readable instructions are executed by the processing device 501, one or more steps in the data processing method described in any of the above embodiments may be executed. It should be noted that for a detailed description of the processing process of the data processing method, reference may be made to the relevant description in the above data processing method embodiments.
[0203] For example, the memory 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) 503 and / or cache memory (cache), etc. For example, computer-readable instructions may be loaded from storage device 508 into random access memory (RAM) 503 to run computer-readable instructions. Non-volatile memory may include, for example, read-only memory (ROM) 502, hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. Various applications and various data, such as style images, and various data used and / or generated by applications, etc., may also be stored in the computer-readable storage medium.
[0204] For example, the processing device 501 , the ROM 502 , and the RAM 503 are connected to one another via a bus 504 . An input / output (I / O) interface 505 is also connected to the bus 504 .
[0205] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, a flash memory, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other electronic devices wirelessly or by wire to exchange data. Although Figure 8 An electronic device 500 having various devices is shown, but it should be understood that it is not required to implement or have all the devices shown, and the electronic device 500 may alternatively implement or have more or fewer devices. For example, the processing device 501 can control other components in the electronic device 500 to perform the desired functions. The processing device 501 can be a device with data processing capabilities and / or program execution capabilities such as a central processing unit (CPU), a tensor processing unit (TPU) or a graphics processing unit GPU. The central processing unit (CPU) can be an X86, ARM, RISC-V architecture, etc. The GPU can be directly integrated into the SOC, directly integrated into the motherboard, or built into the north bridge chip of the motherboard.
[0206] Fig. 9 A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure. Fig. 9As shown, the storage medium 600 may be a non-transitory computer-readable storage medium, and one or more computer-readable instructions 601 may be non-transitory stored on the storage medium 600. For example, when the computer-readable instructions 601 are executed by a processor, one or more steps in the data processing method described above may be executed.
[0207] For example, the storage medium 600 may be applied to the electronic device 500 described above. For example, the storage medium 600 may include a storage device 508 in the electronic device 500 .
[0208] For example, the storage device 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), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer-readable instructions may be stored on the computer-readable storage medium, and the processor may execute the computer-readable instructions to implement various functions of the processor. Various applications and various data may also be stored in the storage medium.
[0209] For example, the storage medium may include a memory card of a smart phone, a storage component of a tablet computer, a hard disk of a personal computer, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), flash memory, or any combination of the above storage media, or other applicable storage media.
[0210] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0211] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0212] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0213] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0214] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0215] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0216] There are a few points to note about this disclosure:
[0217] (1) The drawings of the embodiments of the present disclosure only relate to the structures related to the embodiments of the present disclosure. Other structures may refer to the general design.
[0218] (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.
[0219] 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 data processing method, comprising: Receiving a first source operand and a second source operand as input parameters from a storage component, wherein the type of the first source operand is a floating point type, the type of the second source operand is a first integer type, the received first source operand and the second source operand are cached in a register, the storage component includes a memory, a cache or other registers, and the first source operand and the second source operand include parameters for floating point and integer multiplication in the field of image processing, text processing, video processing or speech processing; Representing the mantissa portion of the first source operand using a first intermediate operand of a second integer type, wherein the bit width of the second integer type is greater than an effective bit width L of the mantissa portion of the first source operand, and the bit width of the maximum value of the second source operand is less than a difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; Converting the second source operand to the second integer type to obtain a second intermediate operand; Using a multiplier of a second integer type, perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; According to the mantissa multiplication result, a destination operand as an output parameter is obtained.
2. The data processing method according to claim 1, wherein: Representing a mantissa portion of the first source operand using a first intermediate operand of a second integer type, comprising: Filling the hidden bits in the mantissa part of the first source operand to obtain a valid mantissa part; The L bits of the effective mantissa part are used as the first bit to the Lth bit of the first intermediate operand, wherein the first bit of the first intermediate operand is the least significant bit.
3. The data processing method according to claim 1, wherein: The destination operand is represented by three independent integer parameters, the three independent integer parameters including a first integer parameter representing a mantissa portion of the destination operand, a second integer parameter representing a sign bit of the destination operand, and a third integer parameter representing an exponent portion of the destination operand, According to the mantissa multiplication result, the destination operand is obtained, including: Using the mantissa multiplication result directly as the first integer parameter; Determining the second integer parameter according to the sign bit of the first source operand and the sign bit of the second source operand; The exponent portion of the first source operand is used as the third integer parameter.
4. The data processing method according to claim 1, wherein: The destination operand is a floating point number, According to the mantissa multiplication result, the destination operand is obtained, including: Determining a mantissa part and an exponent part of the destination operand according to the mantissa multiplication result; The sign bit of the destination operand is determined according to the sign bit of the first source operand and the sign bit of the second operand.
5. The data processing method according to claim 4, wherein: Determining a mantissa part and an exponent part of the destination operand according to the mantissa multiplication result includes: Determine a valid part from the mantissa multiplication result, wherein the starting point of the valid part is the first 1 that appears in the mantissa multiplication result along a preset direction, and the preset direction is the direction from high to low bits in the mantissa multiplication result; Determine a mantissa intermediate result according to the valid part, wherein a bit width of the mantissa intermediate result is less than or equal to L; The mantissa intermediate result is shifted according to the exponent part of the first source operand to obtain the mantissa part and the exponent part of the destination operand.
6. The data processing method according to claim 5, wherein: The end point of the effective part is the last 1 that appears in the mantissa multiplication result along the preset direction, or the end point of the effective part is the lowest bit in the mantissa multiplication result, Determining a mantissa intermediate result according to the valid part includes: The effective part is rounded according to a preset rounding rule to obtain the intermediate result of the mantissa.
7. The data processing method according to claim 6, wherein: The effective part is rounded according to a preset rounding rule to obtain the intermediate result of the mantissa, including: In response to the length N of the effective part being less than or equal to L, directly using the effective part as the mantissa intermediate result; In response to the length N of the effective part being greater than L, the mantissa intermediate result is determined according to the L+1th bit in the effective part, wherein when the length N of the effective part is greater than L, the bit width of the mantissa intermediate result is equal to L, the highest bit in the effective part is taken as the 1st bit, and the L+1th bit in the effective part is the L+1th bit starting from the 1st bit along the preset direction.
8. The data processing method according to claim 7, wherein: Determining the mantissa intermediate result according to the L+1th bit in the effective part includes: In response to the L+1th bit in the effective part being the first value, discarding the L+1th bit to the Nth bit in the effective part, and using the 1st bit to the Lth bit in the effective part as the mantissa intermediate result; In response to the L+1th bit in the effective part being the second value, and at least one bit among the L+2th bit to the Nth bit of the effective part being not the first value, discarding the L+1th bit to the Nth bit of the effective part, and performing a carry operation on the Lth bit of the effective part to obtain the mantissa intermediate result; In response to the L+1th bit in the effective part being the second value, and the L+2th bit to the Nth bit of the effective part being the first value, the mantissa intermediate result is determined according to the Lth bit of the effective part.
9. The data processing method according to claim 5, wherein: Determining a significant portion from the mantissa multiplication result comprises: Starting from the starting point, continuously selecting at most L bits from the mantissa multiplication result along the preset direction as the valid part; Determining a mantissa intermediate result according to the valid part includes: The effective part is taken as the mantissa intermediate result.
10. The data processing method according to claim 5, wherein: The destination operand is the product of the first source operand and the second source operand, The shift processing includes shifting the mantissa intermediate result according to the value of the exponent portion of the first source operand.
11. The data processing method according to claim 5, wherein: The destination operand is a rounding result after further rounding operation is performed on the product result of the first source operand and the second source operand, In response to the rounding operation indicating to perform a floor operation on the product result, the shifting process includes shifting the mantissa intermediate result according to a value of an exponent part of the first source operand.
12. The data processing method according to claim 5, wherein: The destination operand is a rounding result after further rounding operation is performed on the product result of the first source operand and the second source operand, In response to the rounding operation instruction, performing a rounding operation on the product result, the shifting process includes: Shifting the mantissa intermediate result according to the value of the exponent part of the first source operand to obtain a shift result and an overflow mantissa part generated by the shift; In response to the overflow mantissa parts being all the first value, obtaining the mantissa part and the exponent part of the destination operand according to the shift result; In response to the overflow mantissa part not being entirely the first value, a carry operation is performed on the shift result and a mantissa part and an exponent part of the destination operand are obtained according to the carry result.
13. The data processing method according to claim 4, wherein: Determining the sign bit of the destination operand according to the sign bit of the first source operand and the sign bit of the second operand includes: In response to the sign bit of the first source operand being the same as the sign bit of the second source operand, determining that the sign bit of the destination operand is a positive sign bit, wherein the positive sign bit indicates that the destination operand is a positive number; In response to the sign bit of the first source operand being different from the sign bit of the second source operand, the sign bit of the destination operand is determined to be a negative sign bit, wherein the negative sign bit indicates that the destination operand is a negative number.
14. A data processing method, comprising: A data processing instruction indicating at least performing floating point and integer multiplication is received, wherein the data processing instruction includes a first source operand and a second source operand as input parameters, and a destination operand as an output parameter, the first source operand is a floating point type, the second source operand is a first integer type, the received first source operand and the second source operand are cached in a register, and the first source operand and the second source operand include parameters for performing floating point and integer multiplication in the field of image processing, text processing, video processing, or speech processing, After parsing the data processing instruction, executing the data processing instruction using a computing unit, Wherein, using the computing unit to execute the data processing instruction includes: Representing the mantissa portion of the first source operand using a first intermediate operand of a second integer type, wherein the bit width of the second integer type is greater than an effective bit width L of the mantissa portion of the first source operand, and the bit width of the maximum value of the second source operand is less than a difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; Converting the second source operand to the second integer type to obtain a second intermediate operand; Using a multiplier of a second integer type, perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; The destination operand is obtained according to the mantissa multiplication result.
15. A processor, comprising an instruction parsing unit and an operation unit, wherein: The instruction parsing unit is used to receive and parse a data processing instruction, wherein the data processing instruction includes a first source operand and a second source operand as input parameters from a storage component, and a destination operand as an output parameter, the type of the first source operand is a floating point type, the type of the second source operand is a first integer type, the received first source operand and the second source operand are cached in a register, the storage component includes a memory, a cache or other registers, the first source operand and the second source operand include parameters for floating point and integer multiplication in the field of image processing, text processing, video processing or speech processing, The computing unit executes the data processing instruction after the instruction parsing unit parses the data processing instruction. The operation unit executes the data processing instruction, including performing the following operations: Representing the mantissa portion of the first source operand using a first intermediate operand of a second integer type, wherein the bit width of the second integer type is greater than an effective bit width L of the mantissa portion of the first source operand, and the bit width of the maximum value of the second source operand is less than a difference between the bit width of the second integer type and the effective bit width L, and L is a positive integer; Converting the second source operand to the second integer type to obtain a second intermediate operand; Using a multiplier of a second integer type, perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; The destination operand is obtained according to the mantissa multiplication result.
16. A data processing device, comprising: an acquisition module, configured to receive a first source operand and a second source operand as input parameters from a storage component, the type of the first source operand is a floating point type, and the type of the second source operand is a first integer type, wherein the received first source operand and the second source operand are cached in a register, the storage component includes a memory, a cache or other registers, and the first source operand and the second source operand include parameters for floating point and integer multiplication in the field of image processing, text processing, video processing or speech processing; a first conversion module, configured to represent a mantissa portion of the first source operand using a first intermediate operand of a second integer type, wherein a bit width of the second integer type is greater than an effective bit width L of the mantissa portion of the first source operand, a bit width of a maximum value of the second source operand is less than a difference between a bit width of the second integer type and the effective bit width L, and L is a positive integer; A second conversion module is configured to convert the second source operand into the second integer type to obtain a second intermediate operand; a multiplication calculation module, comprising a second integer type multiplier, configured to use the second integer type multiplier to perform integer multiplication of the second integer type on the first intermediate operand and the second intermediate operand to obtain a mantissa multiplication result, wherein the mantissa multiplication result is of the second integer type; The output module is configured to obtain a destination operand as an output parameter according to the mantissa multiplication result.
17. An electronic device comprising: A memory non-transitorily stores computer executable instructions; a processor configured to execute the computer executable instructions, Wherein, when the computer executable instructions are executed by the processor, the data processing method according to any one of claims 1-14 is implemented.
18. A non-transitory computer-readable storage medium, wherein: The non-transitory computer-readable storage medium stores computer-executable instructions, When the computer executable instructions are executed by a processor, the data processing method according to any one of claims 1 to 14 is implemented.
Citation Information
Patent Citations
System and method of floating point multiply operation processing
CN111492343A
Multiplication processor, operation processing method, chip and electronic equipment
CN117472325A
Method and system for processing floating point numbers
US20230333812A1
Fused multiply-add logic to process input operands including floating-point values and integer values
US20240134601A1
KR20230055315A
