Function lookup table establishment method and device, electronic equipment and storage medium
By determining the two adjacent nodes with the largest error in the objective function and inserting new nodes, a more accurate function lookup table is established, which solves the problem of poor approximation effect caused by uniform sampling and improves the approximation accuracy of complex functions.
Patent Information
- Application Number
- CN202510210463.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-06-13
AI Technical Summary
The existing method of determining a series of sampling points through uniform sampling results in poor approximation of functions with uneven changes in function values.
By obtaining the node data of the starting node, terminating node, and median node of the objective function, determine the two adjacent nodes with the greatest error, add new nodes between the two adjacent nodes, and calculate the node data that generates the new node until the number of nodes reaches the preset threshold, to establish a more accurate function lookup table.
Improve the approximation effect of the objective function, especially in areas where the function value changes unevenly, and enhance the accuracy of the hardware when calculating complex functions.
Smart Images

Figure CN120145948A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of chip design. Specifically, it relates to a method, apparatus, electronic device, and storage medium for establishing a function lookup table. Background Art
[0002] In chip algorithm design, it is inevitable to use complex functions (such as division, exponential operation, or logarithmic operation, etc.). For the hardware implementation of complex functions, they are generally converted into the form of a LUT (Look-Up-Table). The LUT contains a series of sampling points converted from the function. These sampling points are calculated externally and then configured into the chip registers. In this way, the chip can use the sampling points combined with the interpolation algorithm to approximate the complex function. However, currently, a series of sampling points are usually determined by uniform sampling, but the sampling points obtained in this way have a poor approximation effect on functions with non-uniform function value changes. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, and storage medium for establishing a function lookup table to solve the problem that the existing method of determining a series of sampling points by uniform sampling results in a poor approximation effect of the obtained sampling points on functions with non-uniform function value changes.
[0004] In a first aspect, this application provides a method for establishing a function lookup table, including: obtaining the node data of the start node, end node, and median node of the target function, where the node data includes the coordinate information of the node; determining the two adjacent nodes with the largest error, adding a new node between the two adjacent nodes, and calculating and generating the node data of the new node. Repeat this step until the number of nodes reaches a preset threshold; where the error is the error between the linear function formed by two adjacent nodes and the target function within the abscissa range of the two adjacent nodes; obtaining a function lookup table based on all the obtained node data.
[0005] In the embodiments of this application, since the two adjacent nodes with the largest error indicate that the linear function formed by these two nodes and the target function have the largest error within the abscissa range of these two adjacent nodes, that is, the approximation effect on the target function is the worst. Therefore, a new node is inserted between the two adjacent nodes with the largest error to reduce the error within the abscissa range of these two nodes and improve the approximation effect on the target function. Since each newly inserted node is between the two adjacent nodes with the largest error, the approximation effect on the target function can be improved each time.
[0006] In combination with the technical solution provided in the above first aspect, in some possible implementation manners, the abscissa of the new node is the average value of the abscissas of the two adjacent nodes with the largest error.
[0007] In the embodiments of the present application, since the abscissa of the new node is the average of the abscissas of the two adjacent nodes with the largest error, the new node can balance the approximation effect of the objective function between these two nodes as much as possible. Moreover, the step (the difference in abscissas) between adjacent nodes after inserting the new node can be maintained as an integer power of 2. In this way, when the hardware calculates a linear function (such as during linear interpolation), the division operation by step can be converted into a shift operation.
[0008] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, the node data further includes an error value, where the error value is: the magnitude of the error between the linear function formed by the first node corresponding to the node data and the next node of the first node and the objective function within the abscissa range of the first node and the next node of the first node; correspondingly, determining the two adjacent nodes with the largest error includes: determining the node corresponding to the largest error value among all node data as the target node; determining the target node and the next node of the target node as the two adjacent nodes with the largest error; correspondingly, after adding a new node between the two adjacent nodes, the method further includes: updating the error value in the node data of the target node.
[0009] In the embodiments of the present application, by adding an error value to the node data, during the subsequent process of determining the two adjacent nodes with the largest error, it can be directly confirmed by looking up the error value in the node data. Moreover, since only the error value in the previous node of the new node needs to be updated after inserting the new node, the error values corresponding to other nodes will not change, so it is not necessary to calculate the errors of all adjacent two nodes each time, reducing the amount of data calculation.
[0010] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, the error value is calculated in the following manner: between the abscissa of the first node and the abscissa of the next node of the first node, multiple error test abscissas are selected; for each error test abscissa, the first ordinate of the error test abscissa in the linear function formed by the first node and the next node is determined, and the second ordinate of the error test abscissa in the objective function is determined; based on the first ordinate and the second ordinate, the test error corresponding to the error test abscissa is obtained; based on all the obtained test errors, the error value of the first node is obtained.
[0011] In the embodiments of the present application, for the same error test abscissa, the difference between the first ordinate of the error test abscissa in the linear function and the second ordinate of the error test abscissa in the target function can reflect the error between the linear function and the target function at the error test abscissa. Therefore, determining the error value of the first node through the test errors corresponding to multiple error test abscissas can more accurately reflect the error corresponding to the first node and the next node.
[0012] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, based on all the obtained test errors, obtaining the error value of the first node includes: taking the maximum value among all the obtained test errors as the error value of the first node.
[0013] In the embodiments of the present application, the larger the test error, the greater the difference between the linear function and the target function, that is, the worse the approximation effect of the linear function on the target function. Therefore, taking the maximum value of the test errors as the error value of the first node can more accurately reflect the approximation effect.
[0014] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, selecting multiple error test abscissas includes: starting from the abscissa of the first node and ending at the abscissa of the next node of the first node, and sequentially determining multiple error test abscissas at preset intervals.
[0015] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, the preset interval is an integer power of 2.
[0016] In the embodiments of the present application, since the function lookup table may need to be deployed to the chip, for the function lookup table that needs to be deployed to the chip, the range of its corresponding abscissa and ordinate is usually an integer power of 2. Therefore, setting the preset interval as an integer power of 2 can achieve an average division of two adjacent nodes.
[0017] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, the node data further includes an abscissa difference, and the abscissa difference is: the difference between the abscissa of the first node corresponding to the node data and the abscissa of the next node of the first node; the abscissa of the new node is x1 + △x / 2; where x1 is the abscissa of the target node and △x is the abscissa difference corresponding to the target node.
[0018] In the embodiments of the present application, by recording the difference between the abscissa of the first node corresponding to the node data and the abscissa of the next node of the first node in the node data, when it is necessary to insert a new node between the first node and the next node of the first node, only the node data of the first node needs to be obtained to get the abscissa of the new node, without obtaining the node data of the next node of the first node, thereby reducing the number of data to be obtained and improving the calculation efficiency of the abscissa of the new node.
[0019] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, the node data further includes the storage address of the node data of the next node.
[0020] In the embodiments of the present application, by including the storage address of the node data of the next node in the node data, it is convenient to quickly find the node data of the next node and improve the table building efficiency.
[0021] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, after obtaining the function lookup table, the method further includes: configuring the function lookup table into the chip register.
[0022] Combined with the technical solution provided in the first aspect above, in some possible implementation manners, obtaining the function lookup table based on all the obtained node data includes: storing the abscissa values in all the node data in ascending order to obtain an abscissa array; storing the corresponding ordinate values in sequence according to the storage order of the abscissa values to obtain an ordinate array; configuring the function lookup table into the chip register includes: configuring the abscissa array and the ordinate array into the chip register; wherein, the function lookup table in the chip includes the abscissa array and the ordinate array configured in the chip register.
[0023] In a second aspect, the present application provides a function lookup table building device, including: an acquisition module and a processing module. The acquisition module is used to acquire the node data of the start node, end node, and median node of the target function respectively, where the node data includes the coordinate information of the node; the processing module is used to determine the two adjacent nodes with the largest error, add new nodes between the two adjacent nodes, and calculate and generate the node data of the new nodes until the number of nodes reaches a preset threshold; wherein, the error is the error between the linear function formed by two adjacent nodes and the target function within the abscissa range of the two adjacent nodes; the processing module is further used to obtain a function lookup table based on all the obtained node data.
[0024] In a third aspect, the present application provides a chip, including: a register, in which a function lookup table established based on the above first aspect and / or any possible implementation manner in combination with the above first aspect is configured.
[0025] In a fourth aspect, the present application provides an electronic device, including: a memory and a processor, the memory is connected to the processor; the memory is used for storing a program; the processor is used for calling the program stored in the memory to execute the method described in the above first aspect and / or any possible implementation manner in combination with the above first aspect.
[0026] In a fifth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a computer, it executes the method described in the above first aspect and / or any possible implementation manner in combination with the above first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation of the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0028] Figure 1 It is a schematic flowchart of a method for establishing a function lookup table shown in an embodiment of the present application;
[0029] Figure 2 It is a schematic diagram of a target function and five nodes shown in an embodiment of the present application;
[0030] Figure 3 It is a schematic diagram of a target function and two nodes shown in an embodiment of the present application;
[0031] Figure 4 It is a schematic diagram of the first linked list shown in an embodiment of the present application;
[0032] Figure 5 It is a schematic diagram of the second linked list shown in an embodiment of the present application;
[0033] Figure 6 It is a schematic diagram of the third linked list shown in an embodiment of the present application;
[0034] Figure 7 It is a schematic diagram of a target function and three nodes shown in an embodiment of the present application;
[0035] Figure 8 It is a schematic diagram of a target function shown in an embodiment of the present application;
[0036] Figure 9 A schematic diagram of an objective function and 17 nodes shown in an embodiment of the present application;
[0037] Figure 10 A schematic diagram of an objective function and 33 nodes shown in an embodiment of the present application;
[0038] Figure 11 A structural block diagram of a function lookup table establishment device shown in an embodiment of the present application;
[0039] Figure 12 A structural block diagram of an electronic device shown in an embodiment of the present application. Detailed implementation manners
[0040] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application.
[0041] It should be noted that: Similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover a non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including a..." does not exclude the presence of additional identical elements in the process, method, article or device including the element.
[0042] Next, the technical solutions of the present application will be described in detail with reference to the accompanying drawings.
[0043] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a function lookup table establishment method shown in an embodiment of the present application. Next, the steps included therein will be described with reference to Figure 1 and explain them.
[0044] S100: Obtain the node data of the start node, end node, and median node of the objective function respectively.
[0045] Among them, the node data includes the coordinate information of the node.
[0046] The node data of the starting node, ending node, and median node of the objective function can be pre-obtained and stored in a local storage medium, and can be directly called when needed. Alternatively, it can also be calculated in real time according to the objective function when needed.
[0047] In one implementation, if the objective function is represented by a functional relationship, the starting node is the node corresponding to the smallest abscissa within the abscissa value range of the objective function. The ending node is the node corresponding to the largest abscissa within the abscissa value range of the objective function. The median node is the node corresponding to the abscissa value that is the average of the largest abscissa and the smallest abscissa within the abscissa value range of the objective function.
[0048] After determining the abscissas of the starting node, ending node, and median node respectively, the abscissas can be substituted into the objective function to obtain the ordinates of the starting node, ending node, and median node respectively.
[0049] For ease of understanding, taking the abscissa value range of the objective function as 0 to 1024 as an example, the abscissa of the starting node of the objective function is 0, the abscissa of the ending node is 1024, and the median abscissa is 512. This example is only for ease of understanding and should not be used as a limitation to this application.
[0050] Optionally, in a chip, in order to reduce the occupation of storage space and reduce the processing cost, data is usually stored in an integer type rather than a floating-point type. Therefore, when determining the abscissa of the node, the abscissa can be set to an integer.
[0051] In this way, the objective function can be obtained first, and then the domain (abscissa range) of the objective function is normalized (transform the abscissa range into 0 to 1). Then, quantization is performed according to the size of the abscissa corresponding bit position set in the chip to determine the final abscissa range. Then, calculate the initial ordinate value corresponding to the minimum value (abscissa of the starting node) of the final abscissa range in the objective function, and determine the final ordinate value (ordinate of the starting node) corresponding to the initial ordinate value according to the size of the ordinate corresponding bit position set in the chip. The calculation methods of the abscissas and ordinates of the ending node and median node are the same. For the sake of brief description, they will not be elaborated here.
[0052] For ease of understanding, taking the objective function as y = sin(x 2) + 1.5, taking x ∈ [0, 2.17] as an example, the initial abscissa range of the objective function is 0 to 2.17. First, it is normalized to 0 to 1 (that is, 2.17 corresponds to 1, and 1.085 corresponds to 0.5). Then quantization is performed (taking 10-bit as an example), so 1.0 (the maximum abscissa after normalization) corresponds to 1024, and 0.5 (the median coordinate after normalization) corresponds to 512 (which is also equivalent to 2.17 of the objective function corresponding to 1024 and 1.085 corresponding to 512). After that, only the quantized abscissa range will be used during the table building process, that is, quantized integer numbers such as X = 0, 1, 2, …, 1024.
[0053] For example, when calculating X = 5, to calculate the linear function, linear interpolation calculation will be performed using the two end nodes. When calculating the ordinate value of X = 5 in the objective function, first calculate x = X ÷ 1024 × 2.17 to get a floating-point number (that is, x = 5 ÷ 1024 × 2.17), and then substitute it into y = sin[(5 ÷ 1024 × 2.17) 2 +1.5 to calculate an initial ordinate. Then, quantization is performed on the initial ordinate (taking 8-bit as an example), then Y = [sin[(5 ÷ 1024 × 2.17) 2 +1.5] × 255, that is, the ordinate corresponding to the node X = 5 is obtained. Among them, 255 is the maximum value that 8 bits can represent.
[0054] If the storage of the ordinate also needs to be an integer type, after calculating the ordinate, round or round up the calculated ordinate to obtain an integer ordinate.
[0055] The above abscissa of 1024 requires a storage space larger than 10 bits. Therefore, when building the function lookup table later, the node data corresponding to the node with abscissa 1024 can be discarded and not included in the range of the function lookup table.
[0056] Or, the node data corresponding to the node with abscissa 1024 can be used as isolated data and stored separately from the function lookup table. However, when the function value needs to be calculated, the isolated data and the function lookup table are combined to calculate the function value.
[0057] Or, the bit of the abscissa can also be expanded to accommodate the node with abscissa 1024.
[0058] In one implementation, if the objective function is represented by a set of sampling points, each sampling point includes an abscissa and an ordinate. The specific method for obtaining the node data of the starting node, the ending node, and the median node of the objective function can be as follows: Determine the sampling point with the smallest abscissa from all the sampling points as the starting node, and use the abscissa and ordinate of the sampling point with the smallest abscissa as the coordinate information in the node data of the starting node.
[0059] Determine the sampling point with the largest abscissa from all the sampling points as the ending node, and use the abscissa and ordinate of the sampling point with the largest abscissa as the coordinate information in the node data of the ending node.
[0060] Determine the sampling point with the abscissa closest to the average of the abscissas of the starting node and the ending node from all the sampling points as the median node, and use the abscissa and ordinate of this sampling point as the coordinate information in the node data of the median node.
[0061] Optionally, the coordinate information of the node can include the abscissa and ordinate of the node.
[0062] Alternatively, the coordinate information of the node can also include the ordinate of the node and the difference between the abscissa of the node and the abscissa of the next node. In this way, only the node information of the first node needs to include the abscissa to obtain the abscissa of each subsequent node.
[0063] Alternatively, the coordinate information of the node can also include the abscissa and ordinate of the node, and the difference between the abscissa of the node and the abscissa of the next node. In this case, if a new node needs to be inserted after the target node, the abscissa of the new node is x1 + △x / 2; where x1 is the abscissa of the target node, and △x is the abscissa difference corresponding to the target node. In this way, when a new node needs to be inserted between the target node and the next node of the target node, only the node data of the target node needs to be obtained to get the abscissa of the new node, without obtaining the node data of the next node of the target node, thereby reducing the amount of data that needs to be obtained and improving the calculation efficiency of the abscissa of the new node.
[0064] Wherein, if △x / 2 is not an integer, the value of x1 + △x / 2 can be rounded or rounded off, and the final result is used as the abscissa of the new node.
[0065] In one implementation, the node data also includes the storage address of the node data of the next node.
[0066] By including the storage address of the node data of the next node in the node data, it is convenient to quickly find the node data of the next node and improve the table building efficiency.
[0067] In one implementation, node data can be stored in the form of a linked list. The node data of each node corresponds to a piece of data in the linked list, and the pointer of each node in the linked list points to the next node of that node.
[0068] In one implementation, since the value ranges of the abscissa and ordinate of different functions are different. Therefore, in order to apply the function lookup table established by this solution to the hardware circuit, the target function can be quantized into integer data, and the function obtained after quantization is the target function. The abscissa range and ordinate range of the target function obtained after quantization are determined by their respective quantization bit widths.
[0069] Among them, the quantization bit width of quantization is set according to the actual requirements, accuracy, and resources of the hardware circuit. The quantization bit width needs to include the quantization bit width of the abscissa and the quantization bit width of the ordinate.
[0070] For example, the quantization bit width of quantization can be determined by the memory size used to store the function lookup table in the hardware circuit.
[0071] For ease of understanding, taking Figure 2 the discrete curve and LUT shown in Table 1 as an example, the normalized evenly spaced x-axis of its original discrete curve is quantized into an integer type with QuanX = 10bit (x = 0, 1, 2,..., 1024, with an interval of 1). The y-axis of the original discrete curve is an array Curve containing 2 10 +1 = 1025 original floating-point numbers, which will be quantized into fixed-point numbers by QuanY bits (taking QuanY = 8bit as an example). For the y-axis of each discrete curve sampling point: Among them, << is the left shift operator, Curve*(1 << 8) means quantizing and amplifying the value of Curve with a bit width of 8bit, and Curve*(1 << 8) can be equivalent to Curve*2 8 ; means rounding down x; adding 0.5 to Curve*(1 << 8) and then rounding down means rounding.
[0072] Among them, Figure 2 there are 5 nodes in the shown figure, dividing the curve into four segments: curve 1, curve 2, curve 3, and curve 4. Among them, the abscissa corresponding to the sampling point i is X[i], the ordinate corresponding to the sampling point i is Y[i], and i is an integer greater than or equal to 0.
[0073] Taking the first sampling point (i.e., sampling point 0, with the abscissa X[0] and the ordinate Y[0]) as an example, The same applies to other sampling points.
[0074] Table 1
[0075]
[0076]
[0077] Among them, Entry represents the number of sampling points, LutX represents the value of X, and LutY represents the value of Y.
[0078] S200: Determine the two adjacent nodes with the largest error, add a new node between the two adjacent nodes, and calculate the node data of the newly generated node. Repeat this step until the number of nodes reaches a preset threshold.
[0079] Among them, the error is the error between the linear function formed by two adjacent nodes and the target function within the abscissa range of the two adjacent nodes.
[0080] Two adjacent nodes refer to: two nodes with adjacent abscissas.
[0081] In one implementation, it can be to randomly select an abscissa within the interval formed by the abscissas of the two adjacent nodes with the largest error as the abscissa of the new node.
[0082] Optionally, the abscissa of the new node is the average value of the abscissas of the two adjacent nodes with the largest error.
[0083] Correspondingly, when calculating the node data of the newly generated node, based on the average value of the abscissas of the two adjacent nodes with the largest error, calculate the corresponding ordinate from the target function. Record the abscissa and ordinate into the node data of the new node as coordinate information.
[0084] The step (abscissa difference) between adjacent nodes after inserting the new node can be maintained as an integer power of 2. In this way, when the hardware calculates the linear function (such as during linear interpolation), the division operation by step can be converted into a shift operation.
[0085] Optionally, when the node data includes the abscissa difference (the abscissa difference is: the difference between the abscissa of the first node corresponding to the node data and the abscissa of the next node), when calculating the node data of the newly generated node, the abscissa of the new node can be calculated according to the abscissa of the target node with the smaller abscissa among the two adjacent nodes with the largest error and the abscissa difference. The abscissa of the new node = x1 + △x / 2. x1 is the abscissa of the target node, and △x is the abscissa difference corresponding to the target node.
[0086] Optionally, after determining the abscissa of the node, the specific method for determining the ordinate corresponding to the node has been described clearly above. For the sake of brief description, it will not be elaborated here.
[0087] In one implementation, the specific method for determining the two adjacent nodes with the largest error can be as follows: First, determine the error corresponding to each pair of adjacent nodes among all nodes. Then, from all the determined errors, determine the maximum error, and the two nodes corresponding to the maximum error are the two adjacent nodes with the largest error.
[0088] In one implementation, the method for determining the error corresponding to each pair of adjacent nodes among all nodes can be as follows: Between the abscissa of the first node and the abscissa of the second node, select multiple error test abscissas. Then, for each error test abscissa, determine the first ordinate of the error test abscissa in the linear function formed by the first node and the second node, and the second ordinate of the error test abscissa in the target function. After that, based on the first ordinate and the second ordinate, obtain the test error corresponding to the error test abscissa. Finally, based on all the obtained test errors, obtain the error corresponding to the first node and the second node. Here, the first node and the second node are two adjacent nodes.
[0089] Among them, the first ordinate of the error test abscissa in the linear function formed by the first node and the second node is the function value obtained by substituting the error test abscissa into the linear function formed by the first node and the second node, which is the ordinate corresponding to the error test abscissa in the linear function.
[0090] Optionally, the method for obtaining the error value of the first node based on all the obtained test errors can be: taking the maximum value among all the obtained test errors as the error between the first node and the second node.
[0091] Or, it can also be taking the average value of all the obtained test errors as the error between the first node and the second node.
[0092] Optionally, the method for selecting multiple error test abscissas can be: starting from the abscissa of the first node and ending at the abscissa of the second node, sequentially determine multiple error test abscissas at intervals of a preset step size.
[0093] The specific length of the preset step size can be set according to actual needs, but the length of the preset step size must be less than the difference between the abscissa of the first node and the abscissa of the second node, and no specific value is restricted here.
[0094] Optionally, one method for determining the preset step size can be to pre-set the number of error test abscissas, and then divide the absolute value of the difference between the abscissa of the first node and the abscissa of the second node by the number of error test abscissas to obtain the preset step size.
[0095] Optionally, the preset step size can be an integer power of 2. Since the function lookup table may need to be deployed to a chip, for the function lookup table that needs to be deployed to the chip, the range of its corresponding horizontal and vertical coordinates is the nth power of 2. Therefore, setting the preset step size to an integer power of 2 can achieve an average division of adjacent two nodes. Here, n is a positive integer.
[0096] In one implementation, the method for determining the error corresponding to each adjacent pair of nodes among all nodes can also be: calculating the definite integral of the linear function formed by the first node and the second node and the target function within the interval range (i.e., the domain) formed by the abscissa of the first node and the abscissa of the second node, and using this definite integral to represent the error between the first node and the second node. Here, the first node and the second node are two adjacent nodes.
[0097] Among them, the specific method for calculating the definite integral according to two functions is already well-known to those skilled in the art. For the sake of brief description, it will not be elaborated here.
[0098] In order to reduce the computational complexity of error calculation, in one implementation, the node data also includes an error value, and the error value is: the magnitude of the error between the linear function formed by the first node corresponding to the node data and the next node of the first node and the target function within the abscissa range of the first node and the next node of the first node.
[0099] Correspondingly, the specific method for determining the two adjacent nodes with the largest error can be: first, determining the node corresponding to the largest error value among all node data as the target node. Then, determining the target node and the next node of the target node as the two adjacent nodes with the largest error.
[0100] Correspondingly, after adding a new node between the two adjacent nodes, the error value in the node data of the target node can also be updated.
[0101] Since a new node is inserted between the target node and the original next node of the target node, the next node of the target node changes to this new node. Therefore, it is necessary to update the error value in the node data of the target node, that is, update it to the error value between the target node and this new node.
[0102] In this way, since there is no next node for the last node (termination node), the node data of the last node may not include an error value.
[0103] In one implementation, the error value is calculated as follows: First, between the first node and the next node of the first node, multiple error test abscissas are selected. Then, for each error test abscissa, a first ordinate of the error test abscissa in the linear function formed by the first node and the next node is determined, as well as a second ordinate of the error test abscissa in the target function; based on the first ordinate and the second ordinate, the test error corresponding to the error test abscissa is obtained. Finally, based on all the obtained test errors, the error value of the first node is obtained.
[0104] Optionally, the specific way to obtain the error value of the first node based on all the obtained test errors can be: taking the maximum value among all the obtained test errors as the error value of the first node.
[0105] Or, it can also be taking the average value (or the sum of all test errors) of all the obtained test errors as the error value of the first node.
[0106] Optionally, the way to select multiple error test abscissas can be: starting from the abscissa of the first node and ending with the abscissa of the next node of the first node, multiple error test abscissas are determined at intervals of a preset step size. Here, the way to select multiple error test abscissas has been described clearly above. For the sake of brief description, it will not be elaborated here.
[0107] Optionally, the preset step size can be a power of 2.
[0108] In one implementation, the error value can also be calculated as follows: Calculate the definite integral of the linear function formed by the first node and the second node and the target function within the range (i.e., the domain) of the abscissa of the first node and the abscissa of the second node. The value of the calculated definite integral is the error value of the first node.
[0109] S300: Obtain a function lookup table based on all the obtained node data.
[0110] Among them, the function lookup table can be configured into the chip register so that the chip can perform approximate calculation of the specified function based on the configured function lookup table. Here, the specified function is the function corresponding to the configured function lookup table.
[0111] In one implementation, the way to obtain the function lookup table based on all the obtained node data can be: Based on all the node data, obtain the abscissa and ordinate of each node, and use the set composed of the abscissa and ordinate as the function lookup table.
[0112] Or, it can also be recording the abscissa and ordinate of each node into a preset table template to obtain the function lookup table.
[0113] Based on all the obtained node data, the function lookup table can also be obtained as follows: Store the abscissa values in all the node data in ascending order to obtain an abscissa array. According to the storage order of the abscissa values, store the corresponding ordinate values in sequence to obtain an ordinate array. The obtained abscissa array and ordinate array are the function lookup table.
[0114] In one implementation, after obtaining the function lookup table, the function lookup table can also be configured into the chip register.
[0115] Optionally, when the function lookup table includes an abscissa array and an ordinate array, the method of configuring the function lookup table into the chip register can be: Configure the abscissa array and the ordinate array into the chip register. Among them, the function lookup table in the chip includes the abscissa array and the ordinate array configured in the chip register.
[0116] In one implementation, the function lookup table can also include the number of nodes.
[0117] To facilitate the understanding of the above method for establishing the function lookup table, below, the node data of each node includes the abscissa (which can also be expressed as LutX), the ordinate (which can also be expressed as LutY), the address of the next node (i.e., data such as a pointer that can represent the address of the next node), the difference in abscissa between this node and the next node (which can also be expressed as Step), and the error value between this node and the next node (which can also be expressed as maxDiff).
[0118] Among them, in order to reduce the number of traversals during the calculation process, a linked list method is adopted to record the node data of the nodes. Each node in the linked list represents the node data of a node. In this way, only the maximum error between the current node and the new node after linear interpolation with the discrete curve, and the maximum error between the new node and the next node after linear interpolation with the discrete curve need to be calculated each time a new node is inserted. This method can greatly reduce the number of traversals required for the calculation.
[0119] First, insert the nodes of the two endpoints into the linked list, that is, the initial node and the termination node.
[0120] Define the first node Node0, corresponding to the first sampling point Sample0 of the LUT. The Node0.LutX of this node is 0, Node0.LutY = CurveY[Node0.LutX], and the Node0.next pointer points to the second node. Among them, Nodei.LutX represents the abscissa of the sampling point i (i.e., node i), Nodei.LutY represents the ordinate of the sampling point i, Nodei.next represents the pointer to the sampling point i + 1, and i is an integer greater than or equal to 0.
[0121] Define the second node Node1, corresponding to the second sampling point Sample1 of the LUT. For this node, Node1.LutX = 1 << QuanX, Node1.LutY = CurveY[Node1.LutX], and the Node1.next pointer points to null (indicating that there is no successor node, which means this node is the last sampling point).
[0122] Then calculate the interval between the first node and the next node: Node0.Step = NOde1.LutX - Node0.LutX. Here, Nodei.Step represents the abscissa difference between sampling point i and sampling point i + 1.
[0123] And set the current number of nodes Entry = 2. At this time, the corresponding LUT sampling point diagram is as Figure 3 shown, and the corresponding linked list structure is as Figure 4 shown. Among them, node 0 can also be represented as Node0, and node 1 can also be represented as Node1, Figure 4 and the error value in [[ ]] can also be represented as maxDiff.
[0124] After that, calculate the error of all nodes in the current linked list. From Figure 3 it can be seen that the initialized LUT only contains two sampling points, sample0 and sample1, and these two sampling points are represented by Node0 and Node1. Among them, Count0 represents the curve between Node0 and Node1.
[0125] First, start from the first node, calculate the maximum error between the result of linear interpolation between the current node and the next node and the discrete curve, and obtain the error value of the current node (that is, maxDiff, and this value is stored in the data structure of the current node).
[0126] Since the abscissa difference (that is, Step) of the x-axis interval between the current node and the next node must satisfy 2 n , n = 0, 1, 2... 10 (for example, the current node Node0.Step = 1 << QuanX, which satisfies 2 QuanX , QuanX = 10), so for any integer X ∈ [Node0.LutX, Node1.LutX], the calculation formula for the linear interpolation output Y between two adjacent nodes is:[[]]
[0127] Y = LinearInterp(Node0, Node1, X)
[0128] =(Node0.LutY*(Node1.LutX - X)+Node1.LutY*(X - Node0.LutX)+(1 << (QuanX - 1))) >> QuanX
[0129] For the discrete curve CurveY, when any integer X ∈ [Node0.LutX, Node1.LutX] is used as the input, the output is CurveY[X]. LinearInterp represents the linear interpolation function.
[0130] To effectively reduce the computational complexity of calculating the maximum error, here X is changed in iteration steps of iterStep, and the iteration step is half of the Step value (i.e., the abscissa difference) of the current node, that is, iterStep = Node.Step >> 1, namely:
[0131] Node0.maxDiff = max(|LinearInterp(Node0, Node1, X) - CurveY[X]|), X = Node0.LutX, Node0.LutX + iterSte, Node1.LutX, for a total of three iterations.
[0132] Then, by analogy, calculate the maximum error Node1.maxDiff between the result of linear interpolation between the next node and the next - next node and the discrete curve until the last node. For the current linked list, the error value of the current node is Node0.maxDiff = 127.3. The next value (i.e., the pointer) of the next node of the current node is null, that is, there is no subsequent node for the next node (no subsequent sampling points), so this step of calculation ends (Node1.maxDiff = 0). The updated linked list corresponding to it is as Figure 5 shown. Among them, Nodei.maxDiff represents the error value corresponding to the sampling point i.
[0133] After determining the error value, find the node corresponding to the maximum error value in the current linked list. First, start from the first node, record the maxDiff value of the current node as the value of LarDiff (the value of LarDiff represents the maximum error value found so far), and let the pointer LarNode point to the current node (the node pointed to by LarNode represents the node corresponding to the maximum error value found so far). Then use the next pointer to find the next node, and judge whether the maxDiff value of the next node is greater than the value of LarDiff. If it is greater, update the value of LarDiff to the maxDiff value of the next node, and update the pointer LarNode to point to the next node, otherwise skip. Then continue to use the next pointer of the next node to find the next-next node, and so on until the last node (the next pointer of the last node is null). After the traversal is completed, the node pointed to by LarNode is the node with the largest maxDiff value in the current linked list.
[0134] The maxDiff value of the node LarNode represents that the maxDiff between the sampling point corresponding to the current node and the next sampling point is the maximum among the maxDiff of all adjacent sampling points.
[0135] After determining the target node with the largest error value, insert a new node between the target node and the next node of the target node.
[0136] The specific steps for inserting a new node are as follows: First, judge whether the length Entry of the current linked list is equal to the SetEntry set during initialization (a preset threshold, for example, set to 5). If they are equal, the table building algorithm exits, otherwise proceed to the next step to create a new node.
[0137] The Step value of the new node newNode is half of the target node LarNode, that is: newNode.Step = LarNode.Step / 2. Among them, newNode.Step represents the Step value of the new node, and LarNode.Step represents the Step value of the target node.
[0138] The LutX value of the new node newNode is the LutX value of the node LarNode plus the Step value of the new node newNode, that is: newNode.LutX = LarNode.Lutx + newNode.Step. Among them, newNode.LutX represents the abscissa of the new node, and LarNode.Lutx represents the abscissa of the target node.
[0139] The LutY value of the new node newNode is the y - coordinate value corresponding to LutX on the discrete curve. newNode.LutY = CurveY[newNode.LutX]. Here, newHode.LutY represents the ordinate of the new node.
[0140] Insert the new node newNode between the target node LarNode and its subsequent node. First, reset the subsequent node of the target node LarNode to be the subsequent node of the new node newNode, and at the same time set the subsequent node of the target node LarNode to be the new node newNode, that is: newNode.next = LarNode.next; LarNode.next = newNode. The corresponding linked list is as Figure 6 shown.
[0141] Since inserting a new node behind the target node LarNode means adding a new sampling point sample1 after the node sample0 in the LUT (the original sample1 will be updated to sample2), as Figure 7 shown. It can be seen that the error between the results of linear interpolation between sample0 and sample1, and between sample1 and sample2 and the discrete curve will change. At the same time, the interval between the node sample0 and the node sample1 on the x - axis will also change. In the linked list, this is manifested as a change in the maxDiff of the target node LarNode, and the Step value of the LarNode node will also change. Here, Count0 represents the curve between Node0 and Node1, and Count1 represents the curve between Node1 and Node2.
[0142] Therefore, update the Step and maxDiff of the target node, and update the maxDiff of the new node.
[0143] The Step value of the target node is updated to: LarNode.Step = LarNode.Step / 2. That is, it is half of the original step.
[0144] For the maxDiff value of the target node LarNode, the aforementioned error calculation formula is used for update. The iteration step iterSte is half of the Step value (the updated Step value) of the target node, that is iterSte = LarNode.Step / 2 = Node0.Step / 2, that is:
[0145] LarNode.maxDiff = Node0.maxDiff = max(|LinearInterp(Node0, Node1, X) - CurveY[X]|), where X = Node0.LutX, Node0.LutX + iterSte, Node1.LutX.
[0146] For the maxDiff value of the new node newNode, it is updated using the aforementioned error calculation formula. The iteration step iterSte is half of the Step value of the new node, that is, iterSte = newNode.Step / 2 = Node1.Step / 2. Namely:
[0147] newNode.maxDiff = Node1.maxDiff = max(|LinearInterp(Node1, Node2, X) - CurveY[X]|), where X = Node1.LutX, Node1.LutX + iterSte, Node2.LutX.
[0148] Finally, update the Entry of the linked list by incrementing the Entry by one.
[0149] After that, continue to check whether Entry is equal to the preset threshold. If not, continue to insert new nodes until Entry is equal to the preset threshold, and then exit the table building process. The LutX, LutY information, and Entry from the first node to the last node are the established LUT.
[0150] Take Figure 8 the curve function shown as an example. The prototype of its corresponding objective function is y = sin(x 2 ) + 1.5, where x ∈ [0, 2.17]. Sample this function into 1025 uniformly spaced sampling points. Some of its data are as follows: Curve(Norm)
[1025] : [1.5, 1.50000449, 1.50001796, 1.50004042, 1.50007185,..., 0.50080813, 0.5004817, 0.50023903, 0.50008041, 0.50000609]. Here, function represents this curve function.
[0151] Quantize the abscissa and ordinate of this function respectively. The quantization bit width of the abscissa is 10 bits, and the quantization bit width of the ordinate is 8 bits. Set the maximum number of nodes to 17.
[0152] The function lookup table established using the function lookup table building method provided by this solution is:
[0153] LutX
[16] : [128, 256, 384, 448, 512, 576, 640, 672, 704, 736, 768, 832, 896, 960, 992, 1024]. Since the first value of X is 0, it can be omitted here.
[0154] LutY
[17] : [383, 401, 456, 539, 582, 618, 637, 628, 611, 585, 549, 503, 391, 268, 168, 138, 128]. The sampling points and the curve are as Figure 9 shown, testCurve represents the curve function, and sample represents the node.
[0155] Using the aforementioned error calculation method, the maximum error calculated is 0.822%.
[0156] If the maximum number of nodes is set to 33, the function look-up table established by using the function look-up table establishment method provided by this solution is:
[0157] LutX
[32] : [64, 128, 192, 256, 320, 384, 416, 448, 480, 512, 544, 576, 592, 608, 624, 640, 656, 672, 688, 704, 736, 752, 768, 784, 800, 832, 896, 928, 960, 992, 1008, 1024].
[0158] LutY
[33] : [383, 387, 401, 425, 456, 496, 539, 561, 582, 602, 618, 630, 637, 637, 636, 633, 628, 621, 611, 599, 585, 549, 527, 503, 477, 450, 391, 268, 213, 168, 138, 130, 128]. The sampling points and the curve are as Figure 10 shown, testCurve represents the curve function, and sample represents the node.
[0159] Using the aforementioned error calculation method, the maximum error calculated is 0.298%.
[0160] When using this solution to process the above curve, compared with the conventional function look-up table establishment method, this solution can obtain the function look-up table more quickly.
[0161] Based on the same technical concept, this application also provides a function look-up table establishment device, as Figure 11 shown, the function look-up table establishment device 100 includes an acquisition module 110 and a processing module 120.
[0162] An acquisition module 110 is configured to acquire the node data of the start node, end node, and median node of a target function respectively, where the node data includes the coordinate information of the node.
[0163] A processing module 120 is configured to determine two adjacent nodes with the largest error, add a new node between the two adjacent nodes, and calculate and generate the node data of the new node, and repeat this step until the number of nodes reaches a preset threshold; where the error is the error between the linear function formed by two adjacent nodes and the target function within the abscissa range of the two adjacent nodes.
[0164] The processing module 120 is further configured to obtain a function look-up table based on all the obtained node data.
[0165] In one implementation, the abscissa of the new node is the average value of the abscissas of the two adjacent nodes with the largest error.
[0166] The node data further includes an error value, where the error value is: the magnitude of the error between the linear function formed by the first node corresponding to the node data and the next node of the first node and the target function within the abscissa range of the first node and the next node of the first node; correspondingly, the processing module 120 is specifically configured to determine the node corresponding to the largest error value in all the node data as the target node; determine the target node and the next node of the target node as the two adjacent nodes with the largest error; correspondingly, after adding a new node between the two adjacent nodes, the processing module 120 is further configured to update the error value in the node data of the target node.
[0167] The processing module 120 is specifically configured to select a plurality of error test abscissas between the abscissa of the first node and the abscissa of the next node of the first node; for each error test abscissa, determine the first ordinate of the error test abscissa in the linear function formed by the first node and the next node, and the second ordinate of the error test abscissa in the target function; obtain the test error corresponding to the error test abscissa based on the first ordinate and the second ordinate; and obtain the error value of the first node based on all the obtained test errors.
[0168] The processing module 120 is specifically configured to use the maximum value among all the obtained test errors as the error value of the first node.
[0169] The processing module 120 is specifically configured to sequentially determine a plurality of error test abscissas at preset intervals starting from the abscissa of the first node and ending at the abscissa of the next node of the first node.
[0170] In one implementation, the preset step size is an integer power of 2.
[0171] In one implementation, the node data further includes an abscissa difference, where the abscissa difference is the difference between the abscissa of the first node corresponding to the node data and the abscissa of the next node of the first node; the abscissa of the new node is x1 + △x / 2; where x1 is the abscissa of the target node and △x is the abscissa difference corresponding to the target node.
[0172] In one implementation, the node data further includes the storage address of the node data of the next node.
[0173] The processing module 120 is specifically configured to store the abscissa values in all node data in ascending order to obtain an abscissa array; store the corresponding ordinate values in sequence according to the storage order of the abscissa values to obtain an ordinate array; configure the abscissa array and the ordinate array into the chip registers; where the function lookup table in the chip includes the abscissa array and the ordinate array configured in the chip registers.
[0174] The function lookup table building device 100 provided by the embodiments of the present application has the same implementation principle and the same technical effects as those of the foregoing function lookup table building method embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing function lookup table building method embodiments.
[0175] Based on the same technical concept, the present application further provides a chip, which includes registers. Among them, a function lookup table is configured in the registers.
[0176] The function lookup table configured in the registers is established based on the foregoing function lookup table building method. The specific implementation manner and principle of the function lookup table building method have been clearly described above. For the sake of brief description, it will not be repeated here.
[0177] The chip can be, for example, an FPGA (Field Programmable Gate Array), a storage chip with a storage function, an arithmetic chip that needs to perform calculations, etc.
[0178] Please refer to Figure 12 , which is an electronic device 200 provided by the embodiments of the present application. The electronic device 200 includes: a processor 210 and a memory 220.
[0179] The memory 220 and the processor 210 are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines. The memory 220 is used to store computer programs, such as storing Figure 11 The software function module shown in is the function lookup table establishment device 100. The function lookup table establishment device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 200. The processor 210 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the function lookup table establishment device 100. At this time, the processor 210 is used to obtain the node data of the starting node, the ending node, and the median node of the target function, wherein the node data includes the coordinate information of the node; determine the two adjacent nodes with the largest error, add a new node between the two adjacent nodes, and calculate and generate the node data of the new node, and repeat this step until the number of nodes reaches a preset threshold; wherein the error is the error between the straight line function formed by the two adjacent nodes and the target function within the horizontal coordinate range of the two adjacent nodes; based on all the obtained node data, a function lookup table is obtained.
[0180] Among them, the memory 220 can be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0181] The processor 210 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor 210 may also be any conventional processor, etc.
[0182] Among them, the above-mentioned electronic device 200 includes, but is not limited to, a personal computer, a server, etc.
[0183] The embodiments of the present application also provide a computer-readable storage medium (hereinafter referred to as the storage medium). A computer program is stored on the storage medium. When the computer program is run by a computer such as the above-mentioned electronic device 200, it executes the function lookup table establishment method shown above. The computer-readable storage medium may include: various media that can store program codes such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk, or an optical disc.
[0184] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application may have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.
Claims
1. A method for establishing a function lookup table, characterized in that: include: Obtaining node data of each of the starting node, the ending node, and the median node of the objective function, wherein the node data includes coordinate information of the node; Determine two adjacent nodes with the largest error, add a new node between the two adjacent nodes, calculate and generate node data of the new node, and repeat this step until the number of nodes reaches a preset threshold; wherein the error is the error between the straight line function formed by the two adjacent nodes and the objective function within the horizontal coordinate range of the two adjacent nodes; Based on all the obtained node data, a function lookup table is obtained.
2. The method according to claim 1, characterized in that The horizontal coordinate of the new node is the average of the horizontal coordinates of the two adjacent nodes with the largest errors.
3. The method according to claim 1, characterized in that The node data also includes an error value, which is: the magnitude of the error between the linear function formed by the first node and the next node of the first node corresponding to the node data and the target function within the horizontal coordinate range of the first node and the next node of the first node; Accordingly, the two adjacent nodes with the largest error are determined, including: Determine the node corresponding to the largest error value among all node data as the target node; Determine that the target node and the next node of the target node are two adjacent nodes with the largest error; Accordingly, after adding a new node between the two adjacent nodes, the method further includes: The error value in the node data of the target node is updated.
4. The method according to claim 3, characterized in that The error value is calculated in the following way: Selecting a plurality of error test abscissas between the abscissa of the first node and the abscissa of a node next to the first node; For each error test horizontal coordinate, determine a first vertical coordinate of the error test horizontal coordinate in the straight line function formed by the first node and the next node, and a second vertical coordinate of the error test horizontal coordinate in the objective function; and obtain a test error corresponding to the error test horizontal coordinate based on the first vertical coordinate and the second vertical coordinate; Based on all obtained test errors, the error value of the first node is obtained.
5. The method according to claim 4, characterized in that Obtaining the error value of the first node based on all obtained test errors includes: The maximum value of all the test errors obtained is used as the error value of the first node.
6. The method according to claim 4, characterized in that Choose from multiple error test abscissas, including: Taking the horizontal coordinate of the first node as a starting point and the horizontal coordinate of a node next to the first node as an end point, a plurality of error test horizontal coordinates are determined in sequence at intervals of a preset step length.
7. The method according to claim 6, characterized in that The preset step size is an integer power of 2.
8. The method according to claim 3, characterized in that The node data also includes a horizontal coordinate difference, and the horizontal coordinate difference is: the difference between the horizontal coordinate of the first node corresponding to the node data and the horizontal coordinate of the next node of the first node; The horizontal coordinate of the new node is x1+△x / 2; wherein x1 is the horizontal coordinate of the target node, and △x is the horizontal coordinate difference corresponding to the target node.
9. The method according to claim 1, characterized in that: The node data also includes the storage address of the node data of the next node.
10. The method according to any one of claims 1 to 9, characterized in that: After obtaining the function lookup table, the method further includes: The function lookup table is configured into a chip register.
11. The method according to claim 10, characterized in that Based on all the obtained node data, a function lookup table is obtained, including: The horizontal coordinate values in all node data are stored in order of size to obtain a horizontal coordinate array; According to the storage order of the horizontal coordinate values, the corresponding vertical coordinate values are stored in sequence to obtain the vertical coordinate array; The configuring the function lookup table into a chip register comprises: The horizontal coordinate array and the vertical coordinate array are configured in the chip register; wherein the function lookup table in the chip includes the horizontal coordinate array and the vertical coordinate array configured in the chip register.
12. A function lookup table establishment device, characterized in that: include: An acquisition module, used to acquire node data of each of the starting node, the ending node, and the median node of the objective function, wherein the node data includes coordinate information of the node; A processing module is used to determine two adjacent nodes with the largest error, add a new node between the two adjacent nodes, and calculate and generate node data of the new node, and repeat this step until the number of nodes reaches a preset threshold; wherein the error is the error between the straight line function formed by the two adjacent nodes and the target function within the horizontal coordinate range of the two adjacent nodes; The processing module is further used to obtain a function lookup table based on all the obtained node data.
13. A chip, characterized in that: include: A register, wherein the register is configured with a function lookup table established based on the method according to any one of claims 1 to 11.
14. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are connected; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1-11.
15. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a computer, the method according to any one of claims 1 to 11 is executed.