Data processing method and device, electronic equipment and computer readable storage medium
Patent Information
- Application Number
- CN202311240518.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-09-22
AI Technical Summary
[0004]本申请实施例提供了一种数据处理方法、装置、电子设备及计算机可读存储介质,可以解决嵌入式微处理器在执行FSCALE指令的过程中,运算速度慢、功耗高的问题
[0061] This application embodiment utilizes a floating-point type conversion unit to perform the following operations on the user-input source data and corresponding target operation parameters: determining the format attributes of the source data based on its hidden bits; calculating the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, an updated value for the exponent of the source data, and sticky bits; and performing shift, rounding, and exponent update operations on the source data based on the shift values, updated values, and sticky bits to generate target data, thereby completing the target exponent operation instruction. In executing the target exponent operation instruction, this application embodiment reuses the existing floating-point type conversion unit for shift, rounding, and exponent update operations, achieving rapid execution of the target exponent operation instruction. Unlike the complex data paths of multiplication and addition units used in existing technologies to implement target exponent operation instructions, the floating-point type conversion unit used in this application embodiment has a simpler data path, improving operational efficiency and reducing processor power consumption.
Smart Images

Figure CN117193707B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of embedded microprocessor technology, and more specifically, to a data processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] Embedded microprocessors are the core component of embedded systems, directly affecting the performance of the entire system. Since the advent of microprocessors, embedded systems have developed rapidly. Embedded microprocessors undertake important tasks of control and system operation, enabling the host device to be intelligent, flexibly designed, and easy to operate.
[0003] Embedded microprocessors all have their corresponding instruction sets, and the functionality of these instruction sets determines the computer system and its basic functions built upon them. Each instruction in the instruction set corresponds to a specific functional operation that the microprocessor must perform; that is, the implementation of these instruction functions is accomplished by the physical devices within the microprocessor. The execution speed of these instructions directly affects the performance of the microprocessor. For example, the FSCALE instruction (an exponentiation instruction) can be used to perform exponentiation. Microprocessors typically execute FSCALE instructions (i.e., target exponentiation instructions) by multiplexing addition and multiplication, which results in slow processing speed and high power consumption. Summary of the Invention
[0004] This application provides a data processing method, apparatus, electronic device, and computer-readable storage medium, which can solve the problems of slow operation speed and high power consumption in embedded microprocessors when executing FSCALE instructions. The technical solution is as follows:
[0005] According to one aspect of the embodiments of this application, a data processing method is provided, the method comprising:
[0006] Obtain the source data input by the user and the target operation parameters corresponding to the source data; wherein, the source data is a floating-point number;
[0007] If the target operation parameter is an integer, perform the following operations on the source data and the target operation parameter to execute the target exponentiation operation instruction and generate the target data corresponding to the source data:
[0008] Determine the format attributes of the source data based on the hidden bits of the source data;
[0009] The calculations are performed on the source data based on the format attributes and the numerical range of the target operation parameters to generate the shift value, the updated value of the exponent of the source data, and the sticky bit of the source data.
[0010] Based on the shifted value, the updated value, and the sticky bit, the target data is generated by performing shift, rounding, and exponent update operations on the source data through the floating-point type conversion unit.
[0011] In one possible implementation, the above calculations are performed on the source data based on the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data, including:
[0012] When the format attribute is a denormalized floating-point number and the target operation parameter is negative, the absolute value of the target operation parameter is used as the shift value, and the update value of the exponent is determined according to the leading zero count of the mantissa of the source data, the bit width of the mantissa, and the target operation parameter. The sticky bit is determined according to the suffix zero count of the mantissa and the target operation parameter.
[0013] When the format attribute is a denormalized floating-point number and the target operation parameter is a positive number, the shift value is determined based on the difference between the leading zero count of the mantissa and the target operation parameter, and the update value of the exponent is determined based on the maximum value of the exponent, the leading zero count, and the target operation parameter, and the sticky position is set to zero.
[0014] When the format attribute is a denormalized floating-point number and the target operation parameter is equal to zero, the shift value and sticky position are set to zero, and the exponent is not updated.
[0015] In one possible implementation, the above method also includes:
[0016] When the format attribute is normalized floating-point number and the target operation parameter is negative, the shift value and the update value of the exponent are determined according to the bit width of the exponent and mantissa and the target operation parameter, and the sticky bit is determined according to the suffix zero count of the exponent and mantissa and the target operation parameter.
[0017] When the format attribute is normalized floating-point number and the target operation parameter is non-negative, the shift value and sticky position are set to zero, and the updated value of the exponent is determined based on the maximum value of the exponent, the exponent, and the target operation parameter.
[0018] In another possible implementation, the target data is generated by performing shift, rounding, and exponent update operations on the source data using a floating-point type conversion module, based on the shifted value, updated value, and sticky bit. This includes:
[0019] The mantissa of the source data is shifted based on the shift value to obtain the shifted mantissa;
[0020] The target mantissa is obtained by rounding the shifted mantissa based on the sticky bit.
[0021] The target data is generated by formatting and packaging the updated value of the exponent, the target mantissa, and the sign bit of the source data.
[0022] In another possible implementation, the above-mentioned format packing based on the exponent update value, the target mantissa, and the sign bit of the source data generates the target data, including:
[0023] When it is determined that the exponent of the source data needs to be updated twice based on the shift and rounding operations, the target exponent is obtained by updating the exponent based on the target mantissa.
[0024] The target data is generated by formatting and packaging the target exponent, target mantissa, and sign bit of the source data.
[0025] In another possible implementation, the above method also includes:
[0026] Based on the rounding rules corresponding to the rounding operation and the change status of the format attributes of the source data during the operation, the exception status information corresponding to the target data is generated.
[0027] In another possible implementation, the source data is a half-precision floating-point number, and the method also includes:
[0028] When the format attribute is denormalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or infinite floating-point number;
[0029] When the format attribute is denormalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is a denormalized floating-point number or zero;
[0030] When the format attribute is normalized floating point and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating point or an infinite floating point.
[0031] When the format attribute is normalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or zero.
[0032] According to another aspect of the embodiments of this application, a data processing apparatus is provided, the apparatus comprising:
[0033] The acquisition module is used to acquire the source data input by the user and the target operation parameters corresponding to the source data; wherein, the source data is a floating-point number;
[0034] The calculation module, if the target calculation parameter is an integer, performs the following calculation operations on the source data and the target calculation parameter to execute the target exponentiation operation instruction and generate the target data corresponding to the source data:
[0035] The hidden bits of the source data are used to determine the format attributes of the source data; calculations are performed on the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data; based on the shift values, update values, and sticky bits, shift operations, rounding operations, and exponent update operations are performed on the source data through the floating-point type conversion unit to generate the target data.
[0036] In one possible implementation, when the aforementioned arithmetic module performs calculations on the source data according to the format attributes and the numerical range of the target arithmetic parameters, generating shift values, updated values of the exponent of the source data, and sticky bits of the source data, it is used for:
[0037] When the format attribute is a denormalized floating-point number and the target operation parameter is negative, the absolute value of the target operation parameter is used as the shift value, and the update value of the exponent is determined according to the leading zero count of the mantissa of the source data, the bit width of the mantissa, and the target operation parameter. The sticky bit is determined according to the suffix zero count of the mantissa and the target operation parameter.
[0038] When the format attribute is a denormalized floating-point number and the target operation parameter is a positive number, the shift value is determined based on the difference between the leading zero count of the mantissa and the target operation parameter, and the update value of the exponent is determined based on the maximum value of the exponent, the leading zero count, and the target operation parameter, and the sticky position is set to zero.
[0039] When the format attribute is a denormalized floating-point number and the target operation parameter is equal to zero, the shift value and sticky position are set to zero, and the exponent is not updated.
[0040] In one possible implementation, the aforementioned computation module is also used for:
[0041] When the format attribute is normalized floating-point number and the target operation parameter is negative, the shift value and the update value of the exponent are determined according to the bit width of the exponent and mantissa and the target operation parameter, and the sticky bit is determined according to the suffix zero count of the exponent and mantissa and the target operation parameter.
[0042] When the format attribute is normalized floating-point number and the target operation parameter is non-negative, the shift value and sticky position are set to zero, and the updated value of the exponent is determined based on the maximum value of the exponent, the exponent, and the target operation parameter.
[0043] In another possible implementation, when the aforementioned arithmetic module performs shift, rounding, and exponent update operations on the source data based on the shifted value, updated value, and sticky bit, through the floating-point type conversion module, to generate the target data, it is used for:
[0044] The mantissa of the source data is shifted based on the shift value to obtain the shifted mantissa;
[0045] The target mantissa is obtained by rounding the shifted mantissa based on the sticky bit.
[0046] The target data is generated by formatting and packaging the updated value of the exponent, the target mantissa, and the sign bit of the source data.
[0047] In another possible implementation, the aforementioned computation module, when formatting and packaging the target data based on the exponent update value, the target mantissa, and the sign bit of the source data, is used for:
[0048] When it is determined that the exponent of the source data needs to be updated twice based on the shift and rounding operations, the target exponent is obtained by updating the exponent based on the target mantissa.
[0049] The target data is generated by formatting and packaging the target exponent, target mantissa, and sign bit of the source data.
[0050] In another possible implementation, the aforementioned computation module is also used for:
[0051] Based on the rounding rules corresponding to the rounding operation and the change status of the format attributes of the source data during the operation, the exception status information corresponding to the target data is generated.
[0052] In another possible implementation, the source data is a half-precision floating-point number, and the aforementioned arithmetic module is also used for:
[0053] When the format attribute is denormalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or infinite floating-point number;
[0054] When the format attribute is denormalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is a denormalized floating-point number or zero;
[0055] When the format attribute is normalized floating point and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating point or an infinite floating point.
[0056] When the format attribute is normalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or zero.
[0057] According to another aspect of the present application, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method shown in the first aspect of the present application.
[0058] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method shown in the first aspect of the embodiments of this application.
[0059] According to one aspect of the embodiments of this application, a computer program product is provided, which includes a computer program that, when executed by a processor, implements the steps of the method shown in the first aspect of the embodiments of this application.
[0060] The beneficial effects of the technical solutions provided in this application are:
[0061] This application embodiment utilizes a floating-point type conversion unit to perform the following operations on the user-input source data and corresponding target operation parameters: determining the format attributes of the source data based on its hidden bits; calculating the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, an updated value for the exponent of the source data, and sticky bits; and performing shift, rounding, and exponent update operations on the source data based on the shift values, updated values, and sticky bits to generate target data, thereby completing the target exponent operation instruction. In executing the target exponent operation instruction, this application embodiment reuses the existing floating-point type conversion unit for shift, rounding, and exponent update operations, achieving rapid execution of the target exponent operation instruction. Unlike the complex data paths of multiplication and addition units used in existing technologies to implement target exponent operation instructions, the floating-point type conversion unit used in this application embodiment has a simpler data path, improving operational efficiency and reducing processor power consumption. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0063] Figure 1 This is a schematic diagram illustrating an application scenario of a data processing method provided in an embodiment of this application;
[0064] Figure 2 A flowchart illustrating a data processing method provided in an embodiment of this application;
[0065] Figure 3-1 A flowchart illustrating the computational operations in a data processing method provided in this application embodiment;
[0066] Figure 3-2 A flowchart illustrating another operation in a data processing method provided in this application embodiment;
[0067] Figure 4A flowchart illustrating the generation of sticky bits in a data processing method provided in an embodiment of this application;
[0068] Figure 5 A schematic flowchart illustrating an example data processing method provided in an embodiment of this application;
[0069] Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application;
[0070] Figure 7 This is a schematic diagram of the structure of a data processing electronic device provided in an embodiment of this application. Detailed Implementation
[0071] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0072] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0073] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0074] Since the advent of microprocessors, embedded systems have developed rapidly. The embedded processor is undoubtedly the core component of an embedded system, directly affecting its overall performance. Generally, "embedded processor" is considered a general term for the core computing and control devices within an embedded system.
[0075] Embedded microprocessors are similar in basic design principles to those of ordinary desktop computer microprocessors, but they offer higher operational stability, lower power consumption, stronger adaptability to environments (such as temperature, humidity, electromagnetic fields, vibration, etc.), smaller size, and more integrated functions. Generally speaking, embedded processors have the following characteristics: strong real-time multitasking support capabilities, memory protection functions, scalable microprocessor architecture, strong interrupt handling capabilities, and low power consumption.
[0076] Embedded microprocessors often have low processing speeds when executing exponential operation instructions such as FSCALE because they need to calculate integer powers of 2.
[0077] The data processing methods, apparatus, electronic devices, and computer-readable storage media provided in this application are intended to solve the above-mentioned technical problems of the prior art.
[0078] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0079] like Figure 1 As shown, the data processing method of this application can be applied to... Figure 1 In the scenario shown, specifically, server 102 obtains the source data input by the user and the corresponding target operation parameters from client 101. When the target operation parameters are integers, the server determines the format attributes of the source data based on the hidden bits, and performs calculations on the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, exponent update values, and sticky bits. Then, based on these values, server 102 performs shift, rounding, and exponent update operations on the source data through a floating-point type conversion unit to generate the target data corresponding to the source data, thus completing the execution of the target exponent operation instruction. Finally, server 102 sends the target data 101 to the client.
[0080] Figure 1 In the scenario shown, the above data processing method can be performed on the server; in other scenarios, it can also be performed on the terminal.
[0081] Those skilled in the art will understand that the “terminal” used herein can be a mobile phone, tablet computer, PDA (Personal Digital Assistant), MID (Mobile Internet Device), etc.; and the “server” can be implemented using a standalone server or a server cluster composed of multiple servers.
[0082] This application provides a data processing method, such as... Figure 2 As shown, this method, which can be applied to a processor, includes:
[0083] S201, obtain the source data input by the user and the target operation parameters corresponding to the source data.
[0084] The source data can be floating-point numbers conforming to the IEEE 754 (IEEE binary floating-point arithmetic standard) format.
[0085] Specifically, users can input source data and corresponding target calculation parameters to the processor by operating the terminal peripherals. This processor can be an embedded microprocessor, which can communicate with the terminal via wired or wireless networks.
[0086] S202, If the target operation parameter is an integer, perform the following operations on the source data and the target operation parameter to execute the target exponentiation operation instruction and generate the target data corresponding to the source data:
[0087] S2021, Determine the format attributes of the source data based on the hidden bits of the source data;
[0088] S2022, calculates the source data based on the format attributes and the numerical range of the target operation parameters to generate the shift value, the updated value of the exponent of the source data, and the sticky bit of the source data.
[0089] S2023, based on the shifted value, the updated value, and the sticky bit, performs shift operations, rounding operations, and exponent update operations on the source data through the floating-point type conversion unit to generate the target data.
[0090] The aforementioned target exponentiation instruction can be the FSCALE instruction, which is used to perform exponentiation operations on the following functions:
[0091] DstFP = SrcFP * 2.0 scale (1)
[0092] Where SrcFP is the source data, scale is the target operation parameter, and DstFP is the target data.
[0093] The specific calculation process will be explained in detail below.
[0094] In the embodiments of the present application, the arithmetic operations executed by the processor can be applied to the fields of image processing, video processing, AI (Artificial Intelligence) processing and other fields. For example, based on the data processing of the embodiments of the present application, the arithmetic operation shown in the above formula (1) can be executed to complete the exponential operation required in the AI processing process, improve the operation efficiency, optimize the process of AI processing, and improve the operation power consumption of the processor.
[0095] In the embodiments of the present application, through a floating-point type conversion unit, the following arithmetic operations are performed on the source data input by the user and the target operation parameters corresponding to the source data: determining the format attribute of the source data based on the hidden bit of the source data; calculating the source data according to the format attribute and the value range of the target operation parameter, to generate a shift value, an updated value of the exponent of the source data, and a sticky bit of the source data; based on the shift value, the updated value and the sticky bit, performing a shift operation, a rounding operation and an exponent update operation on the source data respectively to generate target data, so as to complete the target exponential operation instruction. In the embodiments of the present application, during the execution of the target exponential operation instruction, by reusing the existing floating-point type conversion unit, the fast operation of the target exponential operation instruction is realized; different from the prior art that implements the target exponential operation instruction based on a complex data path of a multiplication and addition unit, the data path of the floating-point type conversion unit used in the embodiments of the present application is simpler, which can improve operation efficiency and reduce the power consumption of the processor.
[0096] A possible implementation is provided in the embodiments of the present application, as Figure 3-1 shown, the step of calculating the source data according to the format attribute and the value range of the target operation parameter to generate a shift value, an updated value of the exponent of the source data, and a sticky bit of the source data comprises:
[0097] (1) When the format attribute is a denormalized floating-point number and the target operation parameter is a negative number, taking the absolute value of the target operation parameter as the shift value, determining the updated value of the exponent according to the leading zero count of the mantissa of the source data, the bit width of the mantissa and the target operation parameter, and determining the sticky bit according to the trailing zero count of the mantissa and the target operation parameter.
[0098] Wherein, the direction of the shift value is right shift.
[0099] Specifically, the updated value of the exponent can be determined based on the following formula:
[0100] When LZC+|scale|≥Mbits+1, EXP′=0;
[0101] When LZC+|scale|<Mbits+1, EXP′=EXP;
[0102] wherein, LZC is the leading zero count of the mantissa of source data; Mbits is the bit width of the mantissa. For example, when the source data is a half-precision floating point number, the bit width of its mantissa is 11 bits, and when the source data is a single-precision floating point number, the bit width of its mantissa is 23 bits; EXP is the exponent of the source data, and EXP' is the updated value of the exponent. When EXP' = 0, the source data, that is, the denormalized floating point number can be converted to 0, that is, the target data can be 0.
[0103] Optionally, the sticky bit can be determined based on the following formula:
[0104] When TZC ≤ (|scale|-2), S = 1;
[0105] When TZC > (|scale|-2), S = 0;
[0106] wherein, TZC is the trailing zero count of the mantissa of the source data, and S is the value of the sticky bit.
[0107] (2) When the format attribute is a denormalized floating point number and the target operation parameter is a positive number, determine the shift value based on the difference between the leading zero count of the mantissa and the target operation parameter, determine the updated value of the exponent according to the maximum exponent value, the leading zero count and the target operation parameter, and set the sticky bit to zero.
[0108] Specifically, the shift value can be determined based on the following formula:
[0109] When LZC < scale, shift_number = LZC;
[0110] When LZC ≥ scale, shift_number = LZC - scale;
[0111] wherein, shift_number is the shift value, and the shift direction is left shift.
[0112] Optionally, the updated value of the exponent can be determined based on the following formula:
[0113] When EXP + inc ≥ EMAX, EXP' = EMAX;
[0114] When EXP + inc < EMAX, EXP' = EXP + inc;
[0115] wherein, inc is a calculation parameter:
[0116] When LZC < scale, inc = scale - LZC;
[0117] When LZC ≥ scale, inc = 0;
[0118] EMAX is the maximum value of the exponent; for example, when the source data is a half-precision floating-point number, the bit width of its exponent is 5 bits, that is, the maximum value of its exponent is 31.
[0119] When EXP′=EMAX, the source data, i.e., the denormalized floating-point number, can be converted into infinity, meaning the target data can be infinity.
[0120] When EXP′=EXP+inc, the source data is the target data corresponding to the denormalized floating-point number, which can be a normalized or denormalized floating-point number.
[0121] (3) When the format attribute is a denormalized floating-point number and the target operation parameter is equal to zero, the shift value and sticky position are set to zero, and the exponent is not updated.
[0122] When the shift value is zero, the mantissa is not shifted; and when the exponent is not updated, EXP′=EXP.
[0123] This application provides one possible implementation method, such as... Figure 3-2 As shown, the above method also includes:
[0124] (1) When the format attribute is normalized floating point number and the target operation parameter is negative, the shift value and the update value of the exponent are determined according to the bit width of the exponent and mantissa and the target operation parameter, and the sticky bit is determined according to the suffix zero count of the exponent and mantissa and the target operation parameter.
[0125] Specifically, the shift value shift_number can be calculated based on the following formula:
[0126] When (EXP-1+Mbits+1+scale)<0, shift_number=shift_number max ;
[0127] When (EXP-1+Mbits+1+scale)≥0 and (EXP-1+scale)<0, shift_number=|scale|-(EXP-1)+1;
[0128] When (EXP-1+Mbits+1+scale)≥0 and (EXP-1+scale)≥0, shift_number=0;
[0129] Among them, shift_number max The maximum number of bits that can be shifted within the range of floating-point numbers in the preset format of the source data.
[0130] Optionally, the updated value of the exponent can be calculated based on the following formula:
[0131] When EXP - 1 + Mbits + 1 + scale < 0, EXP′ = 0;
[0132] When EXP - 1 + Mbits + 1 + scale ≥ 0 and EXP - 1 + scale < 0, EXP′ = 1;
[0133] When EXP - 1 + Mbits + 1 + scale ≥ 0 and EXP - 1 + scale ≥ 0, EXP′ = EXP + scale;
[0134] Wherein, when EXP′ = 0, the target data corresponding to the source data that is a normalized floating-point number may be 0.
[0135] When EXP′ = 1, the target data corresponding to the source data that is a normalized floating-point number may be a denormalized floating-point number.
[0136] When EXP′ = EXP + scale, the target data corresponding to the source data that is a normalized floating-point number may also be a normalized floating-point number.
[0137] Optionally, the sticky bit can be calculated based on the following formula:
[0138] When TZC ≤ (len - 2), S = 1;
[0139] When TZC > (len - 2), S = 0;
[0140] Wherein, len is a length coefficient:
[0141] When EXP - 1 + scale ≥ 0, len = 0;
[0142] When EXP - 1 + scale < 0, len = |scale| - (EXP - 1);
[0143] (2) When the format attribute is a normalized floating-point number and the target operation parameter is a non-negative number, set the shift value and the sticky bit to zero, and determine the updated value of the exponent according to the maximum value of the exponent, the exponent and the target operation parameter.
[0144] Specifically, the updated value of the exponent can be calculated based on the following formula:
[0145] When EXP + scale ≥ EMAX, EXP′ = EMAX;
[0146] When EXP + scale < EMAX, EXP′ = EXP + scale;
[0147] When EXP′=EMAX, the source data, i.e., the normalized floating-point number, can be converted to infinity, meaning the target data can be infinity.
[0148] When EXP′=EMAX+scale, the source data is the target data corresponding to the normalized floating-point number, which can be a denormalized floating-point number.
[0149] This application provides a possible implementation method in which, based on the shift value, update value, and sticky bit, the target data is generated by performing shift operations, rounding operations, and exponent update operations on the source data through a floating-point type conversion module, including:
[0150] S301, perform a shift operation on the mantissa of the source data based on the shift value to obtain the shifted mantissa.
[0151] Specifically, during the shift operation, the sign bit of the source data remains unchanged, the mantissa is shifted left or right, and empty bits are filled with 0 to obtain the shifted mantissa.
[0152] S302, rounds the shifted mantissa based on the sticky bit to obtain the target mantissa.
[0153] The rounding operation can correspond to different rounding rules, such as rounding to the nearest even number, rounding towards +∞, or rounding towards -∞. No specific limitations are made in the embodiments of this application.
[0154] Specifically, the relationship between viscous bits and rounding bits is as follows: Figure 4 As shown, the mantissa after the rounding bit R can be used as the sticky region, and the value of the sticky bit can be determined based on the sticky region; for example, when the value of all bits in the sticky region is 0, the sticky bit is 0; when there is at least one non-zero bit in the sticky region, the sticky bit is 1. Figure 5 If there is at least one non-zero bit in the viscous region, then the viscous bit is 1.
[0155] S303 generates target data by formatting the updated value of the exponent, the target mantissa, and the sign bit of the source data.
[0156] Specifically, the target data can be generated by formatting the updated value of the exponent, the target mantissa, and the sign bit of the source data based on the IEEE 754 encoding format.
[0157] In some implementations, the target data can be directly generated by packaging; in other implementations, the exponent update value can be updated a second time based on the data after shift and rounding operations, and then packaged to generate the target data. The process of the second update of the exponent will be described in detail below.
[0158] This application provides a possible implementation method in which the target data is generated by formatting the updated value of the exponent, the target mantissa, and the sign bit of the source data, including:
[0159] S401, when it is determined from the shift and rounding operations that the exponent of the source data needs to be updated a second time, the updated value of the exponent is updated according to the target mantissa to obtain the target exponent.
[0160] Specifically, the processor can refer to the carry information provided by the rounding subunit to update the exponent's update value and obtain the target exponent.
[0161] For example, after shifting the mantissa, the mantissa is the maximum value of the current floating-point format, and the rounding operation is as follows:
[0162] mantissa=1.111111+0.000001=10.000000 (2)
[0163] Where mantissa is the mantissa, and +0.000001 is the rounding operation;
[0164] Then the exponent's update value EXP' needs to be updated a second time, with EXP'+1 used as the target exponent. Its corresponding mantissa becomes 1.000000.
[0165] S402 generates target data by formatting the target exponent, target mantissa, and sign bit of the source data.
[0166] Specifically, the target data can be generated by formatting the target exponent, target mantissa, and sign bit of the source data based on the IEEE 754 encoding format.
[0167] This application provides a possible implementation method, and the above method further includes:
[0168] Based on the rounding rules corresponding to the rounding operation and the change status of the format attributes of the source data during the operation, the exception status information corresponding to the target data is generated.
[0169] Specifically, exception status information corresponding to the target data can be generated based on the rounding rules corresponding to the rounding operation, the source data, the carry information determined by the aforementioned rounding operation, the target mantissa, and the target exponent.
[0170] Among them, the exception state information is used to characterize the abnormal handling state of the processor during the calculation process.
[0171] For example, when the target data is infinity, the corresponding exception status information can be overflow, which means that the calculated value of the target data exceeds the maximum value that the current floating-point format can represent.
[0172] When the target data is an undefined value or 0 and the inexact condition is met, the corresponding exception status information can be underflow.
[0173] When a rounding operation occurs, if the rounding bit of the mantissa and the bits of the sticky region are not both 0, the corresponding exception status information can be inexact.
[0174] When the target data input result is NaN (not a number), the corresponding exception status information can be invalid operation, that is, an illegal operation.
[0175] This application provides a possible implementation method where the source data is a half-precision floating-point number with an exponent bit width of 5. For a normalized floating-point number, the maximum value of the exponent is 31 and the minimum value is 0. When the exponent is 0, the source data is 0 or a denormalized floating-point number. When the exponent is greater than 31, the source data is infinity.
[0176] The method also includes:
[0177] When the format attribute is denormalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating-point number, a denormalized floating-point number, or an infinite floating-point number.
[0178] When the format attribute is denormalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is a denormalized floating-point number or zero.
[0179] When the format attribute is normalized floating point and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating point or an infinite floating point.
[0180] The exponent is updated based on the target operation parameters.
[0181] When the format attribute is normalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or zero;
[0182] The last digit may be modified.
[0183] In this embodiment, when the source data is a normalized floating-point number and the target operation parameter is negative, if |scale| is large enough (i.e., |scale|>(EXP+Mbits)), the target data will approach 0. This means the updated exponent and mantissa will be too small to be identified using existing floating-point encoding rules, resulting in the target data being 0. In this case, |scale| can be said to be large enough to consume the exponent and mantissa of the target data, causing the target data to become 0. If |scale| can only consume the exponent and a portion of the mantissa bits, the target data will become a denormalized floating-point number. If |scale| cannot consume the exponent to minimize it, then the exponent needs to be updated.
[0184] In other implementations, when the source data is a denormalized floating-point number, we need to compare the difference between LZC and the target arithmetic parameter `scale`. If `scale` is large enough, the exponent value will be updated based on this difference, and the target data can be a normalized floating-point number. For example, for a denormalized source data, its mantissa can be 0.000110101. In this case, as long as `scale` ≥ 3, i.e., 2... 3 *0.000110101 = 1.1010100000, which changes the integer part of the mantissa from 0 to 1, meaning the target data is now a normalized floating-point number. In this embodiment, the target arithmetic parameter only needs to be at least 3 to be large enough. If scale ≤ LZC and scale is not equal to 0, the exponent remains unchanged, and the mantissa is updated according to the value of scale.
[0185] To better understand the data processing methods described above, the following section will combine... Figure 5 The following is a detailed example of a data processing method according to this application. This method can be applied to a microprocessor including a floating-point type conversion unit, which comprises a leading zero counting subunit, a suffix zero counting subunit, a shift subunit, a sticky bit generation subunit, an exponent update subunit, a rounding subunit, a format packing subunit, and an exception status information generation subunit. The method includes the following steps:
[0186] S501, the microprocessor acquires the source data input by the user and the target operation parameters corresponding to the source data.
[0187] S502, LZC for determining the mantissa of source data based on leading zero counting subunit, and TZC for determining the mantissa of source data based on suffix zero counting subunit.
[0188] S503 generates shift values based on LZC and target operation parameters.
[0189] S504, the shift subunit performs a shift operation on the mantissa according to the shift value to generate the shifted mantissa.
[0190] S505, the viscous bit generation sub-unit generates viscous bits S based on TZC and target operation parameters.
[0191] S506, the rounding sub-unit performs a rounding operation on the shifted mantissa based on the sticky bit S to obtain the target mantissa.
[0192] S507, the exponent update subunit determines the updated value of the exponent based on LZC and the target operation parameters. When it is determined that the exponent of the source data needs to be updated a second time based on the shift and rounding operations, the exponent update subunit will update the exponent value again with reference to the carry information provided by the rounding subunit to obtain the target exponent.
[0193] S508, the format packing subunit packs the target data based on the target exponent, target mantissa, and the sign bit of the source data to generate the target data. At the same time, the exception status information generation subunit generates the exception status information corresponding to the target data based on the rounding rules corresponding to the rounding operation, the source data, carry information, target mantissa, and target exponent.
[0194] This embodiment of the application, through a floating-point type conversion unit, performs the following operations on the user-input source data and the corresponding target operation parameters: It determines the format attributes of the source data based on the hidden bits; it calculates the source data according to the format attributes and the numerical range of the target operation parameters, generating a shift value, an updated value for the exponent of the source data, and a sticky bit; based on the shift value, the updated value, and the sticky bit, it performs shift operations, rounding operations, and exponent update operations on the source data to generate the target data, thus completing the target exponent operation instruction. In executing the target exponent operation instruction, this embodiment of the application achieves rapid execution of the target exponent operation instruction by reusing the existing floating-point type conversion unit. Unlike the complex data paths of multiplication and addition units used in existing technologies to implement target exponent operation instructions, the floating-point type conversion unit used in this embodiment has a simpler data path, improving operational efficiency and reducing processor power consumption.
[0195] This application provides a data processing apparatus, such as... Figure 6 As shown, the data processing device 60 may include: an acquisition module 601 and a calculation module 602;
[0196] The acquisition module 601 is used to acquire the source data input by the user and the target operation parameters corresponding to the source data; wherein the source data is a floating-point number;
[0197] The calculation module 602 is used to perform the following calculation operations on the source data and the target calculation parameter if the target calculation parameter is an integer, in order to execute the target exponentiation calculation instruction and generate the target data corresponding to the source data:
[0198] The hidden bits of the source data are used to determine the format attributes of the source data; calculations are performed on the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data; based on the shift values, update values, and sticky bits, shift operations, rounding operations, and exponent update operations are performed on the source data through the floating-point type conversion unit to generate the target data.
[0199] This application embodiment provides a possible implementation method in which the above-mentioned calculation module 602, when calculating the source data according to the format attributes and the numerical range of the target calculation parameters to generate the shift value, the updated value of the exponent of the source data, and the sticky bit of the source data, is used to:
[0200] When the format attribute is a denormalized floating-point number and the target operation parameter is negative, the absolute value of the target operation parameter is used as the shift value, and the update value of the exponent is determined according to the leading zero count of the mantissa of the source data, the bit width of the mantissa, and the target operation parameter. The sticky bit is determined according to the suffix zero count of the mantissa and the target operation parameter.
[0201] When the format attribute is a denormalized floating-point number and the target operation parameter is a positive number, the shift value is determined based on the difference between the leading zero count of the mantissa and the target operation parameter, and the update value of the exponent is determined based on the maximum value of the exponent, the leading zero count, and the target operation parameter, and the sticky position is set to zero.
[0202] When the format attribute is a denormalized floating-point number and the target operation parameter is equal to zero, the shift value and sticky position are set to zero, and the exponent is not updated.
[0203] This application embodiment provides a possible implementation, wherein the above-mentioned calculation module 602 is further used for:
[0204] When the format attribute is normalized floating-point number and the target operation parameter is negative, the shift value and the update value of the exponent are determined according to the bit width of the exponent and mantissa and the target operation parameter, and the sticky bit is determined according to the suffix zero count of the exponent and mantissa and the target operation parameter.
[0205] When the format attribute is normalized floating-point number and the target operation parameter is non-negative, the shift value and sticky position are set to zero, and the updated value of the exponent is determined based on the maximum value of the exponent, the exponent, and the target operation parameter.
[0206] This application embodiment provides a possible implementation method. When the above-mentioned operation module 602 generates target data by performing shift operations, rounding operations, and exponent update operations on the source data based on the shift value, update value, and sticky bit through the floating-point type conversion module, it is used to:
[0207] The mantissa of the source data is shifted based on the shift value to obtain the shifted mantissa;
[0208] The target mantissa is obtained by rounding the shifted mantissa based on the sticky bit.
[0209] The target data is generated by formatting and packaging the updated value of the exponent, the target mantissa, and the sign bit of the source data.
[0210] This application provides a possible implementation method in which the above-mentioned operation module 602, when formatting and packaging the target data based on the exponent update value, the target mantissa, and the sign bit of the source data, is used for:
[0211] When it is determined that the exponent of the source data needs to be updated twice based on the shift and rounding operations, the target exponent is obtained by updating the exponent based on the target mantissa.
[0212] The target data is generated by formatting and packaging the target exponent, target mantissa, and sign bit of the source data.
[0213] This application embodiment provides a possible implementation, wherein the above-mentioned calculation module 602 is further used for:
[0214] Based on the rounding rules corresponding to the rounding operation and the change status of the format attributes of the source data during the operation, the exception status information corresponding to the target data is generated.
[0215] This application provides a possible implementation method, wherein the source data is a half-precision floating-point number, and the above-mentioned arithmetic module 602 is further used for:
[0216] When the format attribute is denormalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or infinite floating-point number;
[0217] When the format attribute is denormalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is a denormalized floating-point number or zero;
[0218] When the format attribute is normalized floating point and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating point or an infinite floating point.
[0219] When the format attribute is normalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is normalized floating-point number, denormalized floating-point number, or zero.
[0220] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0221] This embodiment of the application, through a floating-point type conversion unit, performs the following operations on the user-input source data and the corresponding target operation parameters: It determines the format attributes of the source data based on the hidden bits; it calculates the source data according to the format attributes and the numerical range of the target operation parameters, generating a shift value, an updated value for the exponent of the source data, and a sticky bit; based on the shift value, the updated value, and the sticky bit, it performs shift operations, rounding operations, and exponent update operations on the source data to generate the target data, thus completing the target exponent operation instruction. In executing the target exponent operation instruction, this embodiment of the application achieves rapid execution of the target exponent operation instruction by reusing the existing floating-point type conversion unit. Unlike the complex data paths of multiplication and addition units used in existing technologies to implement target exponent operation instructions, the floating-point type conversion unit used in this embodiment has a simpler data path, improving operational efficiency and reducing processor power consumption.
[0222] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a data processing method. Compared with related technologies, this application embodiment can achieve the following operations using a floating-point type conversion unit for user-input source data and corresponding target operation parameters: determining the format attribute of the source data based on the hidden bits of the source data; calculating the source data according to the format attribute and the numerical range of the target operation parameters to generate a shift value, an update value of the exponent of the source data, and a sticky bit of the source data; and performing shift, rounding, and exponent update operations on the source data based on the shift value, update value, and sticky bit to generate target data, thereby completing the target exponent operation instruction. In the execution of the target exponent operation instruction, this application embodiment achieves rapid execution of the target exponent operation instruction by reusing the existing floating-point type conversion unit. Unlike the complex data paths of multiplication and addition units used in the prior art to implement the target exponent operation instruction, the data path of the floating-point type conversion unit used in this application embodiment is simpler, which can improve computational efficiency and reduce processor power consumption.
[0223] In one alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7The illustrated electronic device 70 includes a processor 701 and a memory 703. The processor 701 and the memory 703 are connected, for example, via a bus 702. Optionally, the electronic device 70 may further include a transceiver 704, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 704 is not limited to one type, and the structure of this electronic device 70 does not constitute a limitation on the embodiments of this application.
[0224] Processor 701 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 701 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0225] Bus 702 may include a pathway for transmitting information between the aforementioned components. Bus 702 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 702 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0226] The memory 703 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0227] The memory 703 stores computer programs that execute embodiments of this application, and the processor 701 controls their execution. The processor 701 executes the computer programs stored in the memory 703 to implement the steps shown in the foregoing method embodiments.
[0228] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, and tablets, as well as fixed terminals such as digital TVs and desktop computers.
[0229] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0230] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the following actions:
[0231] Obtain the source data input by the user and the target operation parameters corresponding to the source data; wherein, the source data is a floating-point number;
[0232] If the target operation parameter is an integer, perform the following operations on the source data and the target operation parameter to execute the target exponentiation operation instruction and generate the target data corresponding to the source data:
[0233] Determine the format attributes of the source data based on the hidden bits of the source data;
[0234] The calculations are performed on the source data based on the format attributes and the numerical range of the target operation parameters to generate the shift value, the updated value of the exponent of the source data, and the sticky bit of the source data.
[0235] Based on the shifted value, the updated value, and the sticky bit, the target data is generated by performing shift, rounding, and exponent update operations on the source data through the floating-point type conversion unit.
[0236] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0237] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0238] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A data processing method applied to a processor, comprising: Obtain the source data input by the user and the target operation parameters corresponding to the source data; wherein, the source data is a floating-point number; If the target operation parameter is an integer, the following operations are performed on the source data and the target operation parameter to execute the target exponentiation operation instruction and generate the target data corresponding to the source data: The format attributes of the source data are determined based on the hidden bits of the source data; The source data is calculated based on the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data. The step of calculating the source data based on the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data includes: When the format attribute is a denormalized floating-point number and the target operation parameter is negative, the absolute value of the target operation parameter is used as the shift value, and the update value of the exponent is determined according to the leading zero count of the mantissa of the source data, the bit width of the mantissa, and the target operation parameter. The sticky bit is determined according to the suffix zero count of the mantissa and the target operation parameter. When the format attribute is a denormalized floating-point number and the target operation parameter is a positive number, the shift value is determined based on the difference between the leading zero count of the mantissa and the target operation parameter, and the update value of the exponent is determined based on the maximum value of the exponent, the leading zero count and the target operation parameter, and the sticky position is set to zero. When the format attribute is a denormalized floating-point number and the target operation parameter is equal to zero, the shift value and sticky position are set to zero, and the exponent is not updated. Based on the shifted value, the updated value, and the sticky bit, the source data is shifted, rounded, and updated using a floating-point type conversion unit to generate the target data.
2. The method according to claim 1, characterized in that, The method further includes: When the format attribute is a normalized floating-point number and the target operation parameter is negative, the shift value and the update value of the exponent are determined according to the exponent, the bit width of the mantissa, and the target operation parameter, and the sticky bit is determined according to the exponent, the suffix zero count of the mantissa, and the target operation parameter. When the format attribute is a normalized floating-point number and the target operation parameter is a non-negative number, the shift value and sticky position are set to zero, and the update value of the exponent is determined according to the maximum value of the exponent, the exponent, and the target operation parameter.
3. The method according to claim 1, characterized in that, The process of generating target data by performing shift, rounding, and exponent update operations on the source data using a floating-point type conversion module based on the shifted value, the updated value, and the sticky bit includes: The mantissa of the source data is shifted based on the shift value to obtain the shifted mantissa; The target mantissa is obtained by rounding the shifted mantissa based on the sticky bit. The target data is generated by formatting and packaging the updated value of the exponent, the target mantissa, and the sign bit of the source data.
4. The method according to claim 3, characterized in that, The process of formatting and packaging the target data based on the updated value of the exponent, the target mantissa, and the sign bit of the source data to generate the target data includes: When it is determined that the exponent of the source data needs to be updated a second time based on the shift and rounding operations, the updated value of the exponent is updated according to the target mantissa to obtain the target exponent. The target data is generated by formatting and packaging the target exponent, target mantissa, and sign bit of the source data.
5. The method according to claim 1, characterized in that, The method further includes: Based on the rounding rules corresponding to the rounding operation and the format attribute change status of the source data in the operation, the exception status information corresponding to the target data is generated.
6. The method according to claim 1, characterized in that, The source data is a half-precision floating-point number, and the method further includes: When the format attribute is a denormalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating-point number, a denormalized floating-point number, or an infinite floating-point number. When the format attribute is a denormalized floating-point number and the target operation parameter is a negative number, the target data corresponding to the source data is a denormalized floating-point number or zero; When the format attribute is a normalized floating-point number and the target operation parameter is a positive number, the target data corresponding to the source data is a normalized floating-point number or an infinite floating-point number. When the format attribute is a normalized floating-point number and the target operation parameter is negative, the target data corresponding to the source data is a normalized floating-point number, a denormalized floating-point number, or zero.
7. A data processing apparatus, characterized in that, include: The acquisition module is used to acquire source data input by the user and the target operation parameters corresponding to the source data; wherein, the source data is a floating-point number; The calculation module is configured to perform the following calculation operations on the source data and the target calculation parameter if the target calculation parameter is an integer, in order to execute the target exponent calculation instruction and generate the target data corresponding to the source data: The format attributes of the source data are determined based on the hidden bits of the source data; calculations are performed on the source data according to the format attributes and the numerical range of the target operation parameters to generate shift values, update values of the exponent of the source data, and sticky bits of the source data; based on the shift values, update values, and sticky bits, shift operations, rounding operations, and exponent update operations are performed on the source data through a floating-point type conversion unit to generate target data; The arithmetic module is further configured to: when the format attribute is a denormalized floating-point number and the target arithmetic parameter is negative, use the absolute value of the target arithmetic parameter as the shift value, and determine the update value of the exponent based on the leading zero count of the mantissa of the source data, the bit width of the mantissa, and the target arithmetic parameter; determine the sticky bit based on the suffix zero count of the mantissa and the target arithmetic parameter; when the format attribute is a denormalized floating-point number and the target arithmetic parameter is positive, determine the shift value based on the difference between the leading zero count of the mantissa and the target arithmetic parameter, and determine the update value of the exponent based on the maximum value of the exponent, the leading zero count, and the target arithmetic parameter, and set the sticky bit to zero; when the format attribute is a denormalized floating-point number and the target arithmetic parameter is equal to zero, set the shift value and the sticky bit to zero, and do not update the exponent.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Floating-point number processing device, floating-point number addition device, and floating-point number processing method
CN112230882A
Floating point multiply-add unit with fusion precision conversion function and application method of floating point multiply-add unit
CN115390790A