A fast evaluation method and system for supporting arbitrary functions

By introducing segmented intervals and sampling step size settings into the hardware structure, and combining them with interpolation calculations, efficient and accurate evaluation of complex functions is achieved. This solves the problems of resource consumption and accuracy in the lookup table method, and enables flexible adaptation and efficient calculation of multiple types of objective functions.

CN120336684BActive Publication Date: 2025-12-26ZHONGZHI QIXIN (SHANGHAI) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510829883.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-20
Publication Date
2025-12-26
Estimated Expiration
2045-06-20

AI Technical Summary

Technical Problem

Existing lookup table methods have limitations in accuracy and adaptability when evaluating complex functions, making it difficult to meet the needs of applications requiring high flexibility and accuracy, and they also consume a lot of resources.

Method used

By introducing segmented interval setting, sampling step size setting, and interpolation calculation mechanism into the hardware structure, configuring the lookup table memory as dual static random access memory or register table memory, and dynamically configuring the segmented interval and sampling step size, the objective function can be evaluated efficiently and accurately.

Benefits of technology

It improves the accuracy and flexibility of evaluating complex functions, adapts to multiple types of objective functions, reduces hardware resource consumption, and enhances adaptability to different hardware platforms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336684B_ABST
    Figure CN120336684B_ABST
Patent Text Reader

Abstract

The application provides a fast evaluation method and system supporting an arbitrary function, and the method comprises the following steps: configuring hardware parameters, wherein the hardware parameters comprise an upper limit of a lookup table capacity and a preset number of segmented intervals; dividing input variable values into multiple segmented intervals, determining input variable starting points of each segmented interval and corresponding sampling steps, and discretely sampling the input variable to calculate corresponding target function output values, wherein the target function output value corresponding to the input variable starting point is a starting threshold value; writing each starting threshold value and the target function output value corresponding to the sampling point into a lookup table memory; in a target function calling process, finding a first sampling point and a second sampling point adjacent to the current input variable according to the current segmented interval and the current sampling step of the current input variable, and reading a first target function output value and a second target function output value; and calculating the target function output value corresponding to the current input variable according to an interpolation formula.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The embodiment of the present application relates to the chip processing technical field, in particular to a fast evaluation method and system supporting arbitrary functions. BACKGROUND

[0002] At present, the hardware method commonly used in the related chip of digital signal processing is divided into approximate calculation method and lookup table method. Among them, the approximate calculation method converts the complex function into a series of multiplication and addition operation through mathematical formula, so as to facilitate the hardware execution. The method has high implementation precision, but the calculation amount is large, and a large amount of hardware resources are occupied, and it is not suitable for all complex functions, which limits its actual application scene. In comparison, the lookup table method pre-stores the output value of the complex function in the internal memory in advance, and the hardware runs to obtain the complex function output value by taking the input variable as the address index. The lookup table method has the advantages of low calculation amount and low resource occupation. However, the existing lookup table method still has obvious limitations in value searching precision and adaptability, and it is difficult to flexibly adjust the segmentation strategy and sampling precision according to the complexity of the complex function, and it is difficult to meet the application scene with high requirements for complex function evaluation precision and flexibility. SUMMARY

[0003] The present application provides a fast evaluation method and system supporting arbitrary functions, which introduces the segmentation interval setting, sampling step setting and interpolation calculation mechanism in the hardware structure, and realizes the efficient and accurate evaluation of the complex function under the condition of limited resources.

[0004] The embodiment of the present application provides a fast evaluation method supporting arbitrary functions, comprising:

[0005] Configuring hardware parameters, the hardware parameters including lookup table capacity upper limit and preset segmentation interval number;

[0006] Dividing the input variable value of the target function into a plurality of segmentation intervals, the number of segmentation intervals being the preset segmentation interval number, determining the input variable starting point of each segmentation interval and the corresponding sampling step, and discretely sampling the input variable in each segmentation interval based on the corresponding sampling step, calculating the target function output value corresponding to each sampling point, and the target function output value corresponding to the input variable starting point of each segmentation interval being the starting threshold value;

