Data processing method, computer readable storage medium and computer program product

By splitting the exponent of the exponential function into integer and fractional parts and using B-spline curve fitting and partial sum array calculation, the latency problem caused by data format conversion is solved, and efficient exponential function calculation is achieved.

CN121785560APending Publication Date: 2026-04-03MOORE THREADS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In calculating exponential functions with different data formats, existing techniques require additional data format conversion logic, leading to latency issues.

Method used

The exponent of the exponential function is split into integer and fractional parts and calculated separately. The exponential function calculation is achieved by using B-spline curve fitting and partial sum array calculation, thus avoiding data format conversion.

Benefits of technology

This reduces latency caused by data format conversion, and allows for efficient exponential function calculations using the same parts and arrays for different data formats.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121785560A_ABST
    Figure CN121785560A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device, a chip, a medium and a product, and relates to the field of integrated circuit design. The method comprises the steps that input data is converted into first data and second data, the input data is an index of an exponential function, the first data is an integer part of a fixed-point number obtained through conversion of the input data, and the second data is a decimal part of the fixed-point number obtained through conversion of the input data; b-spline curve fitting is carried out on the second data to obtain a first processing result, and the B-spline curve fitting is achieved through partial sum array calculation; generating an exponential function calculation result based on the first data and the first processing result; wherein the exponential part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of integrated circuit design, and in particular to a data processing method, a computer-readable storage medium, and a computer program product. Background Technology

[0002] With the rapid development of graphics processing technology, exponential functions, especially the base-2 exponential function (exp2), have become the core of many function calculations. For example, in the implementation of dynamic lighting, the exp2 function can conveniently simulate light attenuation.

[0003] In related technologies, when performing exponential function calculations on exponents with different data formats, it is usually considered to convert the exponents of different data formats into data formats supported by the exponential function calculation device for calculation.

[0004] However, using the above method for calculation requires additional data format conversion logic, which introduces latency. Summary of the Invention

[0005] This application provides a data processing method, a computer-readable storage medium, and a computer program product. The technical solutions provided by this application include the following aspects.

[0006] In one aspect, embodiments of this application provide a data processing method, the method comprising: The input data is converted into first data and second data, wherein the input data is the exponent of an exponential function, the first data is the integer part of a fixed-point number obtained by converting the input data, and the second data is the fractional part of a fixed-point number obtained by converting the input data. The second data is fitted with a B-spline curve to obtain the first processing result, wherein the B-spline curve fitting is achieved by partial sum array calculation; An exponential function calculation result is generated based on the first data and the first processing result; wherein, the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

[0007] On the other hand, embodiments of this application provide a data processing apparatus, which includes a processing module, a calculation module, and a generation module; The processing module is configured to convert input data into first data and second data, wherein the input data is the exponent of an exponential function, the first data is the integer part of a fixed-point number obtained by converting the input data, and the second data is the fractional part of a fixed-point number obtained by converting the input data. The calculation module is configured to perform B-spline curve fitting based on the second data to obtain a first processing result, wherein the B-spline curve fitting is implemented using partial sum array calculation; The generation module is configured to generate an exponential function calculation result based on the first data and the first processing result; wherein the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

[0008] On the other hand, embodiments of this application provide a chip that can be loaded and executed to implement the above-described data processing method.

[0009] On the other hand, embodiments of this application provide a computer-readable storage medium storing a computer program, which is loaded and executed by a processor to implement the above-described data processing method.

[0010] On the other hand, embodiments of this application provide a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor reads from the computer-readable storage medium and executes the computer program to implement the above-described data processing method.

[0011] The technical solution provided in this application can bring the following beneficial effects: By splitting the fixed-point number obtained from the exponent conversion of the exponent function, the integer part of the fixed-point number is used as the first data, and the decimal part is used as the second data. Based on the first data, the exponent of the calculated exponent function result can be determined. Based on the second data, B-spline curve fitting can be performed to obtain the mantissa of the calculated exponent function result. The exponent and mantissa of the calculated exponent function result can be obtained, avoiding data format conversion and reducing the delay caused by data format conversion. At the same time, B-spline curve fitting is implemented using partial sum array calculation, and the same partial sum array can be used for the calculation process of exponent functions with different data formats, realizing the calculation of exponent functions with different data formats. Attached Figure Description

[0012] Figure 1 This is a schematic diagram of the structure of some and array hardware provided in an exemplary embodiment of this application; Figure 2 This is a schematic diagram of the data formats of FP16 and BP16 provided in an exemplary embodiment of this application; Figure 3 This is a flowchart of a data processing method provided in an exemplary embodiment of this application; Figure 4This is a flowchart of a data processing method provided in another exemplary embodiment of this application; Figure 5 This is a flowchart illustrating the process of determining control points and fitting curves according to an illustrative embodiment of this application; Figure 6 This is a schematic diagram illustrating the partitioning of second data by bits, provided in an exemplary embodiment of this application; Figure 7 This is a flowchart illustrating a B-spline curve fitting process according to an illustrative embodiment of this application; Figure 8 This is a flowchart illustrating a portion and array computation process provided in an illustrative embodiment of this application; Figure 9 This is a schematic diagram of a partial integration device provided in an illustrative embodiment of this application; Figure 10 This is a flowchart of the exponential function calculation process provided in an exemplary embodiment of this application; Figure 11 This is a schematic diagram of the structure of a data processing apparatus provided in another exemplary embodiment of this application; Figure 12 This is a schematic diagram of the structure of a data processing apparatus provided in an illustrative embodiment of this application; Figure 13 This is a structural block diagram of a computer device provided in an exemplary embodiment of this application. Detailed Implementation

[0013] 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.

[0014] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0015] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0016] It should be understood that although the terms “first,” “second,” etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, a first parameter may also be referred to as a second parameter, and similarly, a second parameter may also be referred to as a first parameter. Depending on the context, the word “if” as used herein may be interpreted as “when…” or “in response to determination.”

[0017] It should be noted that this application may display a prompt interface, pop-up window, or output voice prompt information before collecting user, processor, computer device, and other related data, and during the process of collecting user-related data. This prompt interface, pop-up window, or voice prompt information is used to inform the user that their related data is being collected. This ensures that the application only begins executing the steps related to collecting user-related data after receiving confirmation from the user regarding the prompt interface or pop-up window; otherwise (i.e., without receiving confirmation from the user), the steps related to collecting user-related data end, meaning no user-related data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of related user data must comply with the laws, regulations, and standards of relevant countries and regions.

[0018] First, the terms used in the embodiments of this application will be introduced.

[0019] Partial array: refers to a parallel computing structure and data organization form used to implement low-bit-width multiplication and addition operations. Its core idea is to decompose a complex multiplication operation, especially a high-bit-width multiplication operation, into multiple multiplication suboperations with lower operand bit widths, and then align and arrange the product results of the suboperations according to their respective numerical weights to form a regular array result.

[0020] Specifically, when calculating the multiplication of two operands A and B, or a multiply-add operation involving multiplication, the partial sum array splits operands A and B into multiple low-bit-width multiplications, as shown below:

[0021] The multiplication of operands A and B is broken down into multiple multiply-add parts. Each bit of operand B is multiplied by A, and the result of each calculation is left-shifted with an appropriate weight to obtain the result of the multiplication of each bit of operand B. The results of the multiplication of each bit of operand B are accumulated to obtain the final calculation result, which is the result of the multiplication of operands A and B.

[0022] like Figure 1The diagram illustrates the structure of a partial sum array hardware provided in an exemplary embodiment of this application. When calculating the multiplication of two operands A and B, operand A comprises 7 bits (a6, a5, a4, a3, a2, a1, a0), and operand B comprises 4 bits (b3, b2, b1, b0). During partial sum array calculation, b0 is multiplied by a6, a5, a4, a3, a2, a1, a0, and the result is shifted left by 0 bits. The first step of the calculation is performed. Then, a bit multiplication is performed between b1 and a6, a5, a4, a3, a2, a1, a0, and the result is shifted left by 1 bit to obtain the second step's result. A bit multiplication is performed between b2 and a6, a5, a4, a3, a2, a1, a0, and the result is shifted left by 2 bits to obtain the third step's result. A bit multiplication is performed between b3 and a6, a5, a4, a3, a2, a1, a0, and the result is shifted left by 3 bits to obtain the fourth step's result. The results of the first, second, third, and fourth steps are then summed to obtain the partial sum array calculation result. Each bit of operand B is multiplied by operand A and shifted to obtain the result of the multiplication operation between that bit of operand B and operand A. The results of each multiplication operation are then summed to obtain the partial sum array calculation result.

