Fast evaluation method and system supporting any function
By introducing segment intervals and sampling step size settings into the hardware structure, combined with interpolation computer system, the accuracy and adaptability problems of the lookup table method under resource constraints are solved, and efficient and accurate evaluation of complex functions is achieved, which is suitable for multi-type activation functions in artificial intelligence accelerators.
Patent Information
- Application Number
- CN202510829883.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-06-20
AI Technical Summary
The existing lookup table method has limitations in value search accuracy and adaptability, and it is difficult to meet the accuracy and flexibility requirements of complex functions evaluation, especially under resource constraints, which is difficult to adapt to the evaluation tasks of multi-type objective functions.
By introducing segment interval setting, sampling step setting and interpolation computer system into the hardware structure, the lookup table memory is configured as a dual static random access memory or register table memory, and the segment interval and sampling step size are dynamically configured to achieve efficient and accurate evaluation of the objective function.
It improves the calculation accuracy and flexibility of the objective function, adapts to the evaluation requirements of different types of functions, and improves the efficiency and adaptability of hardware resource utilization, especially in the field of artificial intelligence accelerators for frequently changing activation functions.
Smart Images

Figure CN120336684A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of chip processing, and in particular, to a method and system for fast evaluation of arbitrary functions. Background Art
[0002] Currently, the common hardware methods for complex functions in digital signal processing related chips are divided into approximate calculation methods and look-up table methods. Among them, the approximate calculation method converts complex functions into a series of multiplication and addition operations through mathematical formulas for easy hardware execution. This method has high implementation accuracy, but large computational complexity, occupies a large amount of hardware resources, and is not applicable to all complex functions, restricting its actual application scenarios. In contrast, the look-up table method pre-stores the output values of complex functions in an internal memory in advance, and when the hardware runs, the input variables are used as address indexes to look up the output values of complex functions in the table. Using the look-up table method to implement complex functions has the advantages of low computational complexity and low resource occupancy. However, the existing look-up table method still has obvious limitations in terms of value lookup accuracy and adaptability, and it is difficult to flexibly adjust the segmentation strategy and sampling accuracy according to the complexity of complex functions, and it is difficult to meet the application scenarios with high requirements for the evaluation accuracy and flexibility of complex functions. Summary of the Invention
[0003] The present invention provides a method and system for fast evaluation of arbitrary functions, which realizes efficient and accurate evaluation of complex functions under resource-constrained conditions by introducing a segmentation interval setting, a sampling step setting, and an interpolation calculation mechanism in the hardware structure.
[0004] The embodiments of the present invention provide a method for fast evaluation of arbitrary functions, including: Configuring hardware parameters, where the hardware parameters include the upper limit of the look-up table capacity and the preset number of segmentation intervals; Dividing the value range of the input variables of the target function into multiple segmentation intervals, where the number of the segmentation intervals is the preset number of segmentation intervals, determining the starting point of the input variables and the corresponding sampling step in each segmentation interval, and performing discrete sampling on the input variables based on the corresponding sampling step in each segmentation interval, calculating the output value of the target function corresponding to each sampling point, and the output value of the target function corresponding to the starting point of the input variables in each segmentation interval is the starting threshold; Arranging each starting threshold and the output value of the target function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and writing them into the look-up table memory in sequence, where the look-up table memory is a dual static random access memory or a register table memory; During the process of calling the objective function, determine the current segmented interval and the corresponding current sampling step according to the current input variable, and look up the first sampling point and the second sampling point adjacent to the current input variable within the current segmented interval from the lookup table memory, and respectively read the first objective function output value and the second objective function output value corresponding to the first sampling point and the second sampling point; Based on the first objective function output value, the second objective function output value, the starting threshold, and the current sampling step, calculate the objective function output value corresponding to the current input variable according to the interpolation formula.
[0005] Preferably, the lookup table memory is used to establish the correspondence between the starting point of each input variable and the starting threshold, and the correspondence between each sampling point and the objective function output value.
[0006] Preferably, the dual static random access memory includes a first static random access memory and a second static random access memory, and is used to store the objective function output values corresponding to two adjacent sampling points within the same segmented interval.
[0007] Preferably, the register table memory is used to arrange in the order of the segmented intervals and the index order of the sampling points, and linearly store the starting threshold of each segmented interval and the objective function output value corresponding to each sampling point.
[0008] Preferably, this method supports dynamic configuration of the lookup table memory during the process of calling the objective function, and the dynamic configuration includes: Keep the starting point of the input variable and the sampling step of each segmented interval unchanged, and replace the objective function; Keep the objective function unchanged, and reset the starting point of the input variable and its corresponding sampling step of each segmented interval; Modify the objective function, the starting point of the input variable of each segmented interval, and its corresponding sampling step at the same time.
[0009] Preferably, the interpolation formula is:
[0010] where output is the objective function output value, lut[n] is the first objective function output value, lut[n + 1] is the second objective function output value, step is the current sampling step, and index is the address index of the objective function output value in the lookup table memory; The calculation formula of index is:
[0011] Among them, input is the current input variable, th is the starting point of the input variable in the current segmented interval, and input - th is the offset of the current input variable in the current segmented interval.
[0012] Preferably, the upper limit of the lookup table capacity is 16, the number of preset segmented intervals is 4, and the lookup table memory is a dual - static random access memory, which is used to parallel - read the output values of the first objective function and the second objective function of the current input variable in the current segmented interval.
[0013] Preferably, the upper limit of the lookup table capacity is 8, the number of preset segmented intervals is 2, and the lookup table memory is a register - table memory, which is used to sequentially read the output values of the first objective function and the second objective function of the current input variable in the current segmented interval.
[0014] Preferably, the upper limit of the lookup table capacity and the number of preset segmented intervals are set in the initialization stage of the fast evaluation method, and remain unchanged during the execution of the fast evaluation method.
[0015] The embodiment of the present invention also provides a fast evaluation system supporting any function, including: A hardware parameter configuration module for configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmented intervals; A target - function sampling parameter determination module for dividing the value range of the input variable of the target function into multiple segmented intervals, where the number of the segmented intervals is the number of preset segmented intervals, determining the starting point of the input variable and the corresponding sampling step size for each segmented interval, and performing discrete sampling on the input variable based on the corresponding sampling step size within each segmented interval, calculating the output value of the target function corresponding to each sampling point, and the output value of the target function corresponding to the starting point of the input variable in each segmented interval is the starting threshold; A lookup - table memory configuration module for arranging the starting threshold and the output value of the target function corresponding to the sampling point in the order of the segmented intervals and the index order of the sampling points, and sequentially writing them into the lookup - table memory, where the lookup - table memory is a dual - static random access memory or a register - table memory; A value - lookup module based on the lookup - table memory, during the call of the target function, determining the current segmented interval and the corresponding current sampling step size according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable in the current segmented interval from the lookup - table memory, and respectively reading the output values of the first objective function and the second objective function corresponding to the first sampling point and the second sampling point; An interpolation calculation module calculates the output value of the objective function corresponding to the current input variable according to an interpolation formula based on the output value of the first objective function, the output value of the second objective function, the starting threshold, and the current sampling step size.
[0016] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects: A fast evaluation method and system for supporting any function according to an embodiment of the present invention. The method includes: configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals; dividing the value range of the input variable of the objective function into multiple segmentation intervals, where the number of the segmentation intervals is the number of preset segmentation intervals, determining the starting point of the input variable and the corresponding sampling step size for each segmentation interval, and discretely sampling the input variable based on the corresponding sampling step size within each segmentation interval, calculating the output value of the objective function corresponding to each sampling point, and the output value of the objective function corresponding to the starting point of the input variable in each segmentation interval is the starting threshold; arranging each starting threshold and the output value of the objective function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and sequentially writing them into a lookup table memory, where the lookup table memory is a dual-static random access memory or a register table memory; during the call of the objective function, determining the current segmentation interval and the corresponding current sampling step size according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and respectively reading the first output value of the objective function and the second output value of the objective function corresponding to the first sampling point and the second sampling point; calculating the output value of the objective function corresponding to the current input variable according to an interpolation formula based on the first output value of the objective function, the second output value of the objective function, the starting threshold, and the current sampling step size. By segmenting the value range of the input variable of the objective function and using different sampling step sizes for different segmentation intervals, the overall calculation accuracy of the objective function is improved. Furthermore, it supports dynamic configuration of the lookup table memory during the call of the objective function, that is, the starting point of the input variable and its corresponding sampling step size in each segmentation interval can be adjusted in real time according to usage requirements, thereby significantly enhancing the compatibility and operation flexibility for evaluation tasks of multiple types of objective functions, and is particularly suitable for complex application scenarios with adjustable precision and frequent changes of objective functions. Furthermore, by setting different lookup table capacities and the number of segmentation intervals, and configuring the lookup table memory as a dual-static random access memory or a register table memory, parallel reading of the output values of the objective function can be achieved when hardware resources are sufficient, improving the overall lookup efficiency; under resource-constrained conditions, linear sequential reading of the output values of the objective function can be achieved, reducing the occupancy of hardware resources while ensuring the evaluation accuracy of the objective function, thereby enhancing the adaptability and practicality of the present invention on various hardware platforms. Furthermore, in the field of artificial intelligence accelerators, the activation functions of different artificial intelligence algorithms are different, and with the iteration of artificial intelligence algorithms, various activation functions will emerge. At this time, the present application can implement different activation functions on the same hardware platform, and when modifying the transformation function, the accuracy of function implementation can be optimized according to the characteristics of the function. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention, rather than all embodiments. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0018] Figure 1 Schematic flowchart of a method for quickly evaluating an arbitrary function provided by an embodiment of the present invention; Figure 2 Schematic diagram of the corresponding relationship between the segmented intervals and sampling points of the objective function provided by an embodiment of the present invention; Figure 3 Schematic diagram of the storage structure of the lookup table memory provided by an embodiment of the present invention; Figure 4 Schematic flowchart of a method for quickly evaluating an arbitrary function provided by another embodiment of the present invention; Figure 5 Schematic diagram of the corresponding relationship between the segmented intervals and sampling points of the objective function provided by another embodiment of the present invention; Figure 6 Schematic diagram of the storage structure of the lookup table memory provided by another embodiment of the present invention; Figure 7 Schematic diagram of the modules of a system for quickly evaluating an arbitrary function provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0020] The technical solution of the present invention will be described in detail below with specific embodiments. The following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0021] In the field of artificial intelligence accelerators, the activation functions of different artificial intelligence algorithms are different, and with the iteration of artificial intelligence algorithms, various activation functions will appear. At this time, the present application can implement different activation functions on the same hardware platform, and when modifying the transformation function, the accuracy of function implementation can be optimized according to the characteristics of the function.
[0022] Based on the problems existing in the prior art, the present invention provides a method and system for quickly evaluating any function, which realizes efficient and accurate evaluation of complex functions under resource-constrained conditions by introducing a segmented interval setting, a sampling step setting, and an interpolation calculation mechanism in the hardware structure.
[0023] Embodiment 1: Figure 1 It is a flowchart of a method for quickly evaluating any function provided by an embodiment of the present invention. Now refer to Figure 1 An embodiment of the present invention provides a method for quickly evaluating any function, including: Step S101: Configure hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the preset number of segmented intervals. The upper limit of the lookup table capacity is 16, and the preset number of segmented intervals is 4.
[0024] In this embodiment, the upper limit of the lookup table capacity and the preset number of segmented intervals are set in the initialization stage of the quick evaluation method, and remain unchanged during the execution of the quick evaluation method.
[0025] Step S102: Divide the input variable values of the target function into multiple segmented intervals. The number of segmented intervals is the preset number of segmented intervals. Determine the starting point of the input variable and the corresponding sampling step for each segmented interval, and perform discrete sampling on the input variable within each segmented interval based on the corresponding sampling step, and calculate the output value of the target function corresponding to each sampling point. The output value of the target function corresponding to the starting point of the input variable in each segmented interval is the starting threshold.
[0026] Step S103: Arrange each starting threshold and the output value of the target function corresponding to the sampling point in the order of the segmented intervals and the index order of the sampling points, and write them into the lookup table memory in sequence. The lookup table memory is a dual static random access memory.
[0027] In this embodiment, the dual static random access memory includes a first static random access memory SRAM0 and a second static random access memory SRAM1.
[0028] Step S104: During the process of calling the target function, determine the current segmentation interval and the corresponding current sampling step according to the current input variable, and look up the first sampling point and the second sampling point adjacent to the current input variable within the current segmentation interval from the lookup table memory, and read the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point respectively.
[0029] In this embodiment, the method supports dynamically configuring the lookup table memory during the process of calling the target function, and the dynamic configuration includes: Keep the starting point of the input variable and the sampling step of each segmentation interval unchanged, and replace the target function to support the fast evaluation of different target functions.
[0030] Keep the target function unchanged, reset the starting point of the input variable and its corresponding sampling step of each segmentation interval, and realize the calculation with different precisions for the same target function.
[0031] Modify the target function, the starting point of the input variable of each segmentation interval and its corresponding sampling step at the same time to meet the lookup value requirements of different target functions at different precisions.
[0032] Step S105: Based on the first target function output value, the second target function output value, the starting threshold, and the current sampling step, calculate the target function output value corresponding to the current input variable according to the interpolation formula.
[0033] The interpolation formula is:
[0034] where output is the target function output value, lut[n] is the first target function output value read from SRAM0, lut[n + 1] is the second target function output value read from SRAM1, step is the current sampling step, and index is the address index of the target function output value in the lookup table memory.
[0035] In this embodiment, the upper limit of the lookup table capacity is 16, so index is a 4-bit address index.
[0036] The calculation formula of index is:
[0037] where input is the current input variable, th is the starting point of the input variable of the current segmentation interval, and input - th is the offset of the current input variable in the current segmentation interval.
[0038] Figure 2Schematic diagram of the correspondence between the segmented intervals of the objective function and the sampling points provided for an embodiment of the present invention. Now refer to Figure 2 The correspondence between the segmented intervals of the objective function and the sampling points provided for an embodiment of the present invention includes: In this embodiment, the objective function is f(x), and the input variable of the objective function is x. The upper limit of the lookup table capacity is 16, that is, the lookup table memory can store 16 output values of the objective function. The number of segmented intervals is 4, that is, the input variable x of the objective function is divided into 4 segmented intervals, namely segmented interval 0, segmented interval 1, segmented interval 2, and segmented interval 3, and the corresponding sampling step sizes are sampling step size 0, sampling step size 1, sampling step size 2, and sampling step size 3. In each of the segmented intervals, the input variable x is discretely sampled based on the corresponding sampling step size, and the output value of the objective function corresponding to each sampling point is calculated.
[0039] Among them, the output value of the objective function corresponding to the starting point of the input variable in segmented interval 0 is starting threshold 0, the output value of the objective function corresponding to the starting point of the input variable in segmented interval 1 is starting threshold 1, the output value of the objective function corresponding to the starting point of the input variable in segmented interval 2 is starting threshold 2, and the output value of the objective function corresponding to the starting point of the input variable in segmented interval 3 is starting threshold 3.
[0040] Figure 3 Schematic diagram of the storage structure of the lookup table memory provided for an embodiment of the present invention. Now refer to Figure 3 The storage structure of the lookup table memory provided for an embodiment of the present invention includes: In this embodiment, the lookup table memory is used to establish the correspondence between each starting point of the input variable and the starting threshold, and the correspondence between each sampling point and the output value of the objective function.
[0041] The dual static random access memory includes a first static random access memory SRAM0 and a second static random access memory SRAM1, and is used to store the output values lut i,n and th i,n+1 of the objective function corresponding to two adjacent sampling points th i [n] and lut i [n + 1] in the same segmented interval.
[0042] During the process of calling the objective function, the dual static random access memory is used to parallelly read the first output value and the second output value of the objective function of the current input variable in the current segmented interval. It can satisfy the hardware to read two output values of the objective function within one clock cycle, thereby improving the value lookup efficiency of the objective function and the overall calculation speed.
[0043] Embodiment 2: Figure 4Flow chart of the fast evaluation method for supporting any function provided for another embodiment of the present invention. Now refer to Figure 4 The fast evaluation method for supporting any function provided by the embodiment of the present invention includes: Step S201: Configure hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals. The upper limit of the lookup table capacity is 8, and the number of preset segmentation intervals is 2.
[0044] In this embodiment, the upper limit of the lookup table capacity and the number of preset segmentation intervals are set in the initialization stage of the fast evaluation method and remain unchanged during the execution of the fast evaluation method.
[0045] Step S202: Divide the value range of the input variable of the target function into multiple segmentation intervals. The number of the segmentation intervals is the number of preset segmentation intervals. Determine the starting point of the input variable and the corresponding sampling step size for each segmentation interval, and perform discrete sampling on the input variable within each segmentation interval based on the corresponding sampling step size. Calculate the output value of the target function corresponding to each sampling point. The output value of the target function corresponding to the starting point of the input variable of each segmentation interval is the starting threshold.
[0046] Step S203: Arrange each starting threshold and the output value of the target function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and write them into the lookup table memory in sequence. The lookup table memory is a register table memory.
[0047] Step S204: During the process of calling the target function, determine the current segmentation interval and the corresponding current sampling step size according to the current input variable. Look up the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and read the first output value of the target function and the second output value of the target function corresponding to the first sampling point and the second sampling point respectively.
[0048] In this embodiment, the method supports dynamic configuration of the lookup table memory during the process of calling the target function. The dynamic configuration includes: Keep the starting point of the input variable and the sampling step size of each segmentation interval unchanged, and replace the target function to support the fast evaluation of different target functions.
[0049] Keep the target function unchanged, reset the starting point of the input variable and its corresponding sampling step size for each segmentation interval to achieve different-precision calculations for the same target function.
[0050] Modify the target function, the starting point of the input variable of each segmentation interval and its corresponding sampling step size at the same time to meet the lookup value requirements of different target functions at different precisions.
[0051] Step S205: Based on the output value of the first objective function, the output value of the second objective function, the starting threshold, and the current sampling step, calculate the output value of the objective function corresponding to the current input variable according to the interpolation formula.
[0052] The interpolation formula is:
[0053] where output is the output value of the objective function, lut[n] and lut[n + 1] are the output values of the first objective function and the second objective function sequentially read from the register table memory, step is the current sampling step, and index is the address index of the output value of the objective function in the lookup table memory.
[0054] The calculation formula for index is:
[0055] where input is the current input variable, th is the starting point of the input variable in the current segmented interval, and input - th is the offset of the current input variable in the current segmented interval.
[0056] Figure 5 It is a schematic diagram of the correspondence between the segmented intervals and sampling points of the objective function provided by another embodiment of the present invention. Now refer to Figure 5 , the correspondence between the segmented intervals and sampling points of the objective function provided by the embodiment of the present invention includes: In this embodiment, the objective function is f(x), and the input variable of the objective function is x. The upper limit of the lookup table capacity is 8, that is, the lookup table memory can store 8 output values of the objective function. The number of segmented intervals is 2, that is, the input variable x of the objective function is divided into 2 segmented intervals, namely segmented interval 0 and segmented interval 1, and the corresponding sampling steps are sampling step 0 and sampling step 1 respectively. The input variable x is discretely sampled based on the corresponding sampling step in each segmented interval, and the output value of the objective function corresponding to each sampling point is calculated.
[0057] Among them, the output value of the objective function corresponding to the starting point of the input variable in segmented interval 0 is starting threshold 0, and the output value of the objective function corresponding to the starting point of the input variable in segmented interval 1 is starting threshold 1.
[0058] Figure 6 It is a schematic diagram of the storage structure of the lookup table memory provided by another embodiment of the present invention. Now refer to Figure 6 , the storage structure of the lookup table memory provided by the embodiment of the present invention includes: In this embodiment, the lookup table memory is used to establish the correspondence between the starting point of each input variable and the starting threshold, as well as the correspondence between each sampling point and the output value of the objective function.
[0059] The register table memory is used to arrange in the order of the segmentation intervals and the index order of the sampling points, and linearly store the starting threshold of each segmentation interval and the output value of the objective function corresponding to each sampling point.
[0060] During the process of calling the objective function, the register table memory is used to sequentially read the first output value and the second output value of the objective function of the current input variable within the current segmentation interval. Thus, it is possible to complete the sequential access of the two output values of the objective function within two clock cycles, saving hardware resources while ensuring calculation accuracy, and being applicable to scenarios with limited hardware resources.
[0061] Figure 7 It is a schematic diagram of the module of the fast evaluation system supporting any function provided by an embodiment of the present invention. Now refer to Figure 7 , an embodiment of the present invention provides a fast evaluation system 700 supporting any function, including: A configure hardware parameter module 701 for configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals.
[0062] A determine objective function sampling parameter module 702 for dividing the value range of the input variable of the objective function into multiple segmentation intervals, where the number of the segmentation intervals is the number of preset segmentation intervals, determining the starting point of the input variable and the corresponding sampling step in each segmentation interval, and discretely sampling the input variable based on the corresponding sampling step within each segmentation interval, and calculating the output value of the objective function corresponding to each sampling point, and the output value of the objective function corresponding to the starting point of the input variable in each segmentation interval is the starting threshold.
[0063] A configure lookup table memory module 703 for arranging each starting threshold and the output value of the objective function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and sequentially writing them into the lookup table memory, where the lookup table memory is a dual static random access memory or a register table memory.
[0064] A lookup value based on lookup table memory module 704 for, during the process of calling the objective function, determining the current segmentation interval and the corresponding current sampling step according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable within the current segmentation interval from the lookup table memory, and respectively reading the first output value and the second output value of the objective function corresponding to the first sampling point and the second sampling point.
[0065] The interpolation calculation module 705 calculates the output value of the objective function corresponding to the current input variable according to the interpolation formula based on the output value of the first objective function, the output value of the second objective function, the starting threshold, and the current sampling step.
[0066] In summary, a fast evaluation method and system for supporting any function according to an embodiment of the present invention, the method includes: configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals; dividing the value range of the input variable of the objective function into multiple segmentation intervals, where the number of the segmentation intervals is the number of preset segmentation intervals, determining the starting point of the input variable of each segmentation interval and the corresponding sampling step, and performing discrete sampling on the input variable within each segmentation interval based on the corresponding sampling step, calculating the output value of the objective function corresponding to each sampling point, and the output value of the objective function corresponding to the starting point of the input variable of each segmentation interval is the starting threshold; arranging each starting threshold and the output value of the objective function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and writing them into the lookup table memory in sequence, where the lookup table memory is a dual static random access memory or a register table memory; during the process of calling the objective function, determining the current segmentation interval and the corresponding current sampling step according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and respectively reading the first output value of the objective function and the second output value of the objective function corresponding to the first sampling point and the second sampling point; calculating the output value of the objective function corresponding to the current input variable according to the interpolation formula based on the first output value of the objective function, the second output value of the objective function, the starting threshold, and the current sampling step. By segmenting the value range of the input variable of the objective function in the present invention and using different sampling steps for different segmentation intervals, the overall calculation accuracy of the objective function is improved; Further, it supports dynamic configuration of the lookup table memory during the process of calling the objective function, that is, the starting point of the input variable of each segmentation interval and its corresponding sampling step can be adjusted in real time according to usage requirements, thereby significantly enhancing the compatibility and operation flexibility for multi-type objective function evaluation tasks, and is particularly suitable for complex application scenarios with adjustable precision and frequent changes of objective functions; Further, by setting different lookup table capacities and the number of segmentation intervals, and configuring the lookup table memory as a dual static random access memory or a register table memory, parallel reading of the output values of the objective function can be realized when the hardware resources are sufficient, thereby improving the overall lookup efficiency; under the condition of limited resources, linear sequential reading of the output values of the objective function is realized, reducing the hardware resource occupation while ensuring the evaluation accuracy of the objective function, thereby enhancing the adaptability and practicability of the present invention under various hardware platforms.
[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A fast evaluation method for supporting arbitrary functions, characterized in that Including: Configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals; Dividing the value range of the input variable of the objective function into multiple segmentation intervals, where the number of the segmentation intervals is the number of preset segmentation intervals, determining the starting point of the input variable and the corresponding sampling step size for each segmentation interval, and performing discrete sampling on the input variable within each segmentation interval based on the corresponding sampling step size, and calculating the output value of the objective function corresponding to each sampling point, and the output value of the objective function corresponding to the starting point of the input variable in each segmentation interval is the starting threshold; Arranging each starting threshold and the output value of the objective function corresponding to the sampling point in the order of the segmentation intervals and the index order of the sampling points, and writing them into the lookup table memory in sequence, where the lookup table memory is a dual static random access memory or a register table memory; During the process of calling the objective function, determining the current segmentation interval and the corresponding current sampling step size according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and respectively reading the first output value of the objective function and the second output value of the objective function corresponding to the first sampling point and the second sampling point; Based on the first output value of the objective function, the second output value of the objective function, the starting threshold, and the current sampling step size, calculating the output value of the objective function corresponding to the current input variable according to the interpolation formula.
2. The fast evaluation method for supporting arbitrary functions according to claim 1, wherein, The lookup table memory is used to establish the corresponding relationship between the starting point of each input variable and the starting threshold, and the corresponding relationship between each sampling point and the output value of the objective function.
3. The fast evaluation method for supporting arbitrary functions according to claim 1, wherein The dual static random access memory includes a first static random access memory and a second static random access memory, and is used to store the output values of the objective function corresponding to two adjacent sampling points in the same segmentation interval.
4. The fast evaluation method for supporting arbitrary functions according to claim 1, wherein The register table memory is used to arrange in the order of the segmentation intervals and the index order of the sampling points, and linearly store the starting threshold of each segmentation interval and the output value of the objective function corresponding to each sampling point.
5. The fast evaluation method for supporting arbitrary functions according to claim 1, characterized in that This method supports dynamic configuration of the lookup table memory during the process of calling the objective function, and the dynamic configuration includes: Keeping the starting point of the input variable and the sampling step size of each segmentation interval unchanged, and replacing the objective function; Keeping the objective function unchanged, and resetting the starting point of the input variable and its corresponding sampling step size for each segmentation interval; Simultaneously modifying the objective function, the starting point of the input variable of each segmentation interval, and its corresponding sampling step size.
6. The fast evaluation method for supporting arbitrary functions according to claim 1, characterized in that The interpolation formula is: Among them, output is the output value of the objective function, lut[n] is the output value of the first objective function, lut[n + 1] is the output value of the second objective function, step is the current sampling step size, and index is the address index of the output value of the objective function in the lookup table memory; The calculation formula of index is: Among them, input is the current input variable, th is the starting point of the input variable in the current segmentation interval, and input - th is the offset of the current input variable in the current segmentation interval.
7. The fast evaluation method for supporting arbitrary functions according to claim 1, characterized in that The upper limit of the lookup table capacity is 16, the number of preset segmentation intervals is 4, the lookup table memory is a dual static random access memory, and is used to parallelly read the first output value of the objective function and the second output value of the objective function of the current input variable in the current segmentation interval.
8. The fast evaluation method for supporting arbitrary functions according to claim 1, characterized in that The upper limit of the lookup table capacity is 8, the number of preset segmentation intervals is 2, the lookup table memory is a register table memory, and is used to sequentially read the first output value of the objective function and the second output value of the objective function of the current input variable in the current segmentation interval.
9. The rapid evaluation method for supporting arbitrary functions according to claim 1, wherein The upper limit of the lookup table capacity and the number of preset segmentation intervals are set in the initialization stage of the fast evaluation method, and remain unchanged during the execution of the fast evaluation method.
10. A fast evaluation system that supports arbitrary functions, characterized in that, It includes: A hardware parameter configuration module for configuring hardware parameters, where the hardware parameters include the upper limit of the lookup table capacity and the number of preset segmentation intervals; A target function sampling parameter determination module for dividing the value range of the input variables of the target function into multiple segmentation intervals, where the number of the segmentation intervals is the number of preset segmentation intervals, determining the starting point of the input variables and the corresponding sampling step length for each segmentation interval, and performing discrete sampling on the input variables based on the corresponding sampling step length within each segmentation interval, calculating the output value of the target function corresponding to each sampling point, and the output value of the target function corresponding to the starting point of the input variables in each segmentation interval is the starting threshold; A lookup table memory configuration module for arranging the output values of the target function corresponding to each starting threshold and sampling point in the order of the segmentation intervals and the index order of the sampling points, and sequentially writing them into the lookup table memory, where the lookup table memory is a dual static random access memory or a register table memory; A lookup value based on the lookup table memory module, during the process of calling the target function, determining the current segmentation interval and the corresponding current sampling step length according to the current input variable, looking up the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and respectively reading the first output value of the target function and the second output value of the target function corresponding to the first sampling point and the second sampling point; An interpolation calculation module for calculating the output value of the target function corresponding to the current input variable based on the first output value of the target function, the second output value of the target function, the starting threshold, and the current sampling step length according to the interpolation formula.
Citation Information
Patent Citations
Minimum gradient included angle pre-integration illumination method of self-adaptive sampling
CN103295259A
Sectional table look-up based arc-tangent function realization method and device
CN106227291A
Device and method of acquiring function value and neural network device
CN108205518A
Method for realizing function, graphic processing device, system and medium
CN113870090A
Parallel table look-up method and device supporting nonlinear function extension function
CN115328553A
Cited By
Activation function calculation circuit, method and system
CN121009930A
Activation function computation circuit, method and system
CN121009930B