Transcendental function processing method and device, equipment and storage medium

By preprocessing and segmenting the independent variable data, the lookup table offset address and polynomial input data are generated, and the results of transcendent functions are determined directly by using the lookup table and polynomial calculation, which solves the problems of large hardware resource consumption and low computing efficiency in the prior art, and realizes efficient and low resource transcendent functions calculation.

CN119690380APending Publication Date: 2025-03-25TAICHU (HANGZHOU) INTEGRATED CIRCUIT CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411749484.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

Existing methods beyond function calculation consume a large amount of hardware resources and are inefficient in computing. Especially when high-precision calculations are required, Taylor series expansion and CORDIC algorithms will increase hardware resource requirements and computational complexity.

Method used

By preprocessing and segmenting the independent variable data, the lookup table offset address and polynomial input data are generated, and the calculation results beyond the function are directly determined using lookup table and polynomial calculations to avoid iterative calculations.

Benefits of technology

It significantly reduces the consumption of hardware resources, improves the efficiency and accuracy of transcendent function processing, and is suitable for transcendent function calculations of different types and scales.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690380A_ABST
    Figure CN119690380A_ABST
Patent Text Reader

Abstract

The invention discloses a transcendental function processing method and device, equipment and a storage medium. Obtaining a target transcendental function, and preprocessing independent variable data of the target transcendental function to generate processed data; segmenting the processed data to generate a lookup table offset address and polynomial input data; and determining a polynomial coefficient according to the lookup table offset address, and determining a calculation result of the target transcendental function according to the polynomial coefficient and the polynomial input data. Through preprocessing and segmentation processing of independent variable data, a lookup table offset address and polynomial input data can be rapidly generated, the obtaining of a transcendental function calculation result does not need iteration, the complex calculation process is reduced, and the calculation speed and the calculation efficiency of the target transcendental function are remarkably improved. And the calculation of the transcendental function is converted into the lookup table and polynomial calculation, so that the calculation complexity is simplified, and the consumption of hardware resources can be reduced to the greatest extent. The method can adapt to calculation of target transcendental functions of different types and scales.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a transcendental function processing method, device, equipment and storage medium. Background Art

[0002] In the field of artificial intelligence, transcendental function acceleration components play an important role. They can support activation function calculations in deep learning models, improve computing efficiency and accuracy, and combine with other functions to build more complex mathematical models and algorithms.

[0003] At present, the technical implementation of transcendental functions mainly includes the following two methods: one is to perform approximate calculations by using Taylor series expansion. In this technology, the Taylor technology is used to expand the relevant transcendental function, and multiple multiplication and addition iterations are performed until the accuracy meets the requirements; the other is to use the CORDIC algorithm for approximate calculations, and the calculation results of the transcendental function are obtained through coordinate rotation and iterative calculations.

[0004] The higher the accuracy requirement of the calculation result of the first method, the higher the order of the Taylor series that needs to be calculated. Taking the calculation of a transcendental function using an N-order Taylor series as an example, at least N-1 accumulator units, N multiplier units, and an N+1 input adder unit are required in this process, which will undoubtedly consume a lot of hardware resources. In addition, after multiple multiplication operations, the increase in data bit width leads to a longer calculation cycle, which limits the calculation efficiency. In order to achieve higher accuracy, the CORDIC algorithm of the second method needs to go through multiple iterative calculations, which will increase the calculation time and complexity. On the other hand, when calculating transcendental functions of non-trigonometric functions, this implementation involves more calculation steps and more complex iterative processes, resulting in an increase in hardware resources. Summary of the invention

[0005] The present invention provides a transcendental function processing method, device, equipment and storage medium, which can reduce the consumption of hardware resources to the maximum extent and improve the transcendental function processing efficiency.

[0006] According to one aspect of the present invention, a transcendental function processing method is provided, the method comprising:

[0007] Obtaining a target transcendental function, and preprocessing independent variable data of the target transcendental function to generate processed data;

[0008] performing segmentation processing on the processed data to generate a lookup table offset address and polynomial input data;

[0009] The polynomial coefficients are determined according to the offset address of the lookup table, and the calculation result of the target transcendental function is determined according to the polynomial coefficients and the polynomial input data.