[0023] B-spline curve fitting is a mathematical modeling and computational method that uses quadratic B-spline basis functions to piecewise approximate a target function. Its core lies in using a set of control points (fewer than the original data points) and their defined spline curves to smoothly and efficiently approximate the shape of the target function. Specifically, the B-spline curve fitting formula is:

[0024] As shown in formula (1), For curve parameters, , , These are the three control points that define the shape of the curve segment.

[0025] The formula is mathematically equivalent to a quadratic polynomial, but its coefficients are composed of a linear combination of multiple control points. This allows adjacent curve segments to satisfy certain continuity constraints, thereby ensuring that the final fitted overall curve has smooth transition characteristics.

[0026] The fitting process first divides the domain of the objective function into several intervals. For each interval, a set of optimal control points is obtained using the least squares method, interpolation method, or other optimization algorithms, minimizing the error between the B-spline fitted curve S(t) and the objective function within that interval. Since the influence of the control points in the formula is local, optimizing and adjusting the control points of any interval only affects its adjacent finite intervals. This characteristic makes the fitting process highly efficient and stable. The B-spline curve fitting method used in this application combines the advantages of polynomial computation simplicity and the local support of spline curves, providing a key technical foundation for achieving high-precision approximation calculations of exponential functions with base 2.

[0027] FP16 (Half-precision floating-point 16): A 16-bit half-precision floating-point format, FP16 is a binary floating-point number representation format that conforms to the IEEE 754 standard. FP16 encodes a value in scientific notation using a 16-bit binary sequence.

[0028] like Figure 2 The diagram illustrates the data formats of FP16 and BP16 (Brain Floating Point 16) provided in an exemplary embodiment of this application. In the FP16 format, the sign bit s occupies the most significant bit and has a length of 1 bit; the exponent bit e is located after the sign bit and has a length of 5 bits; and the mantissa bit m occupies the least significant bit and has a length of 10 bits. The data calculation formula for the FP16 format is as follows:

[0029] As shown in formula (2), The sign bit value. The last digit is the numerical value. The value is the exponent, and the integer value 15 is the bias value represented in FP16 format.

[0030] BP16: 16-bit floating-point format. In BP16 format, the sign bit (s) occupies the most significant bit and is 1 bit long; the exponent bit (e) follows the sign bit and is 8 bits long; and the mantissa bit (m) occupies the least significant bit and is 7 bits long. The data calculation formula in BP16 format is:

[0031] As shown in formula (3), The sign bit value. The last digit is the numerical value. The value is the exponent, and the integer value 127 is the bias value represented in BP16 format.

[0032] When dealing with exponents in different data formats, related technologies typically consider converting the exponents in different data formats into a data format supported by the exponential function calculation device before calculation. However, using the above method requires additional data format conversion logic, and data format conversion introduces latency.

[0033] To address the aforementioned issues, this application provides a data processing method that splits the exponent of an exponential function into its integer and fractional parts, calculates them separately, and obtains the exponent and mantissa of the calculated result. This avoids data format conversion and reduces the delay caused by data format conversion. Furthermore, B-spline curve fitting is implemented using partial sum array calculation, allowing the same partial sum array to be used for the calculation of exponential functions in different data formats, thus realizing the calculation of exponential functions in different data formats.

[0034] The solution provided in this application can be used in computer devices with needs such as graphics processing, scientific computing, and artificial intelligence training. These devices can be terminals or servers. Terminals can be electronic devices such as mobile phones, tablets, in-vehicle terminals (vehicle infotainment systems), wearable devices, and PCs (Personal Computers). Servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud servers, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. In the following embodiments, for ease of description, the example of a data processing method being executed by a computer device is used for illustration.

[0035] Figure 3 This is a flowchart illustrating a data processing method provided in an exemplary embodiment of this application. The method can be executed by the aforementioned computer device and includes at least one of the following steps.

[0036] Step 310: Convert the input data into first data and second data. The input data is the exponent of the exponential function. The first data is the integer part of the fixed-point number obtained by converting the input data, and the second data is the decimal part of the fixed-point number obtained by converting the input data.

[0037] The input data is the exponent of an exponential function. The input data is converted into first data and second data. The first data is the integer part of the fixed-point number obtained by converting the input data, and the second data is the decimal part of the fixed-point number obtained by converting the input data.

[0038] For illustration, the input data is in FP16 format, which is 0x3E00. The converted fixed-point number is 1.5. The integer part of 1.5, 1, is determined as the first data, and the decimal part of 1.5, 0.5, is determined as the second data.

[0039] In some embodiments, both the first data and the second data are represented in hexadecimal. For example, the first data may be defined as 0x1 and the second data as 0x200.

[0040] Since the numerical range of the decimal is [0, 1), the numerical range of the determined second data is [0, 1).

[0041] In other embodiments, the input data is in BP16 format. This application does not limit the data format used for the input data.

[0042] Step 320: Perform B-spline curve fitting on the second data to obtain the first processing result, wherein the B-spline curve fitting is implemented using partial sum array calculation.

[0043] The second data is the decimal part of the fixed-point number obtained by converting the input data. The main computational workload of the exponential function calculation of the input data is reflected in the exponential function calculation of the second data. The computer equipment uses B-spline curve fitting to approximately calculate the exponential function calculation result of the second data.

[0044] B-spline curve fitting involves multiplication operations. To avoid high-bit-width multiplication, partial sum arrays are used when fitting B-spline curves.

[0045] Step 330: Generate an exponential function calculation result based on the first data and the first processing result; wherein, the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

[0046] The first data is the integer part of the fixed-point number obtained by converting the input data. Since the result of the exponential function calculation of the mantissa of the input data does not affect the exponential part of the exponential function calculation result, the computer device can determine the exponential part of the exponential function calculation result based on the first data.

[0047] To illustrate, when calculating the exponential function with base 2, the second data is subjected to the exponential function operation. The numerical range of the second data is [0, 1). The numerical range of the calculated exponential function result is [1, 2). When the exponential function calculation result is normalized, the implicit 1 in the tail part is removed. Then the exponential function calculation result of the second data is corrected to [0, 1), without affecting the exponential part of the exponential function calculation result.

[0048] The exponent part of the exponential function calculation result can be determined from the first data. The first processing result is the mantissa part of the exponential function calculation result. The exponential function calculation result includes the exponent part and the mantissa part. The computer device can determine the exponential function calculation result through the fourth processing result and the first processing result.

[0049] In summary, by splitting the fixed-point number obtained from the exponent conversion of the exponent function, using the integer part of the fixed-point number as the first data and the decimal part as the second data, the exponent of the calculated exponent function can be determined based on the first data. B-spline curve fitting based on the second data yields the mantissa of the calculated exponent function. The exponent and mantissa together form the final exponent function result, avoiding data format conversion and reducing the latency caused by it. Furthermore, the B-spline curve fitting uses partial sum array calculations, allowing the same partial sum array to be used for calculating exponent functions in different data formats, thus enabling the calculation of exponent functions in various data formats.

[0050] The data processing method provided in the above embodiments can be used for image processing. The input data can be image data represented by low-bit-width floating-point numbers. During image rendering, the input data is calculated using an exponential function.

[0051] The data processing method provided in the above embodiments can also be used in artificial intelligence acceleration scenarios. The input data can be attention scores represented by low-bit-width floating-point numbers. When the score vector is converted into a probability distribution in the model output layer, an exponential function is performed on the input data.