[0007] Arranging each starting threshold value and the target function output value corresponding to the sampling point according to the order of the segmentation interval and the index order of the sampling point, and sequentially writing into the lookup table memory, the lookup table memory being a dual static random access memory or a register table memory;

[0008] In the process of calling the target function, the current segment interval and the corresponding current sampling step are determined according to the current input variable, the first sampling point and the second sampling point adjacent to the current input variable in the current segment interval are searched from the lookup table memory, and the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively.

[0009] Based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step, the target function output value corresponding to the current input variable is calculated according to an interpolation formula.

[0010] Preferably, the lookup table memory is used to establish the corresponding relationship between each input variable starting point and the starting threshold value, and the corresponding relationship between each sampling point and the target function output value.

[0011] Preferably, the dual static random access memory includes a first static random access memory and a second static random access memory, which are used to store the target function output values corresponding to two adjacent sampling points in the same segment interval.

[0012] Preferably, the register table memory is arranged in the order of the segment intervals and the index order of the sampling points, and linearly stores the starting threshold value of each segment interval and the target function output value corresponding to each sampling point.

[0013] Preferably, the method supports dynamic configuration of the lookup table memory in the process of calling the target function, and the dynamic configuration includes:

[0014] Keeping the input variable starting point and the sampling step of each segment interval unchanged, the target function is replaced;

[0015] Keeping the target function unchanged, the input variable starting point of each segment interval and the corresponding sampling step are reset;

[0016] The target function, the input variable starting point of each segment interval and the corresponding sampling step are modified simultaneously.

[0017] Preferably, the interpolation formula is:

[0018]

[0019] Wherein, output is the target function output value, lut[n] is the first target function output value, lut[n+1] is the second target function output value, step is the current sampling step, and index is the address index of the target function output value in the lookup table memory.

[0020] The calculation formula of index is:

[0021]

[0022] Wherein, input is the current input variable, th is the input variable starting point of the current segment interval, input-th is the offset of the current input variable in the current segment interval.

[0023] Preferably, the upper limit of the lookup table capacity is 16, the preset number of segment intervals is 4, and the lookup table memory is a dual static random access memory for reading the first target function output value and the second target function output value of the current input variable in the current segment interval in parallel.

[0024] Preferably, the upper limit of the lookup table capacity is 8, the preset number of segment intervals is 2, and the lookup table memory is a register table memory for sequentially reading the first target function output value and the second target function output value of the current input variable in the current segment interval.

[0025] Preferably, the upper limit of the lookup table capacity and the preset number of segment intervals are set in the initialization stage of the fast evaluation method, and remain unchanged in the execution process of the fast evaluation method.

[0026] The embodiment of the application also provides a fast evaluation system supporting an arbitrary function, comprising:

[0027] The hardware parameter configuration module configures hardware parameters, and the hardware parameters include an upper limit of a lookup table capacity and a preset number of segment intervals.

[0028] The target function sampling parameter determination module divides the input variable value of the target function into a plurality of segment intervals, the number of the segment intervals is the preset number of segment intervals, determines the input variable starting point of each segment interval and the corresponding sampling step, and performs discrete sampling on the input variable in each segment interval based on the corresponding sampling step, calculates the target function output value corresponding to each sampling point, and the target function output value corresponding to the input variable starting point of each segment interval is a starting threshold value.

[0029] The lookup table memory configuration module arranges each starting threshold value and the target function output value corresponding to the sampling point according to the order of the segment intervals and the index order of the sampling points, and sequentially writes into the lookup table memory, and the lookup table memory is a dual static random access memory or a register table memory.

[0030] The value lookup module based on a lookup table memory, in the process of calling the target function, according to the current input variable, the current segmented interval and the corresponding current sampling step are determined, the first sampling point and the second sampling point adjacent to the current input variable in the current segmented interval are looked up from the lookup table memory, and the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively;

[0031] The interpolation calculation module calculates the target function output value corresponding to the current input variable according to an interpolation formula based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step.