[0010] Optionally, the independent variable data of the target transcendental function is preprocessed to generate processed data, including: determining the target function type corresponding to the target transcendental function, and determining the target floating-point input format of the independent variable data; obtaining a preset special value processing table, wherein the special value processing includes output special values ​​corresponding to each function type and each floating-point input format; matching the target function type and the target floating-point input format through the preset special value processing table to determine the target output special value; and scaling the target output special value to generate processed data.

[0011] Optionally, the target output special value is scaled to generate processing data, including: obtaining a preset convergence interval value table, wherein the convergence interval value table includes convergence intervals corresponding to each function type; matching the target function type through the convergence interval value table to obtain a target convergence interval corresponding to the target function type; and scaling the target output special value based on the target convergence interval to generate processing data.

[0012] Optionally, segmenting the processed data to generate a lookup table offset address and polynomial input data includes: using a first designated bit data of the processed data as the lookup table offset address; and using a second designated bit data of the processed data as the polynomial input data.

[0013] Optionally, determining the polynomial coefficients according to the lookup table offset address includes: obtaining a preset base address list, wherein the base address list includes the lookup table base addresses corresponding to each function type; matching the target function type through the base address list to obtain the target lookup table base address corresponding to the target function type; calling the target lookup table according to the target lookup table base address; and determining the polynomial coefficients from the target lookup table based on the lookup table offset address.

[0014] Optionally, the calculation result of the target transcendental function is determined based on the polynomial coefficients and the polynomial input data, including: substituting the polynomial coefficients and the polynomial input data into a preset calculation path formula to obtain the polynomial calculation result; scaling and restoring the polynomial calculation result based on the target convergence interval to determine the calculation result of the target transcendental function.

[0015] Optionally, after determining the calculation result of the target transcendental function based on the polynomial coefficients and the polynomial input data, the method also includes: determining a target rounding mode, wherein the target rounding mode includes rounding to the nearest, rounding to 0, rounding up, and rounding down; and normalizing the calculation result according to the target rounding mode.

[0016] According to another aspect of the present invention, there is provided a transcendental function processing device, the device comprising:

[0017] A data preprocessing module, used for obtaining a target transcendental function, and preprocessing the independent variable data of the target transcendental function to generate processed data;

[0018] A data segmentation module, used for segmenting the processed data to generate a lookup table offset address and polynomial input data;

[0019] The transcendental function calculation module is used to determine the polynomial coefficients according to the offset address of the lookup table, and determine the calculation result of the target transcendental function according to the polynomial coefficients and polynomial input data.

[0020] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0021] at least one processor;

[0022] and a memory communicatively coupled to the at least one processor;

[0023] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a transcendental function processing method described in any embodiment of the present invention.

[0024] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a transcendental function processing method described in any embodiment of the present invention when executed.

[0025] The technical solution of the embodiment of the present invention can quickly generate the lookup table offset address and polynomial input data by preprocessing and segmenting the independent variable data. The acquisition of the transcendental function calculation result does not require iteration, which reduces the complex calculation process and significantly improves the calculation speed and efficiency of the target transcendental function. The calculation of the transcendental function is converted into a lookup table and polynomial calculation, which simplifies the complexity of the calculation and can minimize the consumption of hardware resources. It can adapt to the calculation of target transcendental functions of different types and scales.

[0026] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0028] Figure 1 is a flow chart of a transcendental function processing method provided according to Embodiment 1 of the present invention;

[0029] Figure 2 is a schematic diagram of a polynomial calculation path provided according to Embodiment 1 of the present invention;

[0030] Figure 3 is a flow chart of another transcendental function processing method provided according to the second embodiment of the present invention;

[0031] Figure 4 is a schematic diagram of the structure of a transcendental function processing device provided according to Embodiment 3 of the present invention;

[0032] Figure 5 It is a structural schematic diagram of an electronic device for implementing a transcendental function processing method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0035] Embodiment 1

[0036] Figure 1 A flowchart of a transcendental function processing method is provided for the first embodiment of the present invention. This embodiment is applicable to the scenario of processing transcendental functions. The method can be executed by a transcendental function processing device. The transcendental function processing device can be implemented in the form of hardware and / or software. The transcendental function processing device can be configured in a computer controller. Figure 1 As shown, the method includes:

[0037] S110, obtaining a target transcendental function, and preprocessing the independent variable data of the target transcendental function to generate processed data.

[0038] Among them, transcendental function refers to a function whose relationship between variables cannot be expressed by a finite number of addition, subtraction, multiplication, division, exponentiation, and square root operations. For example, exponential functions, logarithmic functions, trigonometric functions, etc. are all transcendental functions. In a specific calculation or problem situation, the specific transcendental function of interest is the target transcendental function. For example, in an engineering calculation, the sine function may be used as the target transcendental function for subsequent processing. Independent variable data refers to the specific values ​​corresponding to the input variables in the target transcendental function.

[0039] Specifically, the preprocessing mainly includes determining whether the input value needs special processing according to the floating-point input format and the properties of the objective function, and scaling the input independent variable to a convergence interval according to the floating-point input format and the properties of the objective function.

[0040] S120 , performing segmentation processing on the processed data to generate a lookup table offset address and polynomial input data.

[0041] The lookup table is a table that pre-stores multiple polynomial coefficients, and the offset address is an index value used to locate a specific data position in the lookup table. The required polynomial coefficients can be quickly found through the lookup table offset address. Polynomial input data refers to the data that is processed and segmented and used as the input of the polynomial calculation. The polynomial input data will be combined with the polynomial coefficients for calculation to approximate the result of the target transcendental function.

[0042] Optionally, segmenting the processed data to generate a lookup table offset address and polynomial input data includes: using a first designated bit data of the processed data as the lookup table offset address; and using a second designated bit data of the processed data as the polynomial input data.

[0043] Specifically, for a transcendental function, a polynomial can be used to approximate it. By selecting appropriate polynomial coefficients, the polynomial can be made as close as possible to the value of the transcendental function within a specific interval. By specifying different positions, the processed data can be divided into different parts. Exemplarily, the high m bits of the independent variable data can be used as the lookup table offset address, and the low nm bits of the independent variable data can be used as the input of the polynomial calculation module.

[0044] In particular, taking function ex2 as an example, m is 6, that is, the convergence interval (0, 1) of the function is divided into 64 segments, and each segment of the function is approximated by a polynomial with different coefficients. Due to the influence of the floating-point format, if the low-order data of the independent variable is directly used for polynomial calculation, when the absolute value of the data is less than 2 -23 , the polynomial results obtained are exactly the same, which leads to a large precision error in the function in the interval (0, 1 / 64).

[0045] Therefore, this embodiment proposes a data storage method for retaining enough valid digits. That is, in the function convergence interval (0, 1), the input independent variable X F Save it in the form of a fixed-point decimal multiplied by the weight, denoted as On the one hand, the same computing core can be used with other objective functions; on the other hand, by calculating the difference between the weights of each order, the displacement required when adding each order is determined, thereby ensuring the calculation accuracy to the greatest extent.

[0046] S130, determining polynomial coefficients according to the offset address of the lookup table, and determining a calculation result of the target transcendental function according to the polynomial coefficients and the polynomial input data.

[0047] Optionally, determining the polynomial coefficients according to the lookup table offset address includes: obtaining a preset base address list, wherein the base address list includes the lookup table base addresses corresponding to each function type; matching the target function type through the base address list to obtain the target lookup table base address corresponding to the target function type; calling the target lookup table according to the target lookup table base address; and determining the polynomial coefficients from the target lookup table based on the lookup table offset address.

[0048] It should be noted that in order to adapt to the accuracy requirements of different objective functions, this implementation method sets up 5 different lookup tables according to the parameters when fitting different functions. Different lookup tables correspond to different base addresses, and the polynomial coefficients C0 / C1 / C2 / C3 are stored in different addresses of the lookup tables in a combined manner.