[0052] The data processing method provided in the above embodiments can also be used in scientific computing scenarios. The input data can be physical variables represented using low-bit-width floating-point numbers. When solving differential equations containing exponential decay or growth terms, the input data is calculated using an exponential function. In some embodiments, when the computer device converts the input data into first data and second data, after converting the input data into fixed-point numbers, the integer part of the fixed-point number is determined as the first data, and the fractional part of the fixed-point number is determined as the second data. The first data is the integer part of the fixed-point number obtained by converting the input data, and the second data is the fractional part of the fixed-point number obtained by converting the input data.

[0053] In some embodiments, when a computer device converts input data into first data and second data, it retains 4 bits for the first data and 10 bits for the second data.

[0054] It is worth noting that the number of bits retained in the first and second data obtained by conversion in this application embodiment is only for illustrative purposes, and this application embodiment does not limit the number of bits retained in the first and second data obtained by conversion.

[0055] This is illustrative; the input data is in FP16 format, and the input data is 0x3E00. The process of converting the input data to a fixed-point number is as follows: 1. Convert 0x3E00 to the corresponding binary sequence: 0011 1110 0000 0000.

[0056] 2. Based on the binary bit sequence of the input data, the sign part is 0, the exponent part is 01111, and the mantissa part is 10 0000 0000. That is, the input data is a positive number, and the exponent is 15 - 15 = 0, where the subtracted 15 is the bias value. The bias value is a technique introduced to represent the exponent part of floating-point numbers, allowing for a wider range of data representation. The mantissa of the input data is:

[0057] 3. The fixed-point number obtained by transforming the input data is:

[0058] 4. The integer part of the fixed-point number is 1, and the fractional part is 0.5. Keep 4 bits of the integer part, which is 0001, and convert it to hexadecimal as 0x1. Keep 10 bits of the fractional part, which is 10 0000 0000, and convert it to hexadecimal as 0x200.

[0059] In some embodiments, after obtaining the binary bit sequence represented by the input data, the sign part, exponent part, and mantissa part are obtained respectively. The binary bit sequence data represented by the input data is then converted into a fixed-point number. The fixed-point number is then rounded down to obtain the integer part of the fixed-point number. The fractional part of the fixed-point number is obtained by subtracting the integer part from the fixed-point number.

[0060] To illustrate, after converting the input data to a fixed-point number using the `signed_value` function, the integer part of the fixed-point number is obtained by using the `floor` function to round it down. Then, the integer part of the fixed-point number is subtracted from the integer part to obtain the decimal part.

[0061] After converting the input data into first data and second data, the first data is the integer part of the fixed-point number obtained from the input data conversion, and the second data is the decimal part of the vertex number obtained from the input data conversion. Performing an exponential function calculation on the input data is then converted to performing exponential function calculations on the first and second data separately, and multiplying the results of the two exponential function calculations. As shown below:

[0062] As shown in formula (4), For input data, As the first data, This is the second data point.

[0063] This is illustrative; when the input data is 1.5, the first data obtained from the input data is 1, and the second data is 0.5. The calculation... Convert to calculation .

[0064] The second data is determined by the decimal part of the fixed-point number obtained by converting the input data, and the value range of the second data is [0, 1). According to the formula for calculating the exponential function, when the value range of the exponent is [0, 1), the calculated result of the exponential function is between 1 and the base of the exponential function.

[0065] To illustrate, if we calculate an exponential function with base 2, then we perform the exponential function operation on the second data, where the value range of the second data is [0, 1), and the value range of the calculated exponential function result is [1, 2).

[0066] In some embodiments, the output is a normalized result. In this case, the exponential function result of the second data needs to have the integer part of 1 discarded. The result of the exponential function of the second data after discarding is then between 0 and 1. Multiplying the result of the exponential function of the second data with the result of the exponential function of the first data in this case allows us to conveniently use the discarded result of the exponential function of the second data as the mantissa. Since the first data is an integer, we can conveniently obtain the exponent part of the exponential function calculation result.

[0067] In some embodiments, since the process of determining control points in B-spline curve fitting is relatively complex, in order to reduce the workload of determining control points, control points are recorded in a lookup table, and control points can be quickly determined based on input data, thus accelerating the B-spline curve fitting process.

[0068] Figure 4 This is a flowchart of a data processing method provided in another illustrative embodiment of this application. The method can be executed by the computer device described above. As shown in the figure, step 330 can also be implemented as steps 332 and 334.

[0069] Step 332: Determine the control points and curve parameters of the fitting curve of the exponential function based on the second data. The control points are used to determine the shape of the fitting curve, and the curve parameters are used to calculate the corresponding function values ​​on the fitting curve.

[0070] The control points for the fitted curve of the exponential function are determined based on the second data. These control points are used to determine the shape of the fitted curve of the exponential function.

[0071] Control points constitute the set of parameters used to define the spatial shape of the B-spline curve. These control points are linearly combined through B-spline basis functions, and together determine the shape of the fitted curve of the exponential function.

[0072] To illustrate, let's take a quadratic B-spline curve as an example, given three control points. Substituting these three control points into the quadratic B-spline fitting curve formula yields a unique quadratic fitting function, thus uniquely determining the curve equation and generating a specific quadratic curve segment.

[0073] Based on the second data, the curve parameters of the fitted curve of the exponential function are determined. The curve parameters are used to calculate the corresponding function value on the fitted curve of the exponential function.

[0074] After determining the fitting curve of the exponential function using control points, the coordinates of the second data on the fitting curve of the exponential function are obtained by substituting the curve parameters into the formula for the fitting curve of the exponential function, thus obtaining the calculation result of the exponential function for the second data.

[0075] Control points are used to determine a fitted curve, but the approximate calculation result of the exponential function cannot be obtained from the curve alone. Substituting the curve parameters into the formula for the fitted curve of the exponential function, the coordinates of the second data point on the fitted curve of the exponential function are obtained, thus yielding the approximate calculation result of the second data on the fitted curve of the exponential function.

[0076] like Figure 5 The diagram illustrates a flowchart of a control point and fitting curve determination process provided in an illustrative embodiment of this application. The process includes the following steps: Step 501: Divide the second data into first sub-data, second sub-data and third sub-data according to bit position. In the second data, the first sub-data has a higher bit position than the second sub-data, and the second sub-data has a higher bit position than the third sub-data. The third sub-data is the curve parameter.

[0077] The first, second, and third sub-data are divided into bits based on the second data, and the first, second, and third sub-data occupy the high, middle, and low bits of the second data, respectively. The sum of the number of bits of the first, second, and third sub-data is the same as the number of bits of the second data.

[0078] like Figure 6The diagram illustrates a schematic representation of a second data segmentation based on bit positions, provided in an exemplary embodiment of this application. The second data consists of 10 bits, from bit 0 to bit 9. Bits 6 to 9 of the second data are designated as the first sub-data, bits 4 and 5 as the second sub-data, and bits 0 to 3 as the third sub-data. The first sub-data has a higher bit position than the second sub-data, and the second sub-data has a higher bit position than the third sub-data. The first sub-data has 4 bits, the second sub-data has 2 bits, and the third sub-data has 4 bits. The sum of the bit positions of the first, second, and third sub-data is the same as the number of bits in the second data.

[0079] In this embodiment, the second data is 0x200, and the binary sequence corresponding to the second data is 10 00000000. The 6th to 9th bits of the binary sequence corresponding to the second data are determined as the first sub-data, represented as 1000 in binary and 0x8 in hexadecimal; the 4th to 5th bits of the binary sequence corresponding to the second data are determined as the second sub-data, represented as 00 in binary and 0x0 in hexadecimal; and the 0th to 3rd bits of the binary sequence corresponding to the second data are determined as the first sub-data, represented as 00 in binary and 0x0 in hexadecimal.

[0080] This application uses an example where the first sub-data is 0x8, the second sub-data is 0x0, and the third sub-data is 0x0.