[0032] Compared with the prior art, the technical scheme of the embodiment of the present application has the following beneficial effects:

[0033] The method comprises the following steps: configuring hardware parameters, wherein the hardware parameters comprise a lookup table capacity upper limit and a preset number of segmented intervals; dividing the input variable value of the target function into a plurality of segmented intervals, wherein the number of the segmented intervals is the preset number of segmented intervals, the input variable starting point of each segmented interval and the corresponding sampling step are determined, and the input variable is discretely sampled in each segmented interval based on the corresponding sampling step, the target function output value corresponding to each sampling point is calculated, and the target function output value corresponding to the input variable starting point of each segmented interval is a starting threshold value; arranging each starting threshold value and the target function output value corresponding to the sampling point in the order of the segmented intervals and the index order of the sampling points, and sequentially writing into a lookup table memory, wherein the lookup table memory is a dual static random access memory or a register table memory; in the process of calling the target function, the current segmented interval and the corresponding current sampling step are determined according to the current input variable, the first sampling point and the second sampling point adjacent to the current input variable in the current segmented interval are looked up from the lookup table memory, the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively, and the target function output value corresponding to the current input variable is calculated according to an interpolation formula based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step. The input variable value of the target function is segmented, different sampling steps are used in different segmented intervals, and the overall calculation accuracy of the target function is improved;

[0034] Further, the lookup table memory is dynamically configured in the process of calling the target function, that is, the input variable starting point of each segmented interval and the corresponding sampling step can be adjusted in real time according to the use demand, thereby significantly improving the compatibility and running flexibility of the evaluation task of multiple types of target functions, and the method is especially suitable for complex application scenarios with adjustable accuracy and frequent changes of target functions.

[0035] Further, by setting different lookup table capacities and segment interval numbers, and configuring the lookup table memory as a dual static random access memory or a register table memory, parallel reading of the target function output value is realized under the condition that hardware resources are sufficient, the overall lookup value efficiency is improved, linear sequential reading of the target function output value is realized under the condition that resources are limited, the hardware resource occupation is reduced while the target function evaluation accuracy is ensured, and therefore the adaptability and practicability of the application under various hardware platforms are enhanced.

[0036] Further, in the field of artificial intelligence accelerators, the activation functions of different artificial intelligence algorithms are different, and various activation functions will appear as the iteration of the artificial intelligence algorithm. At this time, the application can realize different activation functions on the same hardware platform, and when the transformation function is modified, the accuracy of the function implementation can be optimized according to the characteristics of the function. BRIEF DESCRIPTION OF DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, not all embodiments. For those skilled in the art, other drawings can also be obtained without creative labor.

[0038] Figure 1 The flowchart of the fast evaluation method of the arbitrary function provided by an embodiment of the present application is shown;

[0039] Figure 2 The corresponding relationship diagram of the target function segment interval and the sampling point provided by an embodiment of the present application is shown;

[0040] Figure 3 The storage structure diagram of the lookup table memory provided by an embodiment of the present application is shown;

[0041] Figure 4 The flowchart of the fast evaluation method of the arbitrary function provided by another embodiment of the present application is shown;

[0042] Figure 5 The corresponding relationship diagram of the target function segment interval and the sampling point provided by another embodiment of the present application is shown;

[0043] Figure 6 The storage structure diagram of the lookup table memory provided by another embodiment of the present application is shown;

[0044] Figure 7A module schematic diagram of a fast evaluation system supporting an arbitrary function is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0045] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in connection with the drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0046] The technical solutions of the present application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in some embodiments.

[0047] In the field of artificial intelligence accelerators, different artificial intelligence algorithms have different activation functions, and various activation functions will appear as the iteration of artificial intelligence algorithms. 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.

[0048] Based on the problems in the prior art, the present application provides a fast evaluation method and system supporting an arbitrary function, which introduces a segmented interval setting, a sampling step setting and an interpolation calculation mechanism in a hardware structure to efficiently and accurately evaluate a complex function under resource constraints.