[0049] Specifically, the lookup table base address refers to the starting address of the memory area storing the lookup table of a specific function type. The preset base address list is constructed by analyzing and pre-configuring the lookup tables of different function types, and the base address list contains the base addresses of the lookup tables corresponding to various function types. When it is necessary to determine the polynomial coefficients of a specific target function type, the controller can first search and match in the preset base address list according to the target function type. For example, if the target function is a sine function, then the lookup table base address corresponding to the sine function is searched in the list. By matching, the lookup table base address corresponding to the target function type is found, and then the location of the target lookup table in the memory can be determined according to the target lookup table base address. The target lookup table is usually a structured data storage area containing multiple data items. The lookup table offset address is an offset relative to the target lookup table base address. By combining the base address and the offset address, the location of a specific data item in the lookup table can be determined. That is, according to the lookup table offset address, the corresponding data item, that is, the polynomial coefficient required subsequently, can be read from the target lookup table. For example, if the lookup table base address is 0x1000 and the offset address is 0x10, then the address of the specific data item to be accessed is 0x1010. The polynomial coefficients are used to construct a polynomial function to approximate the target transcendental function.

[0050] Optionally, the calculation result of the target transcendental function is determined based on the polynomial coefficients and the polynomial input data, including: substituting the polynomial coefficients and the polynomial input data into a preset calculation path formula to obtain the polynomial calculation result; scaling and restoring the polynomial calculation result based on the target convergence interval to determine the calculation result of the target transcendental function.

[0051] The preset calculation path formula is expressed by the following formula (1):

[0052]

[0053] in, represents the calculation result, C0, C1, C2 and C3 represent the polynomial coefficients, Represents polynomial input data. The controller can substitute specific polynomial coefficients and polynomial input data into a preset calculation path formula and perform calculations according to the operation order in the formula.

[0054] It should be noted that, since direct floating-point calculations occupy a large amount of hardware resources, in the calculation path, the binary fixed-point data is used throughout the multiplication and addition operations.