[0081] In some embodiments, the number of bits in the second data is counted from bit 0 to bit 9, for a total of 10 bits. A function is used to select bits 6 through 9 of the second data as the first sub-data, bits 4 through 5 of the second data as the second sub-data, and bits 0 through 3 of the second data as the third sub-data.

[0082] To illustrate, the `frac_part[i:j]` function is used to retrieve the j-th to i-th bits of the variable `frac_part`. The `frac_part[9:6]` function is used to retrieve the first sub-data, `frac_part[5:4]` is used to retrieve the second sub-data, and `frac_part[3:0]` is used to retrieve the third sub-data.

[0083] In other embodiments, the second data is divided into a first sub-data and a second sub-data by bits, where the first sub-data has more bits than the second sub-data, and the sum of the number of bits in the first and second sub-data is the same as the number of bits in the second data. In other words, it is only necessary to divide the second data into two parts.

[0084] To illustrate, the number of bits in the second data is counted from bit 0 to bit 9, totaling 10 bits. Bits 4 through 9 of the second data are taken as the first sub-data, and bits 0 through 3 of the second data are taken as the second sub-data. In other words, the high-order bits of the second data are used as the first sub-data, and the middle bits are used as the second sub-data.

[0085] The second data is the decimal part of the fixed-point number obtained by converting the input data. The first, second, and third sub-data can directly reflect some characteristics of the decimal part of the fixed-point number obtained by converting the input data.

[0086] The first sub-data occupies the high-order bits of the second data, and has the largest weight. Using the first sub-data, we can roughly represent the approximate range of the second data's value. The second sub-data occupies the middle-order bits of the second data. Adding the second sub-data to the first sub-data allows us to accurately represent the approximate range of the second data's value. The third sub-data occupies the low-order bits of the second data. Adding the third sub-data to the first and second sub-data allows us to fully represent the value of the second data.

[0087] Control points define a range on the fitted curve from the exponential function calculation result of the first data point, while the third sub-data point represents the low-order bits of the first data point. Using the third sub-data point as the curve parameter makes the determined range more accurate.

[0088] By dividing the first data into bits, we obtain the first sub-data, the second sub-data, and the third sub-data. Control points are determined based on the first and second sub-data, and curve parameters are determined based on the third sub-data, which improves the efficiency and accuracy of determining control points and curve parameters.

[0089] In some embodiments, the computer device determines the third sub-data as the curve parameter. That is, the low-order bits of the first data are used as the curve parameter. The first data is the fractional part of a fixed-point number obtained by converting the input data. The curve parameter can reflect some characteristics of the fractional part of the fixed-point number obtained by converting the input data.

[0090] Step 502: Based on the preset mapping relationship, determine the control points corresponding to the first sub-data and the second sub-data. The preset mapping relationship is the mapping relationship between the first sub-data and the second sub-data and the control points of the fitting curve of the exponential function.

[0091] By using the first and second sub-data to find control points from a lookup table containing the mapping relationship between the first and second sub-data and the control points of the fitted curve of the exponential function, the efficiency and accuracy of determining control points are improved.

[0092] The lookup table divides the fitted curve of the exponential function into multiple segments, each recording multiple control points. The second data is determined by the decimal part of the fixed-point number obtained from the input data. The value of the second data is between 0 and 1. In other words, the lookup table divides the fitted curve of the exponential function with an exponent of 0 to 1 into multiple segments, each recording multiple control points. These control points reflect a range of the calculated exponential function result for the second data on the fitted curve. Illustratively, when the second data is 0.5, the fitted curve segment corresponding to the control point corresponds to the fitted curve for an independent variable in the range of 0.45 to 0.55.

[0093] In some embodiments, the lookup table divides the fitted curve of the exponential function into 32 segments, each of which records 4 control points.

[0094] It is worth noting that the embodiments of this application do not limit the number of segments into which the lookup table divides the fitted curve of the exponential function, nor do they limit the number of control points recorded in each segment.

[0095] By using the first and second sub-data, the control point corresponding to the second data is determined to be located in one of the multiple curve segments in the lookup table, thereby obtaining the control point in that curve segment.

[0096] In this embodiment, the first sub-data is 0x8, the second sub-data is 0x0, and the third sub-data is 0x0. The computer device determines three control points, P0, P1, and P2, based on the first and second sub-data. The values ​​of the three control points are 0x351, 0x350, and 0x10, respectively. Here, all three control points refer to the mantissa portion of the floating-point number.

[0097] Performing an exponential function calculation on the second data, since the numerical range of the second data is [0, 1), the numerical range of the result of the exponential function calculation on the second data is [1, base). For example, the numerical range of the result of the exponential function calculation on the second data with base 2 is [1, 2). Based on determining the range of the exponential function calculation result, only the decimal part of the result is needed to determine the complete exponential function calculation result. Therefore, for floating-point data formats, only the mantissa portion needs to be retained in the control points, and the result of the exponential function calculation on the second data can be determined by using the mantissa portion in the calculation. For example, the floating-point FP16 format number 0x3E00, with the mantissa retained as the last 10 bits 10 0000 0000, is represented as the hexadecimal number 0x800.

[0098] In this embodiment, the example is taken where three control points, P0, P1, and P2, are found from the lookup table based on the first and second sub-data, and the values ​​of the three control points are 0x351, 0x350, and 0x10, respectively.

[0099] The first sub-data occupies the high-order bits of the second data, and has the largest weight. Using the first sub-data, we can roughly determine the approximate range of the second data's value. The second sub-data occupies the middle bits of the second data. Adding the second sub-data to the first sub-data allows us to determine the approximate range of the second data's value more precisely. Using both the first and second sub-data, we can determine that the control point corresponding to the second data lies within one of the multiple curve segments in the lookup table, thus obtaining the control point corresponding to that curve segment.

[0100] Step 334: Perform B-spline curve fitting based on control points and curve parameters to obtain the first processing result.

[0101] By determining the control points and surface parameters of the fitted curve of the exponential function based on the second data, and obtaining the first processing result based on the control points and surface parameters, the efficiency and accuracy of obtaining the first processing result are improved, and the efficiency of exponential function calculation is accelerated.

[0102] Control points are used to determine the shape of the fitted curve of the exponential function, and curve parameters are used to calculate the corresponding function values ​​on the fitted curve. After obtaining the control points, the shape of the fitted curve of the exponential function can be determined according to the B-spline curve fitting formula, thus determining the expression of the fitted curve. After obtaining the curve parameters, substituting the curve parameters into the expression of the fitted curve of the exponential function yields the fitted calculation result of the exponential function for the second data.

[0103] like Figure 7 As shown, a flowchart illustrating a B-spline curve fitting process provided in an illustrative embodiment of this application is presented. The process includes the following steps: Step 701: Perform B-spline curve fitting based on control points to obtain the fitted curve.

[0104] Control points are used to determine the shape of the fitted curve of the exponential function. After obtaining the control points, the shape of the fitted curve of the exponential function can be determined according to the B-spline curve fitting formula, thus determining the expression of the fitted curve of the exponential function. The B-spline curve fitting formula is illustrated below:

[0105] As shown in formula (5), For curve parameters, , , For control points.

[0106] Substituting the control points into the B-spline curve fitting formula yields the fitting curve for the exponential function.

[0107] Step 702: Based on the curve parameters and the fitted curve, perform partial sum array calculations to obtain the first processing result.

[0108] B-spline curve fitting includes addition and multiplication operations, with multiplication using partial sum arrays. Before performing multiplication using partial sum arrays, pre-calculation is required to obtain the results of the addition operations.

[0109] In some embodiments, the fitted curve is pre-calculated to obtain a second processing result. The pre-calculated processing result is used as input for partial and array calculations.

[0110] Schematic illustration, in the above B-spline fitting formula , , This is the addition operation in B-spline curve fitting, which requires pre-calculation before partial sum array calculation.

[0111] Because the hardware performs multiplication Multiplication is quite complex. To reduce hardware design complexity, a mathematical transformation is performed on the original formula, multiplying both sides by 2, resulting in the following formula:

[0112] By performing a mathematical transformation on the original formula—that is, multiplying both sides of the formula by 2—the multiplication operation of 0.5 is eliminated, resulting in a multiplication operation of 2. When performing this multiplication operation in hardware, only bit shifting is required. In other words, the hardware-complex multiplication operation of 0.5 is eliminated, and a hardware-friendly multiplication operation of 2, i.e., a bit shift operation, is performed. Its hardware resource overhead and computational complexity are far lower than the multiplication hardware required to perform the multiplication operation of 0.5.

[0113] Since multiplying both parts of the formula by 2 results in twice the expected result, simply dividing the calculated result by 2 gives the expected result.

[0114] After performing a mathematical transformation on the B-spline curve fitting formula, and multiplying both sides of the formula by 2, the addition operation becomes: , , .

[0115] In some embodiments, the addition operations performed by the computer device are respectively , , In other embodiments, the addition operation is performed as follows: , , .

[0116] In other embodiments, no mathematical transformation is performed on the B-spline curve fitting formula; that is, a multiplication operation of 0.5 is required in the formula, and the calculated result is the expected result.

[0117] It is worth noting that this application does not limit whether it is necessary to multiply both sides of the formula by 2 during the B-spline curve fitting process, and therefore this application does not limit the addition operation performed.

[0118] In this embodiment of the application, the mathematical transformation of the B-spline curve fitting formula is taken as an example. That is, the two sides of the formula are multiplied by 2. After B-spline curve fitting, the calculated result is divided by 2 to obtain the expected calculation result.

[0119] In calculation and The result of multiplication and sum and After multiplying the results, substitute the calculated result into the B-spline curve fitting formula after mathematical transformation to obtain the B-spline curve fitting result after mathematical transformation. Then divide the B-spline curve fitting result after mathematical transformation by 2 to obtain the partial sum array calculation result.

[0120] In some embodiments, the values ​​of control points P0, P1, and P2 are 0x351, 0x350, and 0x10, respectively, and all are data formats that only retain the mantissa of floating-point numbers. High-order bits are padded with 0 during alignment, and control points are used in the calculation.

[0121] The process of calculating P0 - 2P1 + P2 is illustrated as follows:

[0122] The process of calculating -P0+P1 is as follows:

[0123] The process of calculating P0+P1 is as follows:

[0124] In some embodiments, the addition operation in B-spline curve fitting based on control points yields floating-point numbers, with only the mantissa retained. In other embodiments, the addition operation in B-spline curve fitting based on control points yields integer results. This application does not limit the data format of the addition operation results obtained from B-spline curve fitting based on control points.

[0125] In some embodiments, The calculation result retains 3 significant bits. The calculation result retains 7 significant bits. The calculation result retains 12 significant bits.

[0126] In some embodiments, The calculation result retains 3 significant bits as 0x1. The calculation result, retaining 7 significant bits, is 0x7f. The calculation result retains 12 significant bits as 0xea1. This application embodiment does not limit the number of significant bits retained in the above calculation result.

[0127] In some embodiments, the second processing result includes respectively , , The result of the three addition operations.

[0128] In the B-spline curve fitting formula, since Less than 1, two After multiplication Less than , and When multiplying, the result of the multiplication operation will be smaller. It is not necessary to retain a large number of significant bits, that is to say The calculation result can retain fewer significant bits. Compared to and Multiply, and The result of multiplication is reduced less, so The effective bit ratio retained in the addition operation result The calculation result retains more significant bits, while No need to Multiplication means that the product will not become smaller. The calculation result can retain more significant bits.

[0129] In other embodiments, , , The calculation results retain the same 12 significant bits.

[0130] It is worth noting that the number of bits retained in the calculated second processing result in this application embodiment is only an illustrative example, and this application embodiment does not limit the number of bits retained in the calculated second processing result.

[0131] The embodiments of this application are as follows: The calculation result retains 3 significant bits as 0x1. The calculation result, retaining 7 significant bits, is 0x7f. The calculation result is retained with 12 significant bits set to 0xea1. This will be used as an example for explanation.

[0132] In some embodiments, when the computer device performs addition operations based on control points to obtain a second processing result, it also calculates the formula for fitting the B-spline curve. That is, to calculate the square of the curve parameters.

[0133] In some embodiments, the value of the curve parameter is 0, that is... If it is 0, then It is also 0.

[0134] In other embodiments, the curve parameter is not zero, i.e. If the value is not 0, it will be used when performing B-spline curve fitting. Retain 7 significant bits, and Retain 3 significant bits.

[0135] In the B-spline curve fitting formula Retain 3 significant bits. and Multiply, Also retain 3 significant bits. and Multiply, Retain 7 significant bits. It also retains 7 significant bits. That is... and The number of valid digits retained in the B-spline curve fitting formula and The number of significant bits retained by the other multiplier in the multiplication is relevant.

[0136] It is worth noting that the embodiments of this application address... and There is no limit to the number of valid bits retained.

[0137] In other embodiments, when the computer device performs addition operations based on control points to obtain a second processing result, it does not calculate the formula for fitting the B-spline curve. .

[0138] In this embodiment of the application, when performing addition operations based on control points to obtain the second processing result, the formula for fitting B-spline curves is also calculated. Let's take an example to illustrate.

[0139] In some embodiments, partial and array calculations are performed based on the second processing result and curve parameters to obtain the partial and array calculation results.

[0140] After obtaining the second processing result, it is necessary to perform multiplication operations in B-spline curve fitting according to the formula. The multiplication operation uses a partial sum array.

[0141] Indicatively, the multiplication operation in the B-spline curve fitting formula is: , .Will Calculation results and The calculation results are input into the partial array for partial and array calculations. The calculation results and The partial and array calculations are performed on the input part and array to obtain The calculation results. Calculation results and The calculation results are input into the partial array for partial and array calculations. The calculation results and Perform partial and array calculations on the input part and array to obtain... The calculation results.

[0142] like Figure 8 The diagram illustrates a flowchart of a partial and array computation process provided in an illustrative embodiment of this application. The partial and array computation process includes the following steps: Step 801: Obtain the low-order bits of m1_a.

[0143] Based on the required calculation precision, the least significant bit of m1_a is taken as the significant bit for calculation.

[0144] Step 802: Obtain the low-order bits of m1_b.

[0145] Based on the required calculation precision, the least significant bit of m1_b is taken as the significant bit for calculation.

[0146] It is worth noting that the execution order of steps 801 and 802 is not important, and the embodiments of this application do not limit the execution order of steps 801 and 802.

[0147] Step 803: Obtain the array precision mask based on the partial and array precision.

[0148] In some embodiments, based on a partial and array precision of w3, As a partial and array precision mask.

[0149] Step 804: Perform a multiply-accumulate operation on each bit of the multiplier, and perform a bitwise AND operation between the result of the multiply-accumulate operation and the partial sum array precision mask to obtain the partial sum array calculation result.

[0150] The following describes the implementation using parts and arrays. and Let's take multiplication as an example, using m1_a to represent it. The calculation result is represented by m1_b. The calculation results.

[0151] In the partial sum array calculation, each bit of m1_b is multiplied and accumulated with m1_a. For illustration, m1_a consists of 4 bits, a3a2a1a0, and m1_b also consists of 4 bits, b3b2b1b0. Therefore, the multiplication of m1_a and m1_b is converted to:

[0152] After obtaining the result of the multiply-accumulate operation, a bitwise AND operation is performed between the result and the partial sum array precision mask to obtain the partial sum array calculation result. The partial sum array precision mask is as follows: By performing a bitwise AND operation between the multiply-accumulated result and the partial sum array precision mask, the number of bits in the calculated partial sum array is the same as the partial sum array precision w3.

[0153] Step 805: Add symbols to correct normal values.

[0154] In some embodiments, a first processing result is obtained based on the partial sum array calculation result. First, the sum of the partial sum array calculation result and the compensation term is calculated. The compensation term is determined by the fifth processing result involved in the partial sum array calculation and the number of bits of the curve parameters.

[0155] The compensation terms include sign-correction constants, high-order bias constants, and carry-over compensation terms.