[0049] Embodiment 1 Figure 1 A flowchart of a fast evaluation method supporting an arbitrary function is provided for an embodiment of the present application. Now referring to Figure 1 The present application provides a fast evaluation method supporting an arbitrary function, which comprises the following steps:

[0050] Step S101: configuring hardware parameters, wherein the hardware parameters comprise a lookup table capacity upper limit and a preset number of segmented intervals, the lookup table capacity upper limit is 16, and the preset number of segmented intervals is 4.

[0051] In the present embodiment, the lookup table capacity upper limit and the preset number of segmented intervals are set in the initialization stage of the fast evaluation method, and remain unchanged in the execution process of the fast evaluation method.

[0052] Step S102: divide the input variable value of the objective function into a plurality of segmented intervals, the number of the segmented intervals being a preset segmented interval number, determine an input variable starting point of each of the segmented intervals and a corresponding sampling step, and perform discrete sampling on the input variable in each of the segmented intervals based on the corresponding sampling step, and calculate an output value of the objective function corresponding to each sampling point, the output value of the objective function corresponding to the input variable starting point of each of the segmented intervals being a starting threshold value.

[0053] Step S103: arrange each of the starting threshold values and the output values of the objective function corresponding to the sampling points in the order of the segmented intervals and the index order of the sampling points, and sequentially write into a lookup table memory, the lookup table memory being a dual static random access memory.

[0054] In the embodiment, the dual static random access memory includes a first static random access memory SRAM0 and a second static random access memory SRAM1.

[0055] Step S104: in the process of calling the objective function, determine a current segmented interval and a corresponding current sampling step according to a current input variable, find a first sampling point and a second sampling point adjacent to the current input variable in the current segmented interval from the lookup table memory, and read a first output value of the objective function corresponding to the first sampling point and a second output value of the objective function corresponding to the second sampling point.

[0056] In the embodiment, the method supports dynamic configuration of the lookup table memory in the process of calling the objective function, and the dynamic configuration includes:

[0057] keeping the input variable starting point and the sampling step of each of the segmented intervals unchanged, and replacing the objective function to support fast evaluation of different objective functions.

[0058] keeping the objective function unchanged, and resetting the input variable starting point of each of the segmented intervals and the corresponding sampling step to realize calculation of different precisions for the same objective function.

[0059] simultaneously modifying the objective function, the input variable starting point of each of the segmented intervals and the corresponding sampling step to adapt to the lookup value requirement of different objective functions under different precisions.

[0060] Step S105: based on the first output value of the objective function, the second output value of the objective function, the starting threshold value and the current sampling step, calculate an output value of the objective function corresponding to the current input variable according to an interpolation formula.

[0061] The interpolation formula is:

[0062]

[0063] Wherein, 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, index is the address index of the target function output value in the lookup table memory.

[0064] In the embodiment, the upper limit of the lookup table capacity is 16, and the index is a 4-bit address index.

[0065] The calculation formula of the index is as follows:

[0066]

[0067] Wherein, input is the current input variable, th is the input variable starting point of the current segment interval, and input-th is the offset of the current input variable in the current segment interval.

[0068] Figure 2 The corresponding relationship between the target function segment interval and the sampling point provided by an embodiment of the present application is shown in the following figure. Figure 2 The corresponding relationship between the target function segment interval and the sampling point provided by an embodiment of the present application includes:

[0069] In the embodiment, the target function is f(x), the input variable of the target function is x, the upper limit of the lookup table capacity is 16, i.e., the target function output value that can be stored in the lookup table memory is 16, the number of segment intervals is 4, i.e., the input variable x of the target function is divided into four segment intervals, which are segment interval 0, segment interval 1, segment interval 2 and segment interval 3, and the corresponding sampling steps are sampling step 0, sampling step 1, sampling step 2 and sampling step 3, respectively. In each segment interval, the input variable x is discretely sampled based on the corresponding sampling step, and the target function output value corresponding to each sampling point is calculated.

