Interpolation method for realizing non-linear operator based on general processor and related product
By adopting the multi-order interpolation method in general processors, the problem of difficulty in taking into account both accuracy and performance in nonlinear function calculations is solved, and the number of segments and interval lengths are flexibly adjusted to meet the needs of different application scenarios, which improves the calculation Efficiency and precision.
Patent Information
- Application Number
- CN202410903104.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-11-22
AI Technical Summary
When processing nonlinear functions, it is difficult to take into account high-precision and high-performance computing. The lookup table method requires huge storage space and cannot control the calculation accuracy. The CORDIC method consumes a lot of hardware resources and is difficult to meet the needs of a general artificial intelligence accelerated computing platform. .
Adopting a segmented multi-order interpolation method based on a general processor, by determining the interpolation interval, segmented sub-pocket interval length and maximum absolute error, optimizing the segmented sub-pocket interval length, generating an interpolation table, realizing segmented interpolation of nonlinear operators, and flexibly adjusting segments The number of segments and interval lengths are balanced to calculate accuracy and performance.
It achieves a balance between computational accuracy and performance, reduces hardware resource requirements, improves computing efficiency and accuracy, and is suitable for nonlinear function calculations in different application scenarios.
Smart Images

Figure CN119003966A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to an interpolation method for implementing a nonlinear operator based on a general-purpose processor and related products. Background Art
[0002] In the approximate calculation of nonlinear functions, the lookup table method is a simple and effective method. Its core idea is to pre-calculate the target function value and store it in a data table. In the actual calculation process, these pre-stored values can be quickly accessed by direct or indirect retrieval. In the lookup table method, if the table directly stores the calculation results, zero-error result output can be achieved. Therefore, for numerical calculations within a limited range, this method shows extremely high accuracy and simplicity. However, as the numerical range expands, the required storage capacity will increase dramatically, resulting in a significant increase in the space complexity of the lookup table method. Figure 1 As shown in the direct lookup table, the input x is u bits and the output f(x) is v bits. To store all possible results, the lookup table requires 2 u ×v bits, as u and v increase, the required storage space will also increase. If 32-bit or 64-bit floating point numbers are used for calculation, the storage space occupied by the simple lookup table method will be very huge.
[0003] In order to alleviate the exponential growth problem of the storage space required for the lookup table, an indirect lookup table method can be used, that is, by performing a preprocessing step on the input data and a post-processing step on the retrieved table entry value. Figure 2 As shown, if both the pre-processing and post-processing units are simple and efficient, this comprehensive solution will show better performance in terms of cost-effectiveness compared to the traditional direct lookup table method, while alleviating the problem of exponential growth of the lookup table size to a certain extent.
[0004] The application of lookup tables effectively simplifies the hardware development process, reduces the complexity and cost of the design, verification and testing phases, and provides a certain degree of flexibility in the later stages of design. In addition, lookup tables also reduce the types and number of building blocks required in arithmetic system design, simplifying the entire design process. Lookup tables stored in read-only memory, especially those entries or data blocks that integrate error detection or error correction coding mechanisms, provide higher stability and reliability than traditional combinational logic circuits. This enhanced robustness effectively improves the reliability of the overall system.
[0005] In general, lookup tables have great advantages and appeal in practical applications. In VLSI, the density of memory is much higher than random logic, and the density of memory is gradually increasing, which will accommodate larger lookup tables. Lookup tables with a capacity of several megabits have been widely used in many modern application scenarios. As a flexible module in hardware, the lookup table can adapt to the computing tasks of multiple functions by loading different table values by utilizing readable and writable storage devices and reconfigurable peripheral logic, thereby increasing the flexibility of the system. This design not only facilitates system maintenance and repair, but also enables the system to more easily adapt to changes in technological advances and application requirements.
[0006] Nonlinear functions are widely used in neural network models. Although the nonlinear factors introduced by them can greatly improve the expressive power of the model, they put forward higher requirements on the calculation accuracy and performance of nonlinear functions. For general artificial intelligence acceleration computing platforms, how to calculate nonlinear functions efficiently and with high precision is a very big challenge. At present, the more accurate calculation method on hardware accelerators is the CORDIC method, but this method requires a lot of hardware resources to achieve high-speed and high-precision calculations, which brings huge challenges to the low-power design of chips. The lookup table method is highly flexible and has low hardware resource requirements when processing nonlinear functions, but it has very obvious disadvantages: it is impossible to control the calculation accuracy and the size of the lookup table, that is, it is difficult to balance high-precision and high-performance computing. Therefore, it is impossible to control the calculation accuracy and the size of the lookup table, that is, it is difficult to balance high-precision and high-performance computing. Summary of the invention
[0007] In order to solve the above-mentioned technical problems, the present disclosure proposes an interpolation method and related products for implementing a nonlinear operator based on a general-purpose processor.
[0008] To achieve the above object, the present disclosure provides an interpolation method for implementing a nonlinear operator based on a general-purpose processor, wherein the method comprises:
[0009] The general processor determines the interpolation interval according to the nonlinear function corresponding to the nonlinear operator;
[0010] The general processor determines the length of the segmented sub-interval according to the starting point of the interpolation interval, the ending point of the interpolation interval, and the number of segmented sub-intervals in the large interval in the interpolation interval; wherein the large interval corresponds to an interpolation table, and the interpolation interval is divided into at least one large interval; the interpolation table records the coefficients of the interpolation function corresponding to the segmented sub-intervals in the large interval;
[0011] The general processor determines the maximum absolute error of the segmented subinterval within the large interval according to the length of the segmented subinterval, compares the maximum absolute error with the absolute error limit, and optimizes the length of the segmented subinterval according to the comparison result;
[0012] The general processor determines the interpolation table corresponding to the large interval according to the optimized length of the segmented sub-interval, and completes the segmented interpolation of the nonlinear operator.
[0013] To achieve the above-mentioned purpose, the present disclosure provides an interpolation device for implementing a nonlinear operator based on a general-purpose processor, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein when the processor executes the computer program, the steps of the interpolation method for implementing a nonlinear operator based on a general-purpose processor are implemented.
[0014] To achieve the above objectives, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the above-mentioned interpolation method for implementing a nonlinear operator based on a general-purpose processor are implemented.
[0015] The segmented multi-order interpolation method used in the technical solution of the present invention can flexibly adjust the number of segments and the length of the segmented sub-intervals according to different actual application scenarios, thereby achieving a balance between calculation accuracy and performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.
[0017] Figure 1 To directly search for the intent;
[0018] Figure 2 To indicate intent for indirect search;
[0019] Figure 3 It is a schematic diagram of the relationship between the length of the segmented sub-interval and the calculation accuracy;
[0020] Figure 4 A flow chart of a piecewise interpolation method for implementing a nonlinear operator using a general-purpose processor disclosed in this application;
[0021] Figure 5 Optimize the flow chart for piecewise multi-order interpolation calculation;
[0022] Figure 6 This is one of the schematic diagrams of the lookup table device disclosed in this application;
[0023] Figure 7This is the second schematic diagram of the lookup table device disclosed in this application;
[0024] Figure 8 Schematic diagram of multi-segment function division. DETAILED DESCRIPTION
[0025] The technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. With reference to the non-limiting exemplary embodiments shown in the accompanying drawings and described in detail in the following description, the exemplary embodiments of the present disclosure and their various features and advantageous details are more fully described. It should be noted that the features shown in the figures are not necessarily drawn to scale. The present disclosure omits the description of known materials, components and process technologies so as not to obscure the exemplary embodiments of the present disclosure. The examples given are only intended to facilitate the understanding of the implementation of the exemplary embodiments of the present disclosure, and to further enable those skilled in the art to implement the exemplary embodiments. Therefore, these examples should not be construed as limiting the scope of the embodiments of the present disclosure.
[0026] Unless otherwise specifically defined, the technical terms or scientific terms used in the present disclosure shall have the usual meanings understood by persons with ordinary skills in the field to which the present disclosure belongs. The words "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. In addition, in various embodiments of the present disclosure, the same or similar reference numerals represent the same or similar components.
[0027] In conjunction with the accompanying drawings, a specific implementation manner of an interpolation method for implementing a nonlinear operator based on a general-purpose processor and related products provided by an embodiment of the present disclosure are described in detail below.
[0028] Although the lookup table method is simple and efficient, its main limitation is the large demand for storage space, which makes it only suitable for small-scale fixed-point operations or scenarios with lower precision requirements. In contrast, the polynomial approximation method provides a calculation method that avoids large-scale storage requirements, but its hardware implementation is relatively complex, which limits its feasibility in supporting high-order polynomials. In order to fully utilize the advantages of the two methods, the two methods can be combined, using a lookup table to store polynomial coefficients, reducing the complexity of the hardware circuit through repeated calculations, and using polynomial calculations greatly reduces the data required to store the lookup table.
[0029] Specifically, if the data used are all u bits, the interval is divided into three sections, and the polynomial used in each section is as follows: S(x) = ax 3 +bx 2 +cx+d can be transformed into S(x)=((ax+b)x+c)x+d.
[0030] Ideally, the coefficients of the polynomial are stored in a lookup table, and each time the coefficient is taken out, a multiplication and an addition operation are performed. Then the hardware only needs one multiplier and one adder to meet the calculation requirements, reducing the area of the hardware circuit. Because the lookup table stores the polynomial coefficients, its size is positively correlated with the order of the piecewise polynomial and the number of segmented intervals. In this example, the lookup table only takes up 12u bits. If the direct lookup table method is used, the storage space required is 2u×u bits.
[0031] This method pre-calculates and stores the polynomial coefficients corresponding to each sub-interval in a lookup table. During calculation, the hardware retrieves the corresponding polynomial coefficients from the lookup table for calculation. This method can be applied to different application scenarios, allowing the order of polynomial approximation and the division of segmented intervals to be adjusted according to specific needs, thereby achieving a balance between computational efficiency and accuracy.
[0032] It has been found that the truncation error of polynomial interpolation is closely related to the distance between interpolation nodes. Specifically, the interpolation error is affected by the distance between adjacent interpolation nodes: the larger the node distance, the larger the potential truncation error. In the piecewise interpolation method, the division of the segmented interval directly determines the construction of the piecewise polynomial, which in turn affects the approximation effect of the piecewise polynomial on the objective function. Next, we will explore in depth the relationship between the length of the segmented sub-interval and the calculation accuracy in the piecewise multi-order interpolation method.
[0033] First, in order to evaluate the approximation effect of the interpolation calculation method and quantitatively control the calculation error, this paper selects the maximum absolute error (MAE) and the mean absolute error (EA) as the core indicators for measuring the accuracy of approximate calculations. In particular, the maximum absolute error MAE is further used as the benchmark for error control. Their definitions are given by formula (1) and formula (2) respectively:
[0034] MAE=max|f(x)-approx| Formula (1)
[0035]
[0036] Where approx is the calculated approximation, f(x) is the target nonlinear function, and B is the number of input values.
[0037] Then, the relationship between the length of the segmented subinterval and the calculation accuracy in the piecewise linear interpolation method is analyzed. Assume that the objective function f(x) is second-order continuously differentiable on [xi,xi+1], and construct the functions Ei(x) and Fi(x):
[0038] E i (x) = f(x) - h i (x) Formula (3)
[0039]
[0040] Because F i (x) = F i (x i )=F i (x i+1 )=0, according to Rolle's middle value theorem, F′ i (s) There are at least two zeros in the interval [xi,xi+1], F″ i (s) has at least one zero, namely:
[0041]
[0042] Where w is F″ i The zero of (s), hi(s) is a first-order polynomial, so E i The expression of (x) is:
[0043]
[0044] Substitute equation (6) into equation (1):
[0045]
[0046] In the interval [a,b], we have
[0047]
[0048] in
[0049] From formula (8), we can see that the maximum absolute error of the piecewise linear interpolation function converges to the second order about the length of the segmented subinterval h. When h is smaller, the fitting degree of the piecewise linear interpolation function is better and the calculation accuracy is higher. However, formula (8) only gives the upper limit of the maximum error of the piecewise linear interpolation function. For some functions with good properties, a more accurate error calculation method can be used.
[0050] Since the cubic spline interpolation function has complex characteristics, its error formula is not easy to obtain. Therefore, the error estimation theorem of the cubic spline function is used to directly obtain the error estimation formula. The cubic spline function error estimation theorem is as follows:
[0051] Let f(x)∈C 4 [a,b], S(x) is a cubic spline function that satisfies the first or second boundary conditions. h i =x i+1 -x i (i=1,2,...,n), then we have the estimation formula:
[0052]
[0053] in,
[0054] The above theorem not only gives the maximum error upper limit of the cubic spline interpolation function S(x), but also shows that when the length h of the segmented subinterval approaches zero, S(x) and its first-order derivative S′(x) and second-order derivative S″(x) all converge to f(x), f′(x) and f″(x), respectively. The maximum absolute error of the cubic spline interpolation function S(x) converges to the fourth order with respect to the segmented subinterval length h.
[0055] In order to vividly show the relationship between the length of the segment interval and the calculation accuracy, this section selects the target nonlinear function f(x)1 / (1+e -x ) is analyzed, that is, the Sigmoid function is interpolated and approximated. In the interval [-8,8], piecewise polynomials are constructed using segmented subintervals of different lengths, and the maximum absolute error between these piecewise polynomials and the objective function is calculated. The results are as follows Figure 3 As shown in the figure, it can be observed that the computational accuracy of both piecewise linear interpolation and cubic spline interpolation increases as the length of the segmented subinterval decreases. In particular, the convergence speed of cubic spline interpolation in terms of accuracy improvement is faster.
[0056] In summary, the computational accuracy of the piecewise multi-order interpolation method converges with respect to the length of the piecewise subinterval. In the training of the neural network model, since higher computational accuracy is usually required, appropriately increasing the number of segments and shortening the subinterval length can improve the approximation effect. In the inference stage of the neural network model, computational efficiency is more critical, and the subinterval length can be appropriately increased and the number of segments can be reduced to increase the computational speed. The piecewise multi-order interpolation scheme used in the present disclosure can flexibly adjust the number of segments and the length of the piecewise subinterval according to different actual application scenarios, thereby achieving a balance between computational accuracy and performance.
[0057] Therefore, the length of the segmented sub-interval affects the calculation accuracy of the piecewise polynomial. The finer the interpolation interval is divided, the better the piecewise polynomial approximation effect on the target nonlinear function will be. However, it will increase the entries in the lookup table, which not only occupies hardware storage space but also slows down the calculation performance. Therefore, it is necessary to reasonably divide the interpolation interval to maximize the calculation performance while meeting the calculation accuracy requirements.
[0058] like Figure 4 As shown, the present application discloses an interpolation method for implementing a nonlinear operator based on a general-purpose processor. The method comprises:
[0059] Step 401): The general processor determines an interpolation interval according to a nonlinear function corresponding to the nonlinear operator.
[0060] In this embodiment, the piecewise first-order polynomial approximation is to use the linear polynomial h(x) to approximate the target nonlinear function f(x), and the approximate value calculated by the linear polynomial h(x) is used to replace the target function value. For a given absolute error limit E, the piecewise first-order polynomial can be calculated by the following calculation steps. In each subinterval [x i ,x i+1 ] satisfies the following relationship:
[0061]
[0062] Then, the interpolation interval of the target nonlinear function f(x) is [a,b].
[0063] In this embodiment, the piecewise third-order polynomial approximation is to use the cubic spline polynomial S(x) to approximate the target nonlinear function f(x), and replace the target function value with the value calculated by the cubic spline polynomial S(x). For a given absolute error limit E, the cubic spline polynomial can be calculated by the following calculation steps, so that the generated cubic spline polynomial S(x) satisfies the following relationship in the interval [a, b]:
[0064]
[0065] Similarly, the interpolation interval of the target nonlinear function f(x) is [a,b].
[0066] Step 402): The general processor determines the length of the segmented sub-interval according to the starting point of the interpolation interval, the ending point of the interpolation interval, and the number of segmented sub-intervals in the large interval in the interpolation interval; wherein the large interval corresponds to an interpolation table, and the interpolation interval is divided into at least one large interval; and the interpolation table records the coefficients of the interpolation function corresponding to the segmented sub-intervals in the large interval.
[0067] In this embodiment, in determining the length of the segmented subinterval within the large interval, the general processor compares the starting point of the interpolation interval and the ending point of the interpolation interval, determines whether the starting point of the interpolation interval is smaller than the ending point of the interpolation interval, and obtains a judgment result. If the judgment result is that the starting point of the interpolation interval is smaller than the ending point of the interpolation interval, the general processor determines the length parameter of the segmented subinterval according to the starting point of the interpolation interval, the ending point of the interpolation interval, and the number of segmented subintervals within the large interval in the interpolation interval, and uses the length parameter of the segmented subinterval to obtain the length of the segmented subinterval within the large interval. If the judgment result is that the starting point of the interpolation interval is greater than or equal to the ending point of the interpolation interval, it means that the interpolation operation of the interpolation interval is completed, and an interpolation table composed of coefficients of the interpolation function can be obtained.
[0068] Specifically, regardless of whether the interpolation function is a piecewise first-order polynomial or a piecewise multi-order polynomial, for the calculation interval [a, b] of the target non-linear function f(x), set the starting point start = a, the ending point end = b, the number of sub-intervals L = num, the absolute error limit E = error, and the table serial number k = 1, indicating the processing of the k-th large interval. Determine whether start is less than end. If start < end, obtain the initial value of n. n is used to calculate the length Δh of the sub-intervals, and its calculation formula is as follows:
[0069]
[0070] The length Δh of the sub-intervals = 2 n 。
[0071] It should be noted that the above-mentioned method for obtaining the weights of the state paths is only some of the examples, not an exhaustive list. Those skilled in the art may generate other deformations or transformations based on the essence of the technical solution of this application. However, as long as the functions achieved and the technical effects reached are similar to those of this application, they should all fall within the protection scope of this application.
[0072] In this embodiment, to meet the characteristics of the floating-point lookup table hardware, the calculation interval [a, b] of the target non-linear function f(x) is divided into multiple large intervals, and the length Δh of the sub-intervals in each large interval = 2 n 。Where n ∈ Z, the lengths of the sub-intervals in the same large interval are the same, and the lengths of the sub-intervals in different large intervals may be different.
[0073] Step 403): The general-purpose processor determines the maximum absolute error of the sub-intervals in the large interval according to the length of the sub-intervals, compares the maximum absolute error with the absolute error limit, and optimizes the length of the sub-intervals according to the comparison result.
[0074] In this embodiment, the steps for the general-purpose processor to optimize the length of the sub-intervals include:
[0075] If the comparison result is that the maximum absolute error of the sub-intervals is greater than the absolute error limit, then reduce the length of the sub-intervals in the large interval, and use the interpolation function corresponding to the reduced length of the sub-intervals and the non-linear function to determine the maximum absolute error of the current sub-intervals. Compare the maximum absolute error of the current sub-intervals with the absolute error limit, and determine whether to reduce the length of the sub-intervals in the large interval until the maximum absolute error of the current sub-intervals is less than or equal to the absolute error limit, and obtain the length of the sub-intervals that meets the limitation of the absolute error limit.
[0076] Specifically, when the interpolation function is a piecewise multi-order polynomial, such as third order, the coefficients of the piecewise polynomial are obtained by the length Δh of the piecewise sub-intervals. i ,x i+1 ], S i The expression of (x) is:
[0077] S i (x) = a i x 3 +b i x 2 +c i x+d i Formula (a)
[0078] It is easy to know that there are 4L unknowns in the L-segment interval, and 4L equations need to be solved, because the derivative of the cubic spline interpolation function is first-order continuous and second-order continuous, satisfying the following formula:
[0079]
[0080] There are 2L-2 equations in total. At the same time, at the interpolation nodes, the function value of the cubic spline is equal to the objective function value, and the L-1 interpolation points inside satisfy:
[0081]
[0082] The first and last interpolation nodes satisfy the first and last cubic spline functions respectively, with a total of 2L equations. Together with the previous equations, there are 4L-2 equations. In order to determine S(x), two conditions are added at the endpoints of the interval [a,b], which are called boundary conditions. Common boundary conditions are:
[0083] (1) The first-order derivative value of a given endpoint, that is, S′(x0)=y′0, S′(x n ) = y′ n .
[0084] (2) The second-order derivative value of the given endpoint, that is, S″(x0)=y″0, S″(x n )=y″ n In particular, S″(x0)=S″(x n )=0 is called the natural boundary condition.
[0085] (3) When f(x) is x n - When x0 is a periodic function, then S(x) is also required to be a periodic function. In this case, the boundary condition should satisfy S(x0+0)=S(x n -0), S′(x0+0)=S′(x n -0),S″(x0+0)=S″(xn -0). The spline function S(x) determined in this way is called a periodic spline function. Since y=f(x) is periodic to ba, f(a)=f(b), and thus S(x0+0)=S(x n -0). Therefore, in this boundary condition, the two equations that really work are the following.
[0086] Here we select the first type of boundary conditions. At this time, there are 4L equations in total, and the unknowns can be solved. For the convenience of calculation, let equation (a) be transformed into:
[0087] S i (x) = a′ i (xx i ) 3 +b′ i (xx i ) 2 +c i (xx i )+d i Formula (b)
[0088] Let k i =S″ i (x i ) = 2b′ i ,h i =x i+1 -x i , because the lengths of the sub-intervals in the same large interval are equal, so let Δh = h i ,Depend on
[0089]
[0090] We can get:
[0091]
[0092] Substitute equation (c) into the following equation:
[0093] S′ i (x i+1 ) = S′ i+1 (x i+1 )
[0094] We can get:
[0095]
[0096] Solve the system of equations and then solve for the unknown quantity k i , i=1,2,...,L. According to formula (a), calculate the coefficient a i ′,b i ′,c i ′ and di ', for the convenience of subsequent calculations, it is necessary to perform a certain transformation on the coefficients, that is, find the coefficients of formula (a), expand formula (b), and obtain the following equation:
[0097]
[0098] Calculate the maximum absolute error between the cubic spline function S(x) and the target non-linear function f(x). In each sub-interval [x i , x i+1 , let x = x i , step = 1, substitute x into F i (x) = |S i (x) - f(x)| for calculation, then convert x to hexadecimal, add step and then convert it to a floating-point number, and iteratively calculate F i (x) until x reaches x i+1 , and then take MAE = max(F(x)). If E ≥ maxerror, then the coefficients of the cubic spline function S(x) that satisfy the absolute error limit E are in formula (e). If E < maxerror, then set n = n - 1, and substitute the updated n into Δh = 2 n to reduce the length of the segmented sub-intervals. Further, determine the current corresponding interpolation function S(x) according to formulas (a), (b), (c), (d), and (e). Determine the maximum absolute error of the segmented sub-interval according to the current corresponding interpolation function S(x), compare the maximum absolute error of the current segmented sub-interval with the absolute error limit, and judge whether to reduce the length of the segmented sub-intervals within the large interval until the maximum absolute error of the current segmented sub-interval is less than or equal to the absolute error limit, and obtain the length of the segmented sub-intervals that meet the limitation of the absolute error limit.
[0099] Specifically, when the interpolation function is a piecewise multi-order polynomial, Δh = 2 n , let:
[0100]
[0101] In each segmented sub-interval [x i , x i+1 , calculate the coefficients of the linear function h i (x) = k i x + b i , that is, calculate the vectors and
[0102]
[0103] where k i and b iare the i-th subinterval [x i ,x i+1 The slope and intercept of ] are calculated by the following formula:
[0104]
[0105] In the interval [x i ,x i+1 ], let the error function F i (x) = f(x) - h i (x), calculate F i (x) in the interval [x i ,x i+1 ], where the extreme points are calculated by the following formula:
[0106] F′(x)=0
[0107] f′(x)=k i
[0108] The interval [x i ,x i+1 Substitute the extreme points and non-differentiable points in the error function F i (x) to find the point where the absolute value of the function is the largest, let μ i In the interval [x i ,x i+1 ], when x=μ i When , the maximum absolute error MAE between the piecewise linear function hi(x) and the target nonlinear function f(x) is obtained i , let MAE=max(MAE1,MAE2,...,MAE L ),like:
[0109]
[0110] Then find the length Δh of the segmented subinterval that meets the conditions, and equation (f) is the coefficient of the interpolation function S(x) that meets the absolute error limit E.
[0111] like: Set n=n-1 and substitute the updated n into Δh=2 n , thereby reducing the length of the segmented subinterval. Further determine the current corresponding interpolation function S(x) according to formula (f). Determine the maximum absolute error of the segmented subinterval according to the current corresponding interpolation function S(x), compare the current maximum absolute error of the segmented subinterval with the absolute error limit, and determine whether to reduce the length of the segmented subinterval in the large interval until the current maximum absolute error of the segmented subinterval is less than or equal to the absolute error limit, and obtain the length of the segmented subinterval that meets the limit of the absolute error limit.
[0112] Step 404): The general processor determines the interpolation table corresponding to the large interval according to the optimized length of the segmented sub-interval, and completes the segmented interpolation of the nonlinear operator.
[0113] Through the above steps, a piecewise polynomial that satisfies the absolute error limit E is generated in the interval [a, b]. The approximation effect of this piecewise polynomial on the target nonlinear function f(x) is controlled by the absolute error limit E. Subsequently, the polynomial coefficients will be transformed into equations to obtain a polynomial coefficient table that is actually usable.
[0114] In this embodiment, the scheme selects piecewise linear function or cubic spline function as interpolation function, adopts maximum absolute error as optimization target, and generates interpolation polynomials that meet predefined accuracy standards in the whole domain space through iterative calculation under the given absolute error limit. Under the premise of reasonably dividing the interpolation interval and meeting the calculation accuracy requirements, the calculation performance is maximized.
[0115] Figure 4 The disclosed solution has two challenges. The first challenge is that the interval [a, b] calculated by the piecewise multi-order interpolation method is finite, but the domain of the target nonlinear function f(x) may be infinite. The second challenge is that although the smaller the length of the segmented subinterval, the higher the calculation accuracy, the number of segments will increase, slowing down the calculation performance. How to further improve the calculation accuracy without reducing the length of the segmented subinterval.
[0116] In order to resolve the contradiction between the finiteness of the interpolation interval and the infinity of the definition domain of the target nonlinear function, the target nonlinear function f(x) needs to have good properties, such as asymptotes or periodicity. If the target nonlinear function does not have these properties, a finite interpolation interval [a, b] needs to be given explicitly. Next, the interpolation interval is converted from an infinite interval (-∞, +∞) to a finite interval [a, b] using the asymptotes or periodicity of the target nonlinear function f(x), and then approximated using a piecewise multi-order interpolation method.
[0117] In this embodiment, if the nonlinear function is a periodic function, a horizontal asymptote, or an oblique asymptote, the interpolation interval is converted from an infinite interval (-∞, +∞) to a finite interval. Further, specifically:
[0118] 1) The function is periodic
[0119] If the target nonlinear function f(x) is a periodic function, then it is only necessary to interpolate and approximate the function curve within a complete period or even a partial period, and the obtained piecewise interpolation polynomial can be reused for other periodic parts of the entire function. For example, for periodic functions such as sin(x) and cos(x), the interpolation interval can be converted from an infinite interval to a finite interval through periodicity. Let f(x) = sin(x), the input x can be equivalently replaced by x = 2πn+r, where n∈Z, rt∈[0,2π). From the periodicity of the sin(x) function, we can get:
[0120] sin(x)=sin(r)
[0121] Among them, r can be equivalently replaced by r = πm + j, where m∈{0,1}, j∈[0,π). So sin(r) = (-1) m ×sin(j)
[0122] Because the sin(x) function is and about Symmetry can be handled by the following changes:
[0123]
[0124] so:
[0125] sin(j)=sin(j′)
[0126] Through the above transformation, we only need to In the process, the target nonlinear function f(x) is calculated by piecewise multi-order interpolation.
[0127] 2) The function has horizontal asymptotes or oblique asymptotes
[0128] If the target nonlinear function f(x) approaches infinity with its independent variable, the function curve approaches a horizontal asymptote or an oblique asymptote, the calculation of the function value can be simplified in the area far from the origin. Specifically, when the independent variable of the target nonlinear function f(x) approaches positive and negative infinity, the function curve approaches a straight line, and the interval (-∞, +∞) can be divided into three parts, namely (-∞, a), [a, b] and (b, +∞). The piecewise multi-order interpolation method is used for calculation in the interval [a, b], and the asymptote value can be used to replace the target function value in the interval (-∞, a) and (b, +∞). For example, if the target nonlinear function f(x) = sigmoid(x), when x approaches negative infinity, its horizontal asymptote is y = 0; when x approaches positive infinity, its horizontal asymptote is y = 1. At this time, we need to determine the values of point a and point b. If the absolute error between the asymptote and the function value is set to be in the order of 10-7, the asymptote value is used to replace the function value for points beyond the interval [a, b].
[0129] |sigmoid(-16)-0|=1.12536*10 -7
[0130] |sigmoid(-16)-1|=1.12535*10 -7
[0131] Therefore, we can let a = -16, b = 16. Then, the target nonlinear function f(x) is approximated by piecewise multi-order interpolation in the interval [-16, 16].
[0132] Interpolation interval preprocessing effectively converts an infinite interpolation interval into one or several finite intervals. This not only reduces the number of polynomial coefficients that need to be stored, but also greatly improves the feasibility and computational efficiency of the entire interpolation process. Therefore, interval preprocessing is very effective when dealing with nonlinear functions with periodicity or asymptotes.
[0133] against Figure 4 For the technical solution shown in the figure, in order to further improve the approximation degree of the piecewise polynomial without reducing the length of the segmented subintervals. Figure 4 The scheme shown is improved to compensate the interpolation error to improve the calculation accuracy. In further detail, the general processor performs error compensation on the interpolation function corresponding to the nonlinear function to obtain a corrected interpolation function; wherein the interpolation table stores the coefficients of the corrected interpolation function.
[0134] Specifically, the general processor determines the nonlinear function corresponding to the nonlinear operator and the error distribution corresponding to the interpolation function. The general processor processes the error distribution to obtain a corresponding error curve; the general processor processes the error curve Figure 4 The method shown obtains the corresponding interpolation function; wherein the segmented interval points selected within the interpolation interval of the error curve are consistent with the segmented interval points selected within the interpolation interval of the nonlinear function corresponding to the nonlinear operator; the general processor adds the interpolation function corresponding to the error curve and the interpolation function corresponding to the nonlinear operator to obtain a corrected interpolation function.
[0135] In this embodiment, the specific steps are as follows:
[0136] (1) Let the target nonlinear function be f(x) and the interpolation interval be [a, b]. Then, the initial piecewise polynomial h(x) is generated by the piecewise multi-order interpolation method.
[0137] (2) Select an appropriate step size, let x st =a, and x st Substitute the following formula to calculate:
[0138] E(x)=f(x)-h(x)
[0139] Then let x st =x st +step, repeat the calculation until x st Until ≥b.
[0140] (3) After the calculation in step (2), the error distribution between the target nonlinear function f(x) and the piecewise polynomial h(x) is obtained. Then the Savitzky-Golay filter is used to fit the error data points. The Savitzky-Golay filter selects the data points in the filter window and fits the error curve H(x) using the least squares method.
[0141] (4) Take H(x) as the target nonlinear function and use the piecewise multi-order interpolation method to generate the piecewise polynomial h′(x) corresponding to the error curve. The selected piecewise interval points are consistent with those when generating the initial piecewise polynomial h(x). Then add h′(x) to h(x) to obtain the corrected piecewise polynomial G(x), that is:
[0142] G(x)=h(x)+h′(x)
[0143] The essence of interpolation error compensation is to compensate for the error of the initially generated piecewise polynomial h(x). Because the compensated error is calculated by the piecewise polynomial h′(x), and the order of the error piecewise polynomial h′(x) is consistent with the initial piecewise polynomial h(x), the coefficients of the piecewise polynomial can be directly calculated.
[0144] In another embodiment, in order to effectively address the challenge, Figure 4 Improvements to the disclosed solution, such as Figure 5 By performing interpolation interval preprocessing and interpolation error compensation at the front end and back end of the interpolation process respectively, the applicability and calculation accuracy of the interpolation are improved. Here, the interpolation interval preprocessing and interpolation error compensation reuse the contents of the above-mentioned embodiment, which will not be repeated here.
[0145] Hardware Design
[0146] Above Figure 4-5The solution is implemented by a general-purpose processor. The general-purpose processor obtains the interpolation table of the nonlinear operator by performing piecewise interpolation processing on nonlinear operators such as the Softmax operator and the GELU operator. The general-purpose processor transmits the obtained interpolation table to the artificial intelligence processor, and the artificial intelligence processor stores the interpolation table in the lookup table device of the artificial intelligence processor. When the artificial intelligence processor performs the nonlinear operator operation, the artificial intelligence processor obtains the coefficient of the interpolation function from the lookup table device, and replaces the nonlinear function of the nonlinear operator with the interpolation function, and the artificial intelligence processor performs the operation of the interpolation function.
[0147] The basic concept of the lookup table is elaborated in detail in the background technology section of this patent application, and its advantages and limitations are analyzed. Through specific hardware implementation, we will further analyze how the lookup table works. The direct lookup table method performs well in processing fixed-point number calculations with a limited range. However, once the representation range of the input value is expanded, the required memory capacity of the lookup table will increase dramatically. In order to overcome the problem of memory space occupation by the direct lookup table method, the indirect lookup table method is often used. This method effectively reduces the number of table entries required for the direct lookup table by preprocessing the input data and post-processing the output data, thereby alleviating the pressure on the memory space. However, the traditional lookup table device requires the lookup interval to be symmetrical about the origin of the coordinate axis, that is, in the form of [-r, r]. This symmetry restriction brings inconvenience in practical applications, because when calculating the target function, it is impossible for the given calculation interval to be symmetric about the origin every time; on the other hand, the floating-point lookup table hardware needs to divide the interval [a, b] into N sub-intervals, and the number of segments N is limited by the lookup table hardware unit. In the scenario of pursuing computing performance, directly dividing the interval [a, b] into N segments can meet the computing requirements, but in the scenario focusing on computing accuracy, dividing the interval [a, b] into N segments may result in insufficient computing accuracy.
[0148] In order to solve the above shortcomings, the existing lookup table device is improved, such as Figure 6As shown. Another adder is added to the lookup table device. The linear lookup table device includes an address index unit, a polynomial coefficient storage unit, a first multiplier, and a first adder. Among them, the newly added adder is called: a second adder. The second adder performs calculations based on the input x and the offset offset, with the purpose of converting the interpolation interval [a, b] into a symmetric interval [-r, r]. The address index unit obtains the sign bit, exponent bit, and mantissa bit of the output result of the second adder, and then calculates the storage index address index of the polynomial coefficient of the corresponding interval based on the input bias, and takes out the coefficient from the polynomial coefficient storage unit. Bias is the exponent value of the endpoint r of the symmetric interval; the function of the first multiplier and the first adder is to calculate the polynomial coefficient taken out with the input x′. If the number of interval segments is N, the approximate result y=k*x′+b is output. If the number of interval segments is greater than the limit of N, the result of this calculation is used as the input x′=k*x′+b for the next calculation.
[0149] exist Figure 6 On the basis of, a second multiplier, a third multiplier, and a third adder are further added, such as Figure 7 As shown. The linear lookup table device includes an address index unit, a polynomial coefficient storage unit, a first multiplier, and a first adder. Among them, the second adder calculates according to the input x and the offset offset to obtain the output result x', the purpose of which is to convert the interpolation interval [a, b] into a symmetric interval [-r, r]. The result x' is input to the second multiplier and the linear lookup table device at the same time. Among them, x' is input to the second multiplier twice at the same time. The output result of the second multiplier and one output result of the linear lookup table device are both used as inputs of the third multiplier at the same time, and the output of the third multiplier and another output result of the linear lookup table device are both used as inputs of the third adder at the same time. If the number of interval segments is greater than N, the output result of the third adder this time is used as the input of the next calculation, x′=ax′ 3 +bx′ 2 +cx′+d; if the number of interval segments is not greater than N, the output result of the third adder is y=ax′ 3 +bx′ 2 +cx′+d.
[0150] The linear lookup table device is the original floating-point lookup table hardware, which includes an address index unit, a polynomial coefficient storage unit, and a first multiplier and a first adder for calculation. By multiplexing this device, it cooperates with subsequent calculation units to calculate the approximate result of the target function.
[0151] In order to reduce the use of hardware resources, the lookup table operation part of the piecewise third-order interpolation function hardware architecture reuses the linear lookup table device, that is, through the calculation instruction control, the linear lookup table device is looked up multiple times. The piecewise third-order interpolation function S(x) is:
[0152] S(x)=ax 3 +bx 2 +cx+d
[0153] Wherein, a, b, c and d are four coefficients of the piecewise third-order interpolation function S(x).
[0154] In a linear lookup table device, a coefficient storage table only stores two coefficients, that is, a table lookup operation can only retrieve two coefficients. Note that coefficients a and b are stored in table A, and c and d are stored in table B.
[0155] Figure 7 The device shown performs the calculation process as follows:
[0156] Step 1, first addition operation: input a floating point number x and an offset offset, and transform the input into x′=x+offset in the second adder.
[0157] Step 2, first table lookup operation: input x' into the linear lookup table device, and calculate the subscript index of the polynomial coefficient in the address index unit in the linear lookup table device. Take out coefficients a and b from table A of the polynomial coefficient storage unit, input coefficient a and input x' into the first multiplier in the linear lookup table device together, the output result of the first multiplier is used as the input of the first adder in the linear lookup table device, and coefficient b is used as the input of the first adder. The two inputs are processed by the first adder, and the result is ax'+b.
[0158] Step 3, second table lookup operation: input x' into the linear lookup table device, and calculate the subscript index of the polynomial coefficient in the address index unit in the linear lookup table device. Take out coefficients c and d from table B of the polynomial coefficient storage unit in the linear lookup table device, and input coefficient c and input x' together into the first multiplier in the linear lookup table device. The output result of the first multiplier is used as the input of the first adder in the linear lookup table device, and the coefficient d is used as the input of the first adder. The two inputs are processed by the first adder, and the result is cx'+d.
[0159] Step 4: First multiplication operation: Use the input x' as the two inputs of the second multiplier and perform multiplication operation. The result is x' 2 .
[0160] Step 5: Second multiplication: Add the result of the first table lookup ax′+b to x′ 2 As the input of the third multiplier, the multiplication operation is performed and the result is ax′ 3 +bx′ 2 .
[0161] Step 6: Second addition operation: Subtract the result of the second multiplication operation ax′ 3 +bx′ 2 The result of the second table lookup operation cx′+d is used as the input of the third adder for addition calculation. If the number of interval segments is greater than N, the result of this calculation is used as the input of the next calculation, x′=ax′ 3 +bx′ 2 +cx′+d, go to step 2 for calculation; if the number of interval segments is not greater than N, the output result is y=ax′ 3 +bx′ 2 +cx′+d.
[0162] Because the interval of the piecewise multi-order interpolation calculation is [a, b], an adder is used in the hardware design to offset the interval to [-r, r]. At this time, the coefficients of the piecewise multi-order interpolation function need to be transformed to ensure the correctness of the calculation result.
[0163] (1) Interpolation calculation using a single interpolation table
[0164] If the computational accuracy requirement is not high or the adopted piecewise interpolation polynomial is of high degree, it is only necessary to divide the function f(x) into N equal segments in the interval [a,b]. Therefore, for any x∈[a,b], it can be transformed to a symmetric interval of the form [-r,r] through the offset offset, and the mapping relationship f is as follows:
[0165] x′=x+offset
[0166] Among them, the offset
[0167] In the piecewise multi-order interpolation function hardware architecture, the input floating point number x and the offset offset are transmitted to the adder for calculation, and x∈[a,b] is transformed into In the subsequent processes, the transformed input x′ is used for calculation. However, the coefficients of the piecewise multi-order interpolation function are calculated and generated in the interval [a, b], that is, the default input is a floating point number x∈[a, b], so the coefficients of the piecewise multi-order interpolation function need to be adjusted to get the correct result. If a piecewise first-order polynomial is used, then it is necessary to ensure that:
[0168] kx+b=k′x′+b′
[0169] Among them, k and b are the initial slope and y-intercept respectively; k' and b' are the adjusted slope and y-intercept respectively; x' = x + offset. After the equation transformation, we get formula (h), which can be used to adjust the coefficients of the piecewise first-order polynomial to obtain the offset interval. Calculate the correct result.
[0170]
[0171] Similarly, if a piecewise third-order polynomial is used, then you need to ensure that:
[0172] ax 3 +bx 2 +cx+d=a′x′ 3 +b′x′ 2 +c′x′+d′ Formula (i)
[0173] Among them, a, b, c, d are the initial cubic polynomial coefficients; a', b', c', d' are the adjusted cubic polynomial coefficients; x' = x + offset. After the equation transformation, we get formula (g), which can be used to adjust the coefficients of the piecewise third-order polynomial to obtain the offset interval. Calculate the correct result.
[0174]
[0175] (2) Multi-table interpolation calculation
[0176] For computer hardware, in order to reduce area overhead, the length of the lookup table is not infinite, and generally has a size limit. For example, the lookup table for one calculation is 64 pairs of coefficients or 128 pairs of coefficients. A larger one can support up to 256 pairs of coefficients. When the number of segmented sub-intervals exceeds the length limit of the lookup table supported by the hardware, or the current segmentation cannot meet the accuracy requirements and needs to be divided into smaller sub-intervals, it is necessary to segment the original function, that is, we need to divide the target nonlinear function f(x) into multiple sub-functions, and then perform segmented interpolation approximation on these sub-functions. Figure 8 As shown, through the sequence Divide the target nonlinear function f(x) into n different sub-functions in the interpolation interval [a,b] Thus, the objective function of the piecewise interpolation calculation is transformed into F i (x). Each subfunction F i (x) corresponds to an interpolation table. The length of the lookup table cannot exceed the hardware limit on the length of the lookup table. Each sub-function F i The lengths of the subintervals corresponding to (x) are also not equal. Through this technical means, we can perform fine-grained segmentation when the slope of the original function f(x) is large, and perform coarse-grained segmentation when the slope is small.
[0177] Each function F after segmentation i (x) corresponds to an interpolation table, and the calculation interval is [x i ,x i+1 ], whose expression is given by formula (k). Input sequence {x i} i=1,2,...,n The table lookup calculations are performed in parallel without interfering with each other. In order to reduce the number of additional calculation instructions, each input value x i It is necessary to calculate all interpolation tables, and then add the calculation results of each interpolation table to finally get the approximate result. Because in the training and reasoning of neural networks, the input data is stored in the form of tensors. Before calculation, it is not easy to determine which calculation interval [x i ,x i+1 ] If we want to determine in advance which large interval each element is in, it will add a lot of tedious calculation operations and affect the calculation performance.
[0178]
[0179] After splitting the target nonlinear function, we only need to i (x) performs single table calculation, and the coefficient transformation is shown in formula (h) and formula (i). If the input x∈[x1,x2], the approximate result is obtained after calculation through the interpolation table corresponding to the function F1(x), and the result 0 is calculated in the interpolation table corresponding to other functions, and the final calculation result is obtained after accumulation. The calculation result of function f(x) can be given by formula (j):
[0180]
[0181] Those skilled in the art also know that, in addition to implementing the client and server in a purely computer-readable program code, the client and server can be made to implement the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a client and server can be considered as a hardware component, and the means for implementing various functions included therein can also be considered as a structure within the hardware component. Or even, the means for implementing various functions can be considered as both a software module for implementing the method and a structure within the hardware component.
[0182] It can be known from the description of the above implementation modes that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various implementation modes of the present application or certain parts of the implementation modes.
[0183] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the implementation of the client and the server, the introduction of the implementation of the aforementioned method can be referred to for comparative explanation.
[0184] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0185] Although the present application has been described through embodiments, those skilled in the art will appreciate that there are many modifications and variations to the present application without departing from the spirit of the present application, and it is intended that the appended claims include these modifications and variations without departing from the spirit of the present application.
Claims
1. A method for implementing an interpolation method of a nonlinear operator based on a general-purpose processor, wherein: The method comprises: The general processor determines the interpolation interval according to the nonlinear function corresponding to the nonlinear operator; The general processor determines the length of the segmented sub-interval according to the starting point of the interpolation interval, the ending point of the interpolation interval, and the number of segmented sub-intervals in the large interval in the interpolation interval; wherein the large interval corresponds to an interpolation table, and the interpolation interval is divided into at least one large interval; the interpolation table records the coefficients of the interpolation function corresponding to the segmented sub-intervals in the large interval; The general processor determines the maximum absolute error of the segmented subinterval within the large interval according to the length of the segmented subinterval, compares the maximum absolute error with the absolute error limit, and optimizes the length of the segmented subinterval according to the comparison result; The general processor determines the interpolation table corresponding to the large interval according to the optimized length of the segmented sub-interval, and completes the segmented interpolation of the nonlinear operator.
2. The method of claim 1, wherein: The step of determining, by the general processor, the length of the segmented sub-interval within the large interval comprises: The general processor compares the starting point of the interpolation interval and the ending point of the interpolation interval, determines whether the starting point of the interpolation interval is smaller than the ending point of the interpolation interval, and obtains a determination result; If the judgment result is that the starting point of the interpolation interval is smaller than the ending point of the interpolation interval, the general processor determines the length parameter of the segmented sub-interval according to the starting point of the interpolation interval, the ending point of the interpolation interval, and the number of segmented sub-intervals in the large interval in the interpolation interval, and uses the length parameter of the segmented sub-interval to obtain the length of the segmented sub-interval in the large interval.
3. The method of claim 1, wherein: The step of optimizing the length of the segmented sub-interval by the general processor comprises: If the comparison result is that the maximum absolute error of the segmented sub-interval is greater than the absolute error limit, the length of the segmented sub-interval in the large interval is reduced, and the interpolation function corresponding to the reduced length of the segmented sub-interval and the nonlinear function are used to determine the maximum absolute error of the current segmented sub-interval, and the maximum absolute error of the current segmented sub-interval is compared with the absolute error limit to determine whether to reduce the length of the segmented sub-interval in the large interval until the maximum absolute error of the current segmented sub-interval is less than or equal to the absolute error limit, so as to obtain the length of the segmented sub-interval that meets the limit of the absolute error limit.
4. The method of claim 1, wherein: The step of the general processor determining the interpolation interval according to the nonlinear function corresponding to the nonlinear operator comprises: If the nonlinear function is a periodic function, a horizontal asymptote, or an oblique asymptote, converting the interpolation interval from an infinite interval (-∞, +∞) to a finite interval; If the nonlinear function is not a periodic function, a horizontal asymptote, or an oblique asymptote, the interpolation interval is set according to requirements.
5. The method of claim 4, wherein: The nonlinear function is a periodic function, and the function curve is interpolated and approximated within a part of the period, and the obtained piecewise interpolation polynomial can be reused in other periodic parts of the nonlinear function.
6. The method of claim 4, wherein: The nonlinear function is a horizontal asymptote or an oblique asymptote, which divides the infinite interval (-∞, +∞) into (-∞, a), [a, b] and (b, +∞); the piecewise interpolation method is used in the interval [a, b], and the value of the asymptote is used instead of the nonlinear function value in the intervals (-∞, a) and (b, +∞).
7. The method according to any one of claims 1 to 6, wherein: The method further comprises: The general processor performs error compensation on the interpolation function corresponding to the nonlinear function to obtain a corrected interpolation function; wherein the interpolation table stores coefficients of the corrected interpolation function.
8. The method of claim 7, wherein: The modified interpolation function acquisition step further comprises: The general processor determines the nonlinear function corresponding to the nonlinear operator and the error distribution corresponding to the interpolation function; The general processor processes the error distribution to obtain a corresponding error curve; The general processor uses the method described in any one of claims 1 to 6 to obtain a corresponding interpolation function for the error curve; wherein the segmented interval points selected within the interpolation interval of the error curve are consistent with the segmented interval points selected within the interpolation interval of the nonlinear function corresponding to the nonlinear operator; The general processor adds the interpolation function corresponding to the error curve and the interpolation function corresponding to the nonlinear operator to obtain a corrected interpolation function.
9. An interpolation device for implementing a nonlinear operator based on a general-purpose processor, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