[0156] The partial sum array used in this application uses multipliers and multiplicands in two's complement format, with negative weight terms introduced into their sign bits. To maintain unsigned multiplication in the partial sum array while ensuring the final calculation result is consistent with the theoretical multiplication result, this application sequentially introduces a sign correction constant, a high-bit bias constant, and a carry compensation term during the partial sum array calculation process. All three types of constants are connected in fixed bit line form, and the compensation term is automatically added during the calculation process.

[0157] By adding a compensation term after obtaining the partial sum array calculation results, the deviation value caused by the introduction of a negative weight term in the sign bit during the partial sum array calculation process is corrected, thereby improving the efficiency and accuracy of the calculation to determine the first processing result.

[0158] Indicatively, let the curve parameter be the multiplier A (M bits), and one of the values ​​in the fifth processing result be the multiplier B (N bits), both in two's complement. The accumulator bit width is W, and W>=M+N. Then A and B can be represented as:

[0159]

[0160] but The product expands to:

[0161]

[0162]

[0163]

[0164]

[0165] Subtraction is involved, but implementing subtraction in hardware is quite complex. To eliminate subtraction, the negative term is replaced by an equivalent transformation of the modulus. The fourth term only has a positive term and requires no additional operation.

[0166] Schematic, for any negative term -X, we have the following transformation:

[0167] The above equivalent transformation methods are applied to the calculation formulas for T1, T2, and T3 respectively:

[0168]

[0169]

[0170] In this formula, the first term on the right is a positive term that can be generated in unsigned computation, and the second term is a fixed constant that can be statically selected as zero or non-zero by the sign bit levels of both parties. Since the sign bit is involved in the operation in formula T1, and the sign of the sign bit is not determined, T1 may also include a negative term.

[0171] All of the equivalent transformations The components are partially split according to their magnitude, and constants are used to map them to three types of compensation terms: 1. The largest magnitude after splitting As a high-level bias constant.

[0172] 2. The lower-order fractions after splitting As a symbolic normalizer.

[0173] 3. Split the... As a carry compensation term, it is used to perform the addition of one in the inversion and addition operations in the modulo operation.

[0174] A sign-correcting constant is added to the partial and array calculation results to correct low-order deviations in the partial and array calculation results.

[0175] Step 806: Add high-order bias constant.

[0176] A high-order bias constant is added to the partial sum array calculation results to correct the high-order deviations in the partial sum array calculation results.

[0177] Step 807: Add carry compensation item.

[0178] A carry compensation term is added to the partial sum array calculation result to perform the addition of one in the inversion and addition operations in the modulo operation.

[0179] By adding the sign-modifying constant, the high-order bias constant, and the carry compensation term to the partial sum array calculation results, the exponential function calculation results in two's complement form are obtained.

[0180] In some embodiments, the result of the exponential function calculation obtained from the two's complement form is converted into the original code form.

[0181] Figure 9 This is a schematic diagram of a partial product device provided in an illustrative embodiment of the present application, used to perform the above-described partial calculation process. The partial product device 900 includes a first partial product 910, a second partial product 920, and a compensation term 930.

[0182] After performing partial sum array calculations on the first partial sum array 910 and the second partial sum array 920, the partial sum array device 900 adds a compensation term 930 to obtain the first processing result. The compensation term 930 includes a sign correction constant, a high-bit bias constant, and a carry compensation term.

[0183] After calculating the partial sum array result, in order to obtain the first processing result of the mantissa part of the exponential function calculation result, the partial sum array calculation result needs to be processed.

[0184] In some embodiments, the sum of the partial sum and array calculation results and the compensation term is truncated, and the tail portion of the partial sum and array calculation results is retained to obtain a third processing result.

[0185] In some embodiments, after obtaining the partial sum array calculation result, if the numerical range of the partial sum array calculation result is greater than 1, it is necessary to remove the integer part of the partial sum array calculation result and only retain the mantissa part of the partial sum array calculation result.

[0186] Since the numerical range of the second data is [0, 1), the numerical range of the result of the exponential function calculation of the second data is [1, base). Illustratively, calculating the exponential function with base 2, the numerical range of the result of the exponential function calculation of the second data is [1, 2). The mantissa of the normalized floating-point number contains an implicit 1. After removing the implicit 1 from the mantissa of the result of the exponential function calculation of the second data, the remaining mantissa is the mantissa of the normalized floating-point number. Therefore, by removing the integer part from the partial and array calculation results and retaining only the mantissa, the third processed result is the mantissa of the normalized floating-point number with the implicit 1 removed.

[0187] In some embodiments, the number of bits in the third processing result is truncated to the number of bits in the data format used by the input data to obtain the first processing result.

[0188] In some embodiments, after obtaining the third processing result, if the number of bits in the third processing result exceeds the number of bits in the mantissa of the FP16 format, the mantissa of the third processing result needs to be truncated to retain an appropriate number of bits.

[0189] The first processing result is the mantissa of the result calculated by the exponential function. The number of mantissas in the result calculated by the exponential function is fixed. If the number of mantissas in the third processing result exceeds the number of mantissas in the result calculated by the exponential function, the number of mantissas to be retained in the third processing result needs to be determined based on the number of mantissas in the result calculated by the exponential function.

[0190] In some embodiments, the data format of the input data is the same as the data format of the exponential function calculation result, and therefore the number of mantissas in the input data format is the same as the number of mantissas in the exponential function calculation result. The number of mantissas to be retained in the exponential function calculation result needs to be determined based on the number of mantissas in the input data format; that is, the number of mantissas to be retained in the third processing result needs to be determined based on the number of mantissas in the input data format. In other embodiments, the data format of the input data is different from the data format of the exponential function calculation result.

[0191] This application example illustrates the use of the same data format for the input data as the data format used for the exponential function calculation result.

[0192] In this embodiment, the input data adopts the FP16 data format. The FP16 format has a 1-bit sign bit, a 5-bit exponent bit, and a 10-bit mantissa bit. Therefore, the third processing result is retained as 10 bits.

[0193] In some embodiments, the calculated third processing result is a signed number, and the third processing result is retained as the first processing result by retaining 10 bits starting from the first bit after the sign bit.

[0194] For illustration, the third processing result is 0x3518. The third processing result is calculated from bit 0 to bit 15, a total of 16 bits, where bit 15 is the sign bit of the partial sum array calculation result. Bits 5 to 14 of the third processing result, 0x1a8, are extracted as the first processing result.

[0195] By performing two truncation processes on the sum of the partial sum array calculation results and the sum of the compensation terms, the data format of the mantissa of the processed partial sum array calculation results is the same as that of the input data, which improves the efficiency and accuracy of obtaining the first processing result.

[0196] In some embodiments, when calculating the fourth processing result based on the first data, the bias value is first determined based on the number of exponent bits of the data format used by the output data.

[0197] In this embodiment, the input data is in FP16 format, with 5 bits as the exponent and a bias value of 15. The formula for calculating the bias value is as follows:

[0198] As shown in formula (6), The number of bits in the exponent part of a floating-point number. This is the calculated bias value.

[0199] Computer equipment can calculate the bias value based on the number of exponents in the data format used by the input data. Illustratively, when the input data is in FP16 format, the bias value calculation process is as follows:

[0200] The calculated bias value is 15.

[0201] After obtaining the bias value, the sum of the first data and the bias value is determined as the fourth processing result.

[0202] According to formula (2), the exponent part of the FP16 format uses an encoding scheme with a fixed bias value during storage, that is, using... The exponent is represented by the index. Therefore, in order to generate exponential function calculation results that conform to the standard format, a bias value needs to be added to the true exponent. This yields the exponent in FP16 format.

[0203] After obtaining the true exponent of the exponential function calculation, an offset value needs to be added to obtain the exponent in FP16 format. The first data is the integer part of the fixed-point number obtained by converting the input data, which is also the true exponent of the exponential function calculation. After adding the offset value to the first data, the fourth processing result is obtained, which is the exponent part of the exponential function calculation.