[0070] Wherein, the target function output value corresponding to the input variable starting point of the segment interval 0 is the starting threshold 0, the target function output value corresponding to the input variable starting point of the segment interval 1 is the starting threshold 1, the target function output value corresponding to the input variable starting point of the segment interval 2 is the starting threshold 2, and the target function output value corresponding to the input variable starting point of the segment interval 3 is the starting threshold 3.

[0071] Figure 3 The storage structure of the lookup table memory provided by an embodiment of the present application is shown in the following figure. Figure 3 The storage structure of the lookup table memory provided by an embodiment of the present application includes:

[0072] In the embodiment, the lookup table memory is used to establish the correspondence between the starting point of each input variable and the starting threshold value, and the correspondence between each sampling point and the target function output value.

[0073] The dual static random access memory includes a first static random access memory SRAM0 and a second static random access memory SRAM1, which are used to store the target function output values of two adjacent sampling points th i,n and th i,n+1 in the same segment interval. i [n] and lut i [n+1].

[0074] In the target function calling process, the dual static random access memory is used to read the first target function output value and the second target function output value of the current input variable in the current segment interval in parallel. The hardware can read two target function output values in one clock cycle, so that the target function lookup value efficiency and the overall calculation speed are improved.

[0075] Embodiment 2: Figure 4 The flowchart of the fast evaluation method of an arbitrary function provided by another embodiment of the application is shown. Now referring to Figure 4 , the fast evaluation method of an arbitrary function provided by the embodiment of the application includes the following steps.

[0076] Step S201: Configure hardware parameters, the hardware parameters including a lookup table capacity upper limit and a preset segment interval number, the lookup table capacity upper limit being 8, and the preset segment interval number being 2.

[0077] In the embodiment, the lookup table capacity upper limit and the preset segment interval number are set in the initialization stage of the fast evaluation method, and remain unchanged in the execution process of the fast evaluation method.

[0078] Step S202: Divide the input variable value of the target function into a plurality of segment intervals, the number of the segment intervals being the preset segment interval number, determine the input variable starting point and the corresponding sampling step of each segment interval, and perform discrete sampling on the input variable in each segment interval based on the corresponding sampling step, calculate the target function output value corresponding to each sampling point, and the target function output value corresponding to the input variable starting point of each segment interval is the starting threshold value.

[0079] Step S203: Arrange each starting threshold value and the target function output value corresponding to the sampling point in the order of the segment intervals and the index order of the sampling points, and write them into the lookup table memory in sequence, the lookup table memory being a register table memory.

[0080] Step S204: In the process of the target function calling, the current segment interval and the corresponding current sampling step are determined according to the current input variable, the first sampling point and the second sampling point adjacent to the current input variable in the current segment interval are searched from the lookup table memory, and the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively.

[0081] In the embodiment, the method supports dynamic configuration of the lookup table memory in the process of the target function calling, and the dynamic configuration includes:

[0082] The input variable starting point and the sampling step of each segment interval are kept unchanged, and the target function is replaced to support fast evaluation of different target functions.

[0083] The target function is kept unchanged, and the input variable starting point and the corresponding sampling step of each segment interval are reset to realize calculation of different precisions for the same target function.

[0084] The target function, the input variable starting point and the corresponding sampling step of each segment interval are modified simultaneously to adapt to the lookup value requirements of different target functions under different precisions.

[0085] Step S205: Based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step, the target function output value corresponding to the current input variable is calculated according to an interpolation formula.

[0086] The interpolation formula is:

[0087]

[0088] Wherein, output is the target function output value, lut[n] and lut[n+1] are the first target function output value and the second target function output value read from the register table memory in sequence, step is the current sampling step, and index is the address index of the target function output value in the lookup table memory.

[0089] The calculation formula of index is:

[0090]

[0091] Wherein, input is the current input variable, th is the input variable starting point of the current segment interval, and input-th is the offset of the current input variable in the current segment interval.

[0092] Figure 5 The corresponding relationship diagram of the target function segment interval and the sampling point is provided for another embodiment of the present application. Now referring to Figure 5The corresponding relationship between the target function segmentation interval and the sampling point provided by the embodiment of the present application comprises:

[0093] In the embodiment, the target function is f(x), the input variable of the target function is x, the upper limit of the lookup table capacity is 8, that is, the lookup table memory can store 8 target function output values, the number of segmentation intervals is 2, that is, the input variable x of the target function is divided into two segmentation intervals, namely, segmentation interval 0 and segmentation interval 1, the corresponding sampling step lengths are sampling step length 0 and sampling step length 1 respectively, and the input variable x is discretely sampled in each segmentation interval based on the corresponding sampling step length, and the target function output value corresponding to each sampling point is calculated.

[0094] The target function output value corresponding to the input variable starting point of the segmentation interval 0 is the starting threshold 0, and the target function output value corresponding to the input variable starting point of the segmentation interval 1 is the starting threshold 1.

[0095] Figure 6 The storage structure diagram of the lookup table memory provided by another embodiment of the present application is shown in the figure. Figure 6 The storage structure of the lookup table memory provided by the embodiment of the present application comprises:

[0096] In the embodiment, the lookup table memory is used to establish the corresponding relationship between each input variable starting point and the starting threshold, and the corresponding relationship between each sampling point and the target function output value.

[0097] The register table memory is arranged in the order of the segmentation intervals and the index order of the sampling points, and linearly stores the starting threshold of each segmentation interval and the target function output value corresponding to each sampling point.

[0098] In the target function calling process, the register table memory is used to sequentially read the first target function output value and the second target function output value of the current input variable in the current segmentation interval. Thus, the sequential access of two target function output values can be completed in two clock cycles, the hardware resources are saved while the calculation accuracy is ensured, and the method is suitable for the hardware resource limited scene.

[0099] Figure 7 The module diagram of the fast evaluation system supporting an arbitrary function provided by an embodiment of the present application is shown in the figure. Figure 7 The embodiment of the present application provides a fast evaluation system 700 supporting an arbitrary function, which comprises:

[0100] The configuration hardware parameter module 701 is configured to configure hardware parameters, and the hardware parameters comprise the upper limit of the lookup table capacity and the preset number of segmentation intervals.

[0101] The determining target function sampling parameter module 702 divides the input variable value of the target function into a plurality of segmented intervals, the number of the segmented intervals is a preset segmented interval number, determines an input variable starting point of each segmented interval and a corresponding sampling step, and performs discrete sampling on the input variable in each segmented interval based on the corresponding sampling step, calculates a target function output value corresponding to each sampling point, and the target function output value corresponding to the input variable starting point of each segmented interval is a starting threshold value.

[0102] The configuration lookup table memory module 703 arranges each starting threshold value and target function output value corresponding to the sampling point in the order of the segmented intervals and the index order of the sampling points, and sequentially writes into the lookup table memory, and the lookup table memory is a dual static random access memory or a register table memory.

[0103] The lookup table memory value based module 704, in the target function calling process, determines a current segmented interval and a corresponding current sampling step according to a current input variable, finds a first sampling point and a second sampling point adjacent to the current input variable in the current segmented interval from the lookup table memory, and reads a first target function output value and a second target function output value corresponding to the first sampling point and the second sampling point respectively.

[0104] The interpolation calculation module 705 calculates the target function output value corresponding to the current input variable according to the interpolation formula based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step.

[0105] To sum up, the embodiment of the application provides a fast evaluation method and system of an arbitrary function, which comprises the following steps: configuring hardware parameters, wherein the hardware parameters comprise an upper limit of a lookup table capacity and a preset number of segmented intervals; dividing input variable values of a target function into a plurality of segmented intervals, wherein the number of the segmented intervals is the preset number of segmented intervals, the input variable starting point of each segmented interval is determined, and corresponding sampling steps are determined, and input variables are discretely sampled in each segmented interval based on the corresponding sampling steps, and the output value of the target function corresponding to each sampling point is calculated, and the output value of the target function corresponding to the input variable starting point of each segmented interval is a starting threshold value; arranging each starting threshold value and the output value of the target function corresponding to each sampling point in the order of the segmented intervals and the index order of the sampling points, and sequentially writing into a lookup table memory, wherein the lookup table memory is a dual static random access memory or a register table memory; in the process of calling the target function, the current segmented interval and the corresponding current sampling step are determined according to the current input variable, the first sampling point and the second sampling point adjacent to the current input variable in the current segmented interval are found in the lookup table memory, and the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively; and the output value of the target function corresponding to the current input variable is calculated according to an interpolation formula based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step. The input variable values of the target function are segmented, different sampling steps are used in different segmented intervals, and the overall calculation accuracy of the target function is improved.

[0106] Further, the lookup table memory can be dynamically configured in the process of calling the target function, that is, the input variable starting point of each segmented interval and the corresponding sampling step can be adjusted in real time according to the use demand, so that the compatibility and running flexibility of the evaluation task of the target function of multiple types are significantly improved, and the application scenario is particularly suitable for complex application scenarios with adjustable accuracy and frequent changes of the target function.

[0107] Further, by setting different lookup table capacities and the number of segmented intervals, and configuring the lookup table memory as a dual static random access memory or a register table memory, parallel reading of the output value of the target function is realized under the condition that the hardware resources are sufficient, the overall lookup value efficiency is improved, linear sequential reading of the output value of the target function is realized under the condition that the resources are limited, the occupation of the hardware resources is reduced, and the evaluation accuracy of the target function is ensured, so that the adaptability and practicality of the application in multiple hardware platforms are enhanced.

[0108] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions recorded in the above embodiments can be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A fast evaluation method for supporting arbitrary functions, characterized in that, The application relates to a method for configuring a lookup table for a target function, comprising the following steps: configuring hardware parameters, wherein the hardware parameters comprise an upper limit of lookup table capacity and a preset number of segmentation intervals; dividing the value range of the input variable of the target function into a plurality of segmentation intervals, wherein the number of the segmentation intervals is the preset number of segmentation intervals, the input variable starting point of each segmentation interval and the corresponding sampling step are determined, the input variable is discretely sampled in each segmentation interval based on the corresponding sampling step, the output value of the target function corresponding to each sampling point is calculated, and the output value of the target function corresponding to the input variable starting point of each segmentation interval is a starting threshold value; arranging the starting threshold value of each segmentation interval and the output value of the target function corresponding to each sampling point according to the order of the segmentation intervals and the index order of the sampling points, and sequentially writing the starting threshold value and the output value of the target function into a lookup table memory, wherein the lookup table memory is used to establish the corresponding relationship between the input variable starting point and the starting threshold value, and the corresponding relationship between each sampling point and the output value of the target function, the lookup table memory is a dual static random access memory or a register table memory, the dual static random access memory comprises a first static random access memory and a second static random access memory, and is used to store the output values of the target function corresponding to two adjacent sampling points in the same segmentation interval, the register table memory is used to arrange the starting threshold value of each segmentation interval and the output value of the target function corresponding to each sampling point according to the order of the segmentation intervals and the index order of the sampling points, and linearly store the starting threshold value and the output value of the target function; in the target function calling process, the current segmentation interval and the corresponding current sampling step are determined according to the current input variable, the first sampling point and the second sampling point adjacent to the current input variable in the current segmentation interval are found in the lookup table memory, and the first target function output value and the second target function output value corresponding to the first sampling point and the second sampling point are read respectively; the lookup table memory is dynamically configured in the target function calling process, and the dynamic configuration comprises: keeping the input variable starting point and the sampling step of each segmentation interval unchanged, and replacing the target function; keeping the target function unchanged, and resetting the input variable starting point of each segmentation interval and the corresponding sampling step; simultaneously modifying the target function, the input variable starting point of each segmentation interval and the corresponding sampling step; based on the first target function output value, the second target function output value, the starting threshold value and the current sampling step, the output value of the target function corresponding to the current input variable is calculated according to an interpolation formula; the interpolation formula is: wherein output is the target function output value, lut[n] is the first target function output value, lut[n+1] is the second target function output value, step is the current sampling step, and index is the address index of the target function output value in the lookup table memory. the calculation formula of the index is: wherein input is the current input variable, th is the start point of the input variable of the current segment interval, and input-th is the offset of the current input variable in the current segment interval.

2. The fast evaluation method of arbitrary functions according to claim 1, wherein, the upper limit of the lookup table capacity is 16, the preset number of segmentation intervals is 4, and the lookup table memory is a dual static random access memory, which is used to read the first target function output value and the second target function output value of the current input variable in the current segmentation interval in parallel.

3. The fast evaluation method of arbitrary functions according to claim 1, wherein, the upper limit of the lookup table capacity is 8, the preset number of segmentation intervals is 2, and the lookup table memory is a register table memory, which is used to sequentially read the first target function output value and the second target function output value of the current input variable in the current segmentation interval.

4. The fast evaluation method of arbitrary functions according to claim 1, wherein, The upper limit of the lookup table capacity and the preset number of segmentation intervals are set in an initialization stage of the fast evaluation method, and remain unchanged during execution of the fast evaluation method.

5. A fast evaluation system for supporting arbitrary functions, characterized by, The method comprises the following steps: A configuration hardware parameter module is configured to configure hardware parameters, wherein the hardware parameters include an upper limit of a lookup table capacity and a preset number of segmentation intervals. A determination target function sampling parameter module is configured to divide input variable values of a target function into a plurality of segmentation intervals, wherein the number of the segmentation intervals is the preset number of segmentation intervals, determine an input variable starting point of each segmentation interval and a corresponding sampling step, and perform discrete sampling on the input variable in each segmentation interval based on the corresponding sampling step, calculate a target function output value corresponding to each sampling point, and the target function output value corresponding to the input variable starting point of each segmentation interval is a starting threshold value. A configuration lookup table memory module is configured to arrange each starting threshold value and target function output value corresponding to a sampling point in order of the segmentation intervals and an index order of the sampling points, and sequentially write the starting threshold value and the target function output value into a lookup table memory, wherein the lookup table memory is configured to establish a corresponding relationship between each input variable starting point and a starting threshold value, and a corresponding relationship between each sampling point and a target function output value, the lookup table memory is a dual static random access memory or a register table memory, the dual static random access memory includes a first static random access memory and a second static random access memory, and is configured to store target function output values corresponding to adjacent two sampling points in a same segmentation interval, and the register table memory is configured to arrange the starting threshold value and the target function output value corresponding to each sampling point in a linear manner according to the order of the segmentation intervals and the index order of the sampling points. A lookup table memory value-based searching module is configured to, in a target function calling process, determine a current segmentation interval and a corresponding current sampling step according to a current input variable, search for a first sampling point and a second sampling point adjacent to the current input variable in the current segmentation interval from the lookup table memory, and read first and second target function output values corresponding to the first and second sampling points, respectively. The lookup table memory is also dynamically configured in the target function calling process, and the dynamic configuration includes the following steps: The input variable starting point and the sampling step of each segmentation interval remain unchanged, and the target function is replaced; The target function remains unchanged, and the input variable starting point of each segmentation interval and the corresponding sampling step are reset; The target function, the input variable starting point of each segmentation interval and the corresponding sampling step are simultaneously modified; An interpolation calculation module is configured to calculate a target function output value corresponding to the current input variable according to an interpolation formula based on the first and second target function output values, the starting threshold value and the current sampling step. The interpolation formula is as follows: wherein output is the target function output value, lut[n] is the first target function output value, lut[n+1] is the second target function output value, step is the current sampling step, and index is the address index of the target function output value in the lookup table memory. The calculation formula of the index is as follows: wherein input is the current input variable, th is the start point of the input variable of the current segment interval, and input-th is the offset of the current input variable in the current segment interval.

Citation Information

Patent Citations

  • Method for realizing function, graphic processing device, system and medium

    CN113870090A