[0055] Specifically, Figure 2 A schematic diagram of a polynomial calculation path is provided for the first embodiment of the present invention. The calculation core performs multiplication and addition operations in the form of a pipeline. The first operation is C1X l 、C3Xl With X l 2 The multiplication operation is then performed and the resulting C3X l Product and X l 2 The products are reused to obtain the quadratic product and the cubic product. Then three addition operations are performed. Before each addition operation, it is necessary to calculate the product according to E l The information carried is shifted on the product of the first term and the product of the third term, the direction is right, and the number is |E l |( Figure 2 Right shift 1) and |2E l |( Figure 2 Similarly, a shift operation is performed on the sum of the quadratic term and the cubic term before the final addition operation ( Figure 2 Right shift 3), the shift amount is |2E l |. The output of the calculation module is divided into two parts: one part is the binary decimal representing the effective digits, denoted by X p , and the other part is the index E that represents the weight of the result p .

[0056] Among them, the target convergence interval is a specific interval determined when processing the target transcendental function, which is used to map the calculation results within the convergence interval to the entire single-precision floating-point domain and restore the final result to make it closer to the true value of the target transcendental function.

[0057] Optionally, after determining the calculation result of the target transcendental function based on the polynomial coefficients and the polynomial input data, the method also includes: determining a target rounding mode, wherein the target rounding mode includes rounding to the nearest, rounding to 0, rounding up, and rounding down; and normalizing the calculation result according to the target rounding mode.

[0058] Among them, the target rounding mode includes rounding to the nearest integer, rounding to 0, rounding up, and rounding down. Rounding to the nearest integer means rounding a value to the nearest integer. If the value is in the middle of two integers, it is usually rounded according to the principle of "rounding up". Rounding to 0 is also called truncation rounding, which means directly truncating the value to the integer part and ignoring the decimal part. Rounding up means rounding the value to the nearest integer in the positive infinity direction. Regardless of the size of the decimal part, the integer part is increased by 1. Rounding down means rounding the value to the nearest integer in the negative infinity direction. Regardless of the size of the decimal part, the integer part remains unchanged. By determining the target rounding mode and standardizing the calculation results of the target transcendental function according to the mode, the calculation results can be made more in line with specific application requirements and the accuracy and reliability of the calculation can be improved.

[0059] The technical solution of the embodiment of the present invention can quickly generate the lookup table offset address and polynomial input data by preprocessing and segmenting the independent variable data. The acquisition of the transcendental function calculation result does not require iteration, which reduces the complex calculation process and significantly improves the calculation speed and efficiency of the target transcendental function. The calculation of the transcendental function is converted into a lookup table and polynomial calculation, which simplifies the complexity of the calculation and can minimize the consumption of hardware resources. It can adapt to the calculation of target transcendental functions of different types and scales.

[0060] Embodiment 2

[0061] Figure 3 This is a flow chart of a transcendental function processing method provided in the second embodiment of the present invention. This embodiment adds a specific process of preprocessing the independent variable data of the target transcendental function to generate processed data on the basis of the above-mentioned first embodiment. Among them, the specific contents of steps S260-S270 are roughly the same as steps S120-S130 in the first embodiment, so they will not be repeated in this embodiment. Figure 3 As shown, the method includes:

[0062] S210, obtaining a target transcendental function.

[0063] S220, determining the target function type corresponding to the target transcendental function, and determining the target floating-point input format of the independent variable data.

[0064] S230: Obtain a preset special value processing table, wherein the special value processing includes output special values ​​corresponding to each function type and each floating-point input format.

[0065] S240: Match the target function type and the target floating-point input format through a preset special value processing table to determine the target output special value.

[0066] In a specific implementation, the following Table 1 is a schematic diagram of the obtained preset special value processing table:

[0067] Table 1

[0068]

[0069] Among them, rcp represents the reciprocal function, raqrt represents the reciprocal square root function, log2 represents the logarithmic function with base 2, and ex2 represents the exponential function 2 x , ex2m1 represents function 2 x-1, special values ​​in the target floating-point input format include NaN (not a number), ±inf (positive or negative infinity), -norm (negative normalized number), ±sub (positive or negative non-normalized number), and ±0. Special values ​​may appear in the calculation of transcendental functions and require special processing. For example, for logarithmic functions, when the independent variable is 0 or a negative number, the result is infinity or not a number; for exponential functions, when the exponent is infinite, the result is also infinite. In addition, the part marked as pending in the table needs to be converted to the standard format in the subsequent input range scaling and then processed uniformly.

[0070] Specifically, the preset special value processing table contains output special values ​​corresponding to different function types and different floating-point input formats. The controller can search and match in the preset special value processing table according to the determined target transcendental function type and the target floating-point input format of the independent variable data to determine the corresponding target output special value.

[0071] S250 , scaling the target output special value to generate processed data.

[0072] Optionally, the target output special value is scaled to generate processing data, including: obtaining a preset convergence interval value table, wherein the convergence interval value table includes convergence intervals corresponding to each function type; matching the target function type through the convergence interval value table to obtain a target convergence interval corresponding to the target function type; and scaling the target output special value based on the target convergence interval to generate processing data.

[0073] The preset convergence interval value table is constructed by analyzing and studying different transcendental functions and predetermining the convergence interval corresponding to each function type. The controller can search and match in the preset convergence interval value table according to the type of the target transcendental function to determine the target convergence interval. The target convergence interval will be used to scale the target output special value.

[0074] Specifically, the purpose of scaling is to adjust the target output special value to the target convergence interval so as to better perform subsequent calculations and processing. For example, if the target output special value exceeds the target convergence interval, it can be mapped to the interval through a certain scaling algorithm. The following Table 2 shows an example of the preset special value processing table obtained:

[0075] Table 2

[0076] Function Type Convergence interval rcp (1,2) rsqrt (1,2) log2 (1,2) ex2 (0,1) ex2m1 (0,1)

[0077] The left column represents the function type, the right column represents the convergence interval, rcp represents the reciprocal function, raqrt represents the reciprocal square root function, log2 represents the logarithmic function with base 2, and ex2 represents the exponential function 2x , ex2m1 represents function 2 x -1, and the right column is the convergence interval corresponding to each function type. It should be noted that for the function ex2(2 x ) and ex2m1(2 x -1), special processing is required when scaling: that is, according to the exponent E x Shift the significant digit X by the size to represent the floating-point input as a fixed-point decimal, and record the integer part as X I , the decimal part is recorded as X F Then convert the decimal part X F Send to the next step for processing.

[0078] S260 , performing segmentation processing on the processed data to generate a lookup table offset address and polynomial input data.

[0079] Optionally, segmenting the processed data to generate a lookup table offset address and polynomial input data includes: using a first designated bit data of the processed data as the lookup table offset address; and using a second designated bit data of the processed data as the polynomial input data.

[0080] S270, determining polynomial coefficients according to the offset address of the lookup table, and determining a calculation result of the target transcendental function according to the polynomial coefficients and the polynomial input data.

[0081] Optionally, determining the polynomial coefficients according to the lookup table offset address includes: obtaining a preset base address list, wherein the base address list includes the lookup table base addresses corresponding to each function type; matching the target function type through the base address list to obtain the target lookup table base address corresponding to the target function type; calling the target lookup table according to the target lookup table base address; and determining the polynomial coefficients from the target lookup table based on the lookup table offset address.

[0082] Optionally, the calculation result of the target transcendental function is determined based on the polynomial coefficients and the polynomial input data, including: substituting the polynomial coefficients and the polynomial input data into a preset calculation path formula to obtain the polynomial calculation result; scaling and restoring the polynomial calculation result based on the target convergence interval to determine the calculation result of the target transcendental function.

[0083] Optionally, after determining the calculation result of the target transcendental function based on the polynomial coefficients and the polynomial input data, the method also includes: determining a target rounding mode, wherein the target rounding mode includes rounding to the nearest, rounding to 0, rounding up, and rounding down; and normalizing the calculation result according to the target rounding mode.

[0084] The technical solution of the embodiment of the present invention can quickly generate the lookup table offset address and polynomial input data by preprocessing and segmenting the independent variable data. The acquisition of the transcendental function calculation result does not require iteration, which reduces the complex calculation process and significantly improves the calculation speed and efficiency of the target transcendental function. The calculation of the transcendental function is converted into a lookup table and polynomial calculation, which simplifies the complexity of the calculation and can minimize the consumption of hardware resources. It can adapt to the calculation of target transcendental functions of different types and scales.

[0085] Embodiment 3

[0086] Figure 4 This is a schematic diagram of the structure of a transcendental function processing device provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a data preprocessing module 310, which is used to obtain a target transcendental function and preprocess the independent variable data of the target transcendental function to generate processed data;

[0087] A data segmentation module 320, configured to segment the processed data to generate a lookup table offset address and polynomial input data;

[0088] The transcendental function calculation module 330 is used to determine polynomial coefficients according to the lookup table offset address, and determine the calculation result of the target transcendental function according to the polynomial coefficients and polynomial input data.

[0089] Optionally, the data preprocessing module 310 specifically includes: a function type and input format determination unit, used to determine the target function type corresponding to the target transcendental function, and determine the target floating-point input format of the independent variable data; a special value processing table acquisition unit, used to obtain a preset special value processing table, wherein the special value processing includes output special values ​​corresponding to each function type and each floating-point input format; a target output special value determination unit, used to match the target function type and the target floating-point input format through the preset special value processing table to determine the target output special value; and a data scaling unit, used to scale the target output special value to generate processed data.

[0090] Optionally, a data scaling unit is specifically used to: obtain a preset convergence interval value table, wherein the convergence interval value table includes convergence intervals corresponding to each function type; match the target function type through the convergence interval value table to obtain a target convergence interval corresponding to the target function type; and scale the target output special value based on the target convergence interval to generate processing data.

[0091] Optionally, the data segmentation module 320 is specifically used to: use the first designated bit data of the processed data as the offset address of the lookup table; and use the second designated bit data of the processed data as the polynomial input data.

[0092] Optionally, the transcendental function calculation module 330 specifically includes: a polynomial coefficient determination unit, which is used to: obtain a preset base address list, wherein the base address list includes a lookup table base address corresponding to each function type; match the target function type through the base address list to obtain a target lookup table base address corresponding to the target function type; call the target lookup table according to the target lookup table base address; and determine the polynomial coefficients from the target lookup table based on the lookup table offset address.

[0093] Optionally, the transcendental function calculation module 330 specifically includes: a transcendental function calculation unit, used to: substitute the polynomial coefficients and the polynomial input data into a preset calculation path formula to obtain the polynomial calculation result; and scale and restore the polynomial calculation result based on the target convergence interval to determine the calculation result of the target transcendental function.

[0094] Optionally, the device also includes: a standardization processing module, used to: determine a target rounding mode, wherein the target rounding mode includes rounding to the nearest, rounding to 0, rounding up and rounding down; and standardize the calculation result according to the target rounding mode.

[0095] The technical solution of the embodiment of the present invention can quickly generate the lookup table offset address and polynomial input data by preprocessing and segmenting the independent variable data. The acquisition of the transcendental function calculation result does not require iteration, which reduces the complex calculation process and significantly improves the calculation speed and efficiency of the target transcendental function. The calculation of the transcendental function is converted into a lookup table and polynomial calculation, which simplifies the complexity of the calculation and can minimize the consumption of hardware resources. It can adapt to the calculation of target transcendental functions of different types and scales.

[0096] A transcendental function processing device provided in an embodiment of the present invention can execute a transcendental function processing method provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

[0097] Embodiment 4

[0098] Figure 5 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0099] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0100] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0101] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as a transcendental function processing method.

[0102] In some embodiments, a transcendental function processing method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of a transcendental function processing method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a transcendental function processing method in any other appropriate manner (e.g., by means of firmware).

[0103] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0104] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0105] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0106] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0107] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0108] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0109] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0110] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A transcendental function processing method, characterized in that: include: Obtaining a target transcendental function, and preprocessing independent variable data of the target transcendental function to generate processed data; Performing segmentation processing on the processed data to generate a lookup table offset address and polynomial input data; The polynomial coefficients are determined according to the offset address of the lookup table, and the calculation result of the target transcendental function is determined according to the polynomial coefficients and the polynomial input data.

2. The method according to claim 1, characterized in that The preprocessing of the independent variable data of the target transcendental function to generate processed data includes: Determining the target function type corresponding to the target transcendental function, and determining the target floating-point input format of the independent variable data; Obtain a preset special value processing table, wherein the special value processing includes output special values ​​corresponding to each function type and each floating-point input format; Matching the target function type and the target floating-point input format through the preset special value processing table to determine a target output special value; The target output special value is scaled to generate processed data.

3. The method according to claim 2, characterized in that The step of performing scaling processing on the target output special value to generate processing data comprises: Obtaining a preset convergence interval value table, wherein the convergence interval value table includes convergence intervals corresponding to each function type; Matching the objective function type through the convergence interval value table to obtain a target convergence interval corresponding to the objective function type; The target output specific value is scaled based on the target convergence interval to generate processing data.

4. The method according to claim 1, characterized in that: The segmenting process of the processed data to generate a lookup table offset address and polynomial input data includes: Using the first designated bit data of the processed data as a lookup table offset address; The second designated bit data of the processing data is used as polynomial input data.

5. The method according to claim 2, characterized in that: The determining of polynomial coefficients according to the lookup table offset address comprises: Obtaining a preset base address list, wherein the base address list includes a lookup table base address corresponding to each function type; Matching the target function type through the base address list to obtain a target lookup table base address corresponding to the target function type; Retrieving a target lookup table according to the target lookup table base address; Polynomial coefficients are determined from the target lookup table based on the lookup table offset address.

6. The method according to claim 3, characterized in that The step of determining a calculation result of a target transcendental function according to the polynomial coefficients and the polynomial input data comprises: Substituting the polynomial coefficients and the polynomial input data into a preset calculation path formula to obtain a polynomial calculation result; The polynomial calculation result is scaled and restored based on the target convergence interval to determine the calculation result of the target transcendental function.

7. The method according to claim 1, characterized in that After determining the calculation result of the target transcendental function according to the polynomial coefficients and the polynomial input data, the method further includes: Determine a target rounding mode, wherein the target rounding mode includes rounding to nearest, rounding to zero, rounding up, and rounding down; The calculation result is normalized according to the target rounding mode.

8. A transcendental function processing device, characterized in that: include: A data preprocessing module, used for obtaining a target transcendental function, and preprocessing the independent variable data of the target transcendental function to generate processed data; A data segmentation module, used for segmenting the processed data to generate a lookup table offset address and polynomial input data; The transcendental function calculation module is used to determine the polynomial coefficients according to the offset address of the lookup table, and determine the calculation result of the target transcendental function according to the polynomial coefficients and polynomial input data.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 7 when executed.

Citation Information

Cited By

  • Multi-precision special function unit

    CN122195391A