[0204] By determining the sum of the first data and the bias value as the fourth processing result, the difference between the first data and the exponential part of the exponential function calculation result is corrected, thereby improving the efficiency and accuracy of determining the fourth processing result.

[0205] In some embodiments, when generating the exponential function calculation result based on the fourth processing result and the first processing result, the fourth processing result is first shifted left by one number to obtain the fifth processing result, where the first number is the number of digits in the data format used by the input data.

[0206] The fourth processing result is the exponent part of the exponential function calculation result, and the first processing result is the mantissa part of the exponential function calculation result. Shifting the fourth processing result left by one bit results in the fifth processing result, where the exponent part of the exponential function calculation result is in the correct bit position.

[0207] After obtaining the fifth processing result, a bitwise OR operation is performed between the fifth processing result and the first processing result to obtain the exponential function calculation result.

[0208] By performing a left shift operation on the fourth processing result and then performing a bitwise OR operation with the first processing result, the result of the exponential function calculation is obtained, which improves the efficiency and accuracy of obtaining the result of the exponential function calculation.

[0209] In some embodiments, when the exponential function calculation result is obtained based on the fourth processing result and the first processing result, the sign bit of the exponential function calculation result is determined to be 0 by default, that is, the sign of the exponential function calculation result is positive.

[0210] According to the properties of exponential functions, regardless of the value of the exponent, the result of an exponential function is always a positive number. For example, when calculating an exponential function with base 2, the graph of the base 2 exponential function confirms that the result is always positive.

[0211] Indicatively, when the fourth processing result is 0x1 and the first processing result is 0x1a8, the fourth processing result is shifted left by 10 bits to obtain 0x4000. 0x4000 is then bitwise ORed with 0x1a8 to obtain 0x41a8. The sign bit is then set to 0, resulting in the exponential function calculation result of 0x41a8.

[0212] In summary, by splitting the fixed-point number obtained from the exponent conversion of the exponent function, using the integer part of the fixed-point number as the first data and the decimal part as the second data, the exponent of the calculated exponent function can be determined based on the first data. B-spline curve fitting based on the second data yields the mantissa of the calculated exponent function. The exponent and mantissa together form the final exponent function result, avoiding data format conversion and reducing the latency caused by it. Furthermore, the B-spline curve fitting uses partial sum array calculations, allowing the same partial sum array to be used for calculating exponent functions in different data formats, thus enabling the calculation of exponent functions in various data formats.

[0213] By using a lookup table, the control points of the fitted curve of the exponential function can be quickly determined, reducing the workload of calculating control points, accelerating the B-spline curve fitting process, and improving the computational efficiency of data processing.

[0214] like Figure 10 The diagram illustrates a flowchart of an exponential function calculation process provided in an exemplary embodiment of this application. The exponential function calculation process includes: Step 1010: Input data.

[0215] When performing exponential function calculations, the first step is to obtain the exponent of the function to be calculated.

[0216] Step 1020: Convert floating-point to fixed-point.

[0217] After obtaining the input data, the input data is converted into a fixed-point number, and the integer part and decimal part of the fixed-point number are obtained based on the fixed-point number.

[0218] Step 1030: Find the control point based on the decimal part of the fixed point number.

[0219] Based on the decimal part of the fixed point, the control points of the fitted curve of the exponential function are found from the lookup table. The control points are used to determine the shape of the fitted curve of the exponential function and perform B-spline curve fitting.

[0220] Step 1040, pre-calculation, generates partial sums of input.

[0221] After obtaining the control points, the addition operation in B-spline curve fitting is first performed using the control points. After the addition operation in B-spline curve fitting, the multiplier for the multiplication operation in B-spline curve fitting is obtained.

[0222] Step 1050, partial and array calculation.

[0223] After obtaining the pre-calculated results, input the pre-calculated results into the part and array, and perform the multiplication operation in B-spline curve fitting.

[0224] Step 1060: Generate the mantissa portion of the result of the exponential function calculation.

[0225] After obtaining the partial sum array calculation results, they need to be processed to conform to the format of the mantissa portion of the exponential function calculation results. This involves adding compensation terms and / or truncating the partial sum array calculation results to generate the mantissa portion of the exponential function calculation results.

[0226] Step 1070: Generate the exponential part of the result of the exponential function calculation based on the integer part of the fixed point.

[0227] The integer part of the fixed-point number is processed, and an bias value is added to the integer part of the fixed-point number to generate the exponential part of the exponential function calculation result.

[0228] Step 1080, output the result.

[0229] The result of an exponential function calculation includes an exponent part and a mantissa part. After obtaining the exponent part and mantissa part of the exponential function calculation result, the result of the exponential function calculation can be output correctly.

[0230] like Figure 11 As shown, this illustration depicts a schematic diagram of a data processing apparatus 1100 provided in another exemplary embodiment of this application. The data processing apparatus 1100 includes an input module 1110, a floating-point to fixed-point conversion module 1120, a control point lookup table module 1130, a pre-calculation module 1140, a partial sum array 1150, an exponent calculation module 1160, and an output module 1170. The data processing apparatus 1100 can perform operations such as... Figure 10 The calculation process of the exponential function is shown.

[0231] Among them, the input module 1110 performs the following: Figure 10 Step 1010 in the exponential function calculation process is shown; the floating-point to fixed-point module 1120 executes as follows: Figure 10 Step 1020 in the exponential function calculation process is shown; the control point lookup table module 1130 executes as follows: Figure 10 Step 1030 in the exponential function calculation process is shown; the pre-calculation module 1140 executes as follows: Figure 10 Step 1040 in the exponential function calculation process shown; Part and array 1150 are performed as follows Figure 10 Steps 1050 and 1060 in the exponential function calculation process are shown; the exponential calculation module 1160 executes as follows: Figure 10 Step 1070 in the exponential function calculation process is shown; the output module 1170 executes as follows: Figure 10 Step 1080 in the calculation process of the exponential function is shown.

[0232] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0233] like Figure 12 As shown, it illustrates a schematic diagram of the structure of a data processing apparatus provided in an illustrative embodiment of this application, characterized in that the apparatus includes a processing module 1210, a calculation module 1220, and a generation module 1230; Processing module 1210 is configured to convert input data into first data and second data, where the input data is the exponent of an exponential function, the first data is the integer part of a fixed-point number obtained by converting the input data, and the second data is the decimal part of a fixed-point number obtained by converting the input data. The calculation module 1220 is configured to perform B-spline curve fitting based on the second data to obtain the first processing result, wherein the B-spline curve fitting is implemented by partial sum array calculation; The generation module 1230 is configured to generate an exponential function calculation result based on the first data and the first processing result; wherein the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

[0234] The calculation module 1220 is also configured to determine the control points and curve parameters of the fitting curve of the exponential function based on the second data. The control points are used to determine the shape of the fitting curve, and the curve parameters are used to calculate the corresponding function values ​​on the fitting curve. B-spline curve fitting is performed based on control points and curve parameters to obtain the first processing result.

[0235] The calculation module 1220 is also configured to divide the second data into a first sub-data, a second sub-data, and a third sub-data according to bits, wherein the first sub-data has higher bits than the second sub-data, the second sub-data has higher bits than the third sub-data, and the third data is a curve parameter; Based on the preset mapping relationship, the control points corresponding to the first sub-data and the second sub-data are determined. The preset mapping relationship is the mapping relationship between the first sub-data and the second sub-data and the control points of the fitted curve of the exponential function.

[0236] The calculation module 1220 is also configured to perform B-spline curve fitting based on control points to obtain the fitted curve; Based on the curve parameters and the fitted curve, partial sum array calculations are performed to obtain the first processing result.

[0237] The calculation module 1220 is also configured to pre-calculate the fitted curve to obtain a second processing result; Based on the second processing result and curve parameters, partial sum and array calculations are performed to obtain the partial sum and array calculation results. The partial and array calculation results are compensated and truncated to obtain the first processed result.

[0238] The calculation module 1220 is also configured to be the sum of the calculation results of the calculation part and the array, and the compensation term is determined by the number of bits of the data involved in the calculation of the calculation part and the array. The partial sum array calculation result and the sum of the compensation term are truncated to the number of bits in the data format used by the input data. The partial sum array calculation result and the sum of the compensation term are truncated, and the last part of the partial sum array calculation result is retained to obtain the third processing result. The number of digits in the third processing result is truncated to the number of digits in the data format used by the input data to obtain the first processing result.

[0239] The calculation module 1220 is also configured to determine the bias value based on the number of exponents in the data format used by the input data; The sum of the first data and the bias value is determined as the fourth processing result; The exponential function calculation result is generated based on the fourth processing result and the first processing result, and the exponential part of the exponential function calculation result is the fourth processing result.

[0240] The generation module 1230 is also configured to shift the fourth processing result to the left by one number to obtain the fifth processing result, where the first number is the number of digits in the data format used by the input data; The fifth processing result is bitwise ORed with the first processing result to obtain the result of the exponential function calculation.

[0241] The processing module 1210 can be a structure with floating-point to fixed-point conversion function, which can be implemented by a hardware unit containing shift registers and rounding logic. The calculation module 1220 can be a structure with partial sum array calculation function, which can be implemented by a hardware unit consisting of a multiplier array, an adder tree, and an accumulator register. The generation module 1230 can be a structure with data concatenation function, which can be implemented by a hardware unit consisting of a multiplexer, a shifter, and concatenation logic.

[0242] In summary, by splitting the fixed-point number obtained from the exponent conversion of the exponent function, using the integer part of the fixed-point number as the first data and the decimal part as the second data, the exponent of the calculated exponent function can be determined based on the first data. B-spline curve fitting based on the second data yields the mantissa of the calculated exponent function. The exponent and mantissa together form the final exponent function result, avoiding data format conversion and reducing the latency caused by it. Furthermore, the B-spline curve fitting uses partial sum array calculations, allowing the same partial sum array to be used for calculating exponent functions in different data formats, thus enabling the calculation of exponent functions in various data formats.

[0243] For a detailed description of the data processing process performed by the above-mentioned data processing device, please refer to the embodiments of the above-mentioned data processing method. This embodiment will not be repeated here.

[0244] In some embodiments, the data processing apparatus in this application may be integrated into a chip. This application provides a chip that includes the data processing apparatus as provided in any of the above embodiments.

[0245] Optionally, the chip can be a processor, such as an AI processor, a CPU processor, or other processors with vector operation requirements (especially multi-issue and vector branch operation requirements), and this application embodiment does not limit this.

[0246] Please refer to Figure 13 This diagram illustrates a structural block diagram of a computer device 1300 provided in an exemplary embodiment of this application. The computer device 1300 may be a terminal or a server.

[0247] Typically, computer device 1300 includes a processor 1301 and a memory 1302.

[0248] Processor 1301 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1301 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). Processor 1301 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1301 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1301 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.

[0249] In some embodiments, the processor 1301 may integrate the data processing device provided in the above embodiments. When there is a need to calculate an exponential function, the data processing device can be used to perform the data processing calculation task.

[0250] The memory 1302 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 1302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices.

[0251] In some embodiments, the computer device 1300 may also optionally include a peripheral device interface 1303 and at least one peripheral device.

[0252] Those skilled in the art will understand that Figure 13 The structure shown does not constitute a limitation on the computer device 1300, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0253] On the other hand, embodiments of this application provide a chip that can be loaded and executed to implement the data processing method provided in the embodiments of this application as described above.

[0254] On the other hand, embodiments of this application provide a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement the data processing method provided in the embodiments of this application as described above.

[0255] On the other hand, embodiments of this application provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the data processing method provided in the embodiments of this application described above.

[0256] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0257] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A data processing method, characterized in that, The method includes: The input data is converted into first data and second data, wherein the input data is the exponent of an exponential function, the first data is the integer part of a fixed-point number obtained by converting the input data, and the second data is the fractional part of a fixed-point number obtained by converting the input data. The second data is fitted with a B-spline curve to obtain the first processing result, wherein the B-spline curve fitting is achieved by partial sum array calculation; An exponential function calculation result is generated based on the first data and the first processing result; wherein, the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

2. The method according to claim 1, characterized in that, The step of performing B-spline curve fitting on the second data to obtain the first processing result includes: Based on the second data, the control points and curve parameters of the fitting curve of the exponential function are determined. The control points are used to determine the shape of the fitting curve, and the curve parameters are used to calculate the corresponding function value on the fitting curve. Based on the control points and the curve parameters, B-spline curve fitting is performed to obtain the first processing result.

3. The method according to claim 2, characterized in that, The step of determining the control points and curve parameters of the fitted curve of the exponential function based on the second data includes: The second data is divided into a first sub-data, a second sub-data, and a third sub-data according to bits. The first sub-data has a higher bit position than the second sub-data, the second sub-data has a higher bit position than the third sub-data, and the third sub-data is the curve parameter. Based on a preset mapping relationship, the control points corresponding to the first sub-data and the second sub-data are determined. The preset mapping relationship is the mapping relationship between the first sub-data and the second sub-data and the control points of the fitting curve of the exponential function.

4. The method according to claim 2, characterized in that, The step of performing B-spline curve fitting based on the control points and the curve parameters to obtain the first processing result includes: Based on the control points, a B-spline curve is fitted to obtain the fitted curve; Based on the curve parameters and the fitted curve, partial sum array calculations are performed to obtain the first processing result.

5. The method according to claim 4, characterized in that, The step of performing partial sum array calculations based on the curve parameters and the fitted curve to obtain the first processing result includes: The fitted curve is pre-calculated to obtain the second processing result; Based on the second processing result and the curve parameters, partial sum and array calculations are performed to obtain the partial sum and array calculation results; The calculation results of the portion and array are compensated and truncated to obtain the first processing result.

6. The method according to claim 5, characterized in that, The compensation and truncation of the calculation results of the portion and the array to obtain the first processing result includes: The sum of the partial and array calculation results and the compensation term is calculated, wherein the compensation term is determined by the fifth processing result participating in the partial and array calculation and the number of bits of the curve parameter; The sum of the partial sum and array calculation results and the compensation term is truncated, and the last part of the partial sum and array calculation results is retained to obtain the third processing result; The first processing result is obtained by truncating the number of digits in the third processing result to the number of digits in the data format used by the input data.

7. The method according to any one of claims 1 to 6, characterized in that, The step of generating the exponential function calculation result based on the first data and the first processing result includes: The bias value is determined based on the number of exponent bits in the data format used by the input data; The sum of the first data and the bias value is determined as the fourth processing result; An exponential function calculation result is generated based on the fourth processing result and the first processing result, wherein the exponential part of the exponential function calculation result is the fourth processing result.

8. The method according to claim 7, characterized in that, The generation of the exponential function calculation result based on the fourth processing result and the first processing result includes: The fourth processing result is shifted left by one number to obtain the fifth processing result, where the first number is the last digit of the data format used by the input data; The fifth processing result is bitwise ORed with the first processing result to generate the exponential function calculation result.

9. A data processing apparatus, characterized in that, The device includes a processing module, a computing module, and a generation module; The processing module is configured to convert input data into first data and second data, wherein the input data is the exponent of an exponential function, the first data is the integer part of a fixed-point number obtained by converting the input data, and the second data is the fractional part of a fixed-point number obtained by converting the input data. The calculation module is configured to perform B-spline curve fitting based on the second data to obtain a first processing result, wherein the B-spline curve fitting is implemented using partial sum array calculation; The generation module is configured to generate an exponential function calculation result based on the first data and the first processing result; wherein the exponent part of the exponential function calculation result is determined by the first data, and the mantissa part of the exponential function calculation result is the first processing result.

10. A chip, characterized in that, The chip can be loaded and executed to implement the data processing method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the data processing method as described in any one of claims 1 to 8.

12. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, and a processor reads from and executes the computer program to implement the data processing method as described in any one of claims 1 to 8.