Simulation calculation method and device and storage medium

By converting high-precision values ​​into low-precision values ​​and splitting them into multiple calculation items, the problem that artificial intelligence chips do not support high-precision floating-point calculations is solved, and higher-precision calculation results are achieved, expanding the application range of the chip.

CN119148979APending Publication Date: 2024-12-17SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411296988.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

Existing artificial intelligence chips do not support high-precision floating-point number calculations, which limits the accuracy and application range of artificial intelligence models.

Method used

By converting high-precision values ​​into two low-precision values ​​and splitting the high-precision calculation into multiple calculation terms, each calculation term is participated by two low-precision values, the approximation and error values ​​are calculated to simulate the high-precision calculation results.

Benefits of technology

Without increasing hardware costs, the calculation accuracy is improved and the accuracy range supported by artificial intelligence chips is expanded, and it is suitable for scenarios where high-precision computing is required.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119148979A_ABST
    Figure CN119148979A_ABST
Patent Text Reader

Abstract

The invention provides a simulation calculation method and device and a storage medium. The method comprises the steps that two original numerical values used for high-precision calculation are obtained; under the condition that the original numerical value is a high-precision numerical value, the high-precision numerical value is converted into two low-precision numerical values, the high-precision calculation is divided into at least two calculation items, and each calculation item is realized by the two low-precision numerical values; calculating each calculation item to obtain an approximate value and an error value of each calculation item; and based on the approximate value and the error value of each calculation item, determining a calculation result simulating the high-precision calculation. According to the method, the device and the storage medium provided by the invention, a calculation result with higher precision is obtained through an analog calculation mode on the premise of not increasing hardware cost, and the precision range supported by an artificial intelligence chip is effectively expanded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a simulation computing method, device and storage medium. Background Art

[0002] With the rapid development of artificial intelligence technology, artificial intelligence chips, as one of its core driving forces, play a vital role in model training and reasoning.

[0003] In order to improve computing efficiency and reduce costs, AI chips currently on the market generally support low-precision floating-point calculations (such as FP8, FP16, and FP32) and do not support high-precision floating-point calculations (such as FP64). This design strategy significantly improves computing speed and reduces power consumption and hardware costs, and is particularly suitable for large-scale data processing and real-time application scenarios.

[0004] Since high-precision floating-point calculations are not supported, applications that require high-precision calculations cannot be implemented on AI chips, which limits the accuracy of AI models and the application scope of AI chips. Summary of the invention

[0005] The present invention provides a simulation calculation method, device and storage medium to solve the defect that artificial intelligence chips in related technologies do not support high-precision calculations.

[0006] The present invention provides a simulation calculation method, comprising: Get two raw values ​​for high-precision calculations; In the case where the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0007] According to a simulation calculation method provided by the present invention, converting the high-precision numerical value into two low-precision numerical values ​​includes: The high-precision value is subjected to precision reduction processing to obtain a first low-precision value, and the difference between the high-precision value and the one low-precision value is used as a second low-precision value.

[0008] According to a simulation calculation method provided by the present invention, when the high-precision calculation is the addition of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the addition of the two high-precision values ​​into four calculation items to be performed sequentially; The four sequentially executed calculation items include adding the first low-precision values ​​of each of the two high-precision values ​​to obtain a first value, adding the second low-precision values ​​of each of the two high-precision values ​​to obtain a second value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the first low-precision value of the second value, adding the first low-precision value of the first value and the second low-precision value of the first value to obtain an updated first value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value, and adding the first low-precision value of the updated first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value.

[0009] According to a simulation calculation method provided by the present invention, when the high-precision calculation is the multiplication of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the multiplication of the two high-precision values ​​into the sum of three calculation items; The three calculation items include multiplying the first low-precision values ​​of each of the two high-precision values, multiplying the first low-precision value of one high-precision value by the second low-precision value of another high-precision value, and multiplying the second low-precision value of another high-precision value by the first low-precision value of another high-precision value.

[0010] According to a simulation calculation method provided by the present invention, when the high-precision calculation is the division of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the division of the two high-precision values ​​into five calculation items to be performed sequentially; The five sequentially executed calculation items include dividing the first low-precision values ​​of two high-precision values ​​to obtain a first value, multiplying a high-precision value by the first value to obtain a second value, subtracting another high-precision value from the second value to obtain a third value, multiplying the first low-precision value of the third value by the reciprocal of the first low-precision value of the high-precision value to obtain a fourth value, and adding the two first values ​​to the fourth value.

[0011] According to a simulation calculation method provided by the present invention, when the calculation item includes addition, the step of calculating each calculation item to obtain an approximate value and an error value of each calculation item includes: Adding two low-precision values ​​involved in the addition to obtain an approximate value of the addition; The approximate value of the addition and the two low-precision values ​​participating in the addition are used to determine the participating values ​​of the two low-precision values ​​in the addition; An error value of the addition is determined based on the two low-precision values ​​and the participation values ​​of the two low-precision values ​​in the addition.

[0012] According to a simulation calculation method provided by the present invention, when the calculation item includes multiplication, the step of calculating each calculation item to obtain an approximate value and an error value of each calculation item includes: Splitting two low-precision data involved in the multiplication into high-order terms and low-order terms respectively; Taking the product of the high-order terms of the two low-precision data as an approximate value of the multiplication; The product of the high-order term and the low-order term of the two low-precision data and the product of the low-order term of the two low-precision data are used as error values ​​of the multiplication.

[0013] A simulation calculation method provided by the present invention also includes: In the case where the original numerical value is low-precision data, the high-precision calculation is used as the calculation item.

[0014] The present invention provides a simulation calculation method, comprising: receiving a calculation instruction, wherein the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation; If it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0015] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned simulation calculation methods is implemented.

[0016] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the simulation calculation method described in any one of the above is implemented.

[0017] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the simulation calculation method described above is implemented.

[0018] The simulation calculation method, device and storage medium provided by the present invention can convert a high-precision value into two low-precision values, thereby simulating a high-precision calculation through calculations based on low-precision values. In addition, in this process, the approximate value and error value of each calculation item are calculated, and the calculation results of the high-precision calculation are simulated with the approximate value and the error value, further improving the calculation accuracy of the simulation calculation, and then obtaining a higher-precision calculation result through simulation calculation without increasing the hardware cost, effectively expanding the accuracy range supported by the artificial intelligence chip. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 It is one of the flow charts of the simulation calculation method provided by the present invention.

[0021] Figure 2 This is the second flow chart of the simulation calculation method provided by the present invention.

[0022] Figure 3 It is one of the structural schematic diagrams of the simulation computing device provided by the present invention.

[0023] Figure 4 This is the second structural schematic diagram of the analog computing device provided by the present invention.

[0024] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 are within the scope of protection of the present invention.

[0026] With the rapid development of artificial intelligence technology, artificial intelligence chips, as one of its core driving forces, play a vital role in model training and reasoning. Common artificial intelligence chips include GPU (Graphics Processing Unit), GPGPU (General-Purpose computing on Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural network Processing Unit), DPU (Deep learning Processing Unit), APU (Accelerated Processing Unit), etc.

[0027] At present, since the floating-point computing performance of artificial intelligence chips is better than that of the CPU (Central Processing Unit), artificial intelligence chips are also often used for floating-point calculations.

[0028] In order to improve computing efficiency, AI chips on the market currently generally support low-precision floating-point calculations (such as FP8, FP16, and FP32) to calculate the training and reasoning efficiency of AI models. At the same time, for cost considerations, AI chip manufacturers usually reduce the hardware computing units required for high-precision floating-point calculations (such as FP64) on mid- and low-end AI chip products, which makes many AI chips unable to support high-precision floating-point calculations. When high-precision calculations are required, AI chips can only achieve low-precision calculations through low-precision instructions, and the calculation results obtained are obviously unable to meet the accuracy requirements of high-precision calculations.

[0029] However, in some scenarios that require high-precision calculations, such as when applying the Resize operator to calculate coordinate mapping, or in scientific computing scenarios, slight precision losses may affect the accuracy and reliability of the calculation results. Since many artificial intelligence chips cannot support high-precision floating-point calculations, the application of artificial intelligence chips in the above scenarios is limited.

[0030] In order to improve the accuracy of artificial intelligence models and expand the application scope of artificial intelligence chips, an embodiment of the present invention provides a simulation calculation method, which can simulate high-precision floating-point calculations by performing low-precision floating-point calculations on artificial intelligence chips that do not support high-precision floating-point calculations, thereby replacing high-precision floating-point calculations with low-cost, low-loss simulation calculations.

[0031] Figure 1 It is one of the flow charts of the simulation calculation method provided by the present invention, such as Figure 1 As shown, the method can be applied to various types of artificial intelligence chips, and the method includes the following steps: Step 110, obtaining two original numerical values ​​for high-precision calculation.

[0032] Specifically, high-precision calculation refers to high-precision floating-point calculation, which refers to the use of a calculation technique with higher precision than the standard floating-point type (such as single-precision float in the IEEE754 standard). In an embodiment of the present invention, the high precision referred to in high-precision calculation can be the high precision of the calculated value or the high precision of the calculation technique. Generally, high-precision calculation can support data calculation with a larger numerical range than low-precision calculation. For example, low-precision calculation can support the calculation of single-precision floating-point numbers, while high-precision calculation can support the calculation of double-precision floating-point numbers with a larger numerical representation range than single-precision floating-point numbers.

[0033] For ease of explanation, the two values ​​used for high-precision calculations can be recorded as original values ​​in the embodiment of the present invention. Here, the original value can be a high-precision value, such as a double-precision double value of the FP64 type, or a low-precision value, such as a single-precision float value of the FP8, FP16 and FP32 types, and the embodiment of the present invention does not specifically limit this. It can be understood that when the original value itself is a high-precision value, the calculation used to implement the original value is a high-precision calculation; and when the original value itself is a low-precision value, the calculation process used to implement the original value may also involve a larger numerical range and precision, that is, it can also be a high-precision calculation.

[0034] Step 120, when the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least one calculation item, each calculation item is implemented by two low-precision values.

[0035] Specifically, after obtaining the two original values ​​for high-precision calculation, since the artificial intelligence chip cannot support high-precision calculation, it is first necessary to determine whether the original value is a high-precision value or a low-precision value.

[0036] In the case where the original value itself is a high-precision value, it is necessary to convert the high-precision value, specifically, converting a high-precision value into two low-precision values, that is, two low-precision values ​​can be used to represent a high-precision value with higher precision than itself. For example, the high-precision value can be type-converted to convert the high-precision value into a low-precision value, and then the difference between the high-precision value and the low-precision value is calculated, thereby, a low-precision value obtained by conversion and another low-precision value as the difference can be used as two low-precision values ​​that can represent the high-precision value.

[0037] By converting high-precision values ​​into low-precision values, all values ​​involved in high-precision calculations can be expressed as low-precision values.

[0038] On this basis, the high-precision calculation itself can be split, thereby splitting the high-precision calculation into at least one calculation item. It can be understood that the calculation items here are calculation items that can be directly run on the artificial intelligence chip, and each calculation item is participated by two low-precision values. That is, by splitting the high-precision calculation, the high-precision calculation can be simulated by at least one calculation item, thereby enabling the simulation of high-precision calculation to be realized on an artificial intelligence chip that only supports low-precision calculation.

[0039] Here, the high-precision calculation itself can be split by substituting the low-precision value obtained when the original value is a high-precision value into the high-precision calculation: For example, for two high-precision values , The multiplication of can be expressed as , assuming that the high-precision value can be Convert to two low-precision numbers and , the high-precision value Convert to two low-precision numbers and ,but:

[0040] From this we can get , , Three calculation items.

[0041] in, Can be a high-precision value With the general Convert to low precision The difference between Can be a high-precision value With the general Convert to low precision The difference between and Both are low-precision numbers with smaller values. The product of these two The value is smaller, so can be ignored in the calculation of the value.

[0042] Step 130, calculate each calculation item to obtain an approximate value and an error value of each calculation item.

[0043] Specifically, after completing the conversion of high-precision numerical values ​​and the splitting of high-precision calculations, each split calculation item can be calculated separately. In this process, due to the limited accuracy of running the calculation item on the artificial intelligence chip, in order to improve the calculation accuracy of the calculation item, the value directly calculated for the calculation item can be used as the approximate value of the calculation item, and the loss caused by the limited calculation accuracy during the operation of the calculation item can be used as the error value of the calculation item. Therefore, the calculation result of a calculation item can be characterized by two parts: the approximate value and the error value.

[0044] Among them, for a calculation item, the error value of the calculation item can be obtained by calculating the error between the original value of each low-precision numerical value participating in the calculation item and the value participating in the calculation in the actual calculation. Here, the error between the value participating in the calculation in the actual calculation and the low-precision numerical value itself is caused by the limited precision of the calculation itself. The limited precision of the calculation causes a loss of precision in the calculation process of the calculation item, which can be specifically reflected as the error between the value actually participating in the calculation and the low-precision numerical value itself. Here, taking the addition calculation item as an example, for a low-precision numerical value, the value actually participating in the calculation can be obtained by the difference between the approximate value of the calculation item and another low-precision numerical value.

[0045] Moreover, for different types of calculation items, the calculation method of the error value can be different. For example, for addition calculation items, the difference between the original and actual participating values ​​of each low-precision value can be summed as the error value of the addition calculation item. For another example, for multiplication calculation items, the low-order term of each low-precision value can be regarded as the part that fails to participate in the calculation, and the product of the low-order term and the high-order term of other low-precision values, as well as the sum of the products between the low-order terms of each low-precision value, can be regarded as the error value of the multiplication calculation item.

[0046] Step 140, determining a calculation result simulating the high-precision calculation based on the approximate value and the error value of each calculation item.

[0047] Specifically, after obtaining the approximate value and the error value of each calculation item, the approximate value and the error value of each calculation item can be accumulated to obtain the calculation result obtained by simulating high-precision calculation.

[0048] In the method provided in the embodiment of the present invention, a high-precision value can be converted into two low-precision values, thereby simulating high-precision calculations through calculations based on low-precision values. In addition, in this process, the approximate value and error value of each calculation item are calculated, and the calculation results of the high-precision calculations are simulated with the approximate value and the error value, further improving the calculation accuracy of the simulated calculation, and then obtaining a higher-precision calculation result through simulated calculation without increasing the hardware cost, effectively expanding the accuracy range supported by the artificial intelligence chip.

[0049] Based on the above embodiment, in step 120, converting the high-precision value into two low-precision values ​​includes: The high-precision value is subjected to precision reduction processing to obtain a first low-precision value, and the difference between the high-precision value and the one low-precision value is used as a second low-precision value.

[0050] Specifically, for any original high-precision value, the high-precision value can be processed to reduce its precision. Here, the value after the precision reduction can be used as a low-precision value representing the high-precision value. For the sake of distinction, it can be recorded as the first low-precision value.

[0051] Here, the precision reduction process may be implemented by data type conversion, for example, converting a double-precision double type into a single-precision float type.

[0052] After the precision reduction process is completed and the first low-precision value is obtained, the difference between the high-precision value and the first precision value can be calculated. It can be understood that the difference here reflects the error introduced by the precision reduction process, and the difference can be used as another low-precision value representing the high-precision value, which is recorded as the second low-precision value here.

[0053] Thus, a high-precision value can be represented by the first low-precision value and the second low-precision value.

[0054] For example, the conversion from high-precision numbers to low-precision numbers can be achieved through the following code: double doubleθ; float x = float(doubleθ); float y = float(doubleθ - double(x)); In the above code, a double-precision double value is first defined, that is, doubleθ. It can be understood that doubleθ here is a high-precision value. By float x = float(doubleθ), the type of doubleθ is converted to single-precision float type, and the obtained x is the first low-precision value. By float y = float(doubleθ -double(x)), the difference between the high-precision value and the first low-precision value is converted to single-precision float type, and the obtained y is the second low-precision value.

[0055] It can be understood that, in the two low-precision values ​​obtained by converting the high-precision value, the value of the first low-precision value is greater than the value of the second low-precision value.

[0056] Based on any of the above embodiments, in step 120, when the high-precision calculation is the addition of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the addition of the two high-precision values ​​into four calculation items to be performed sequentially; The four sequentially executed calculation items include adding the first low-precision values ​​of each of the two high-precision values ​​to obtain a first value, adding the second low-precision values ​​of each of the two high-precision values ​​to obtain a second value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the first low-precision value of the second value, adding the first low-precision value of the first value and the second low-precision value of the first value to obtain an updated first value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value, and adding the first low-precision value of the updated first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value.

[0057] Specifically, the addition of two high-precision values ​​can be regarded as the addition of two high-precision values ​​converted into two low-precision values ​​respectively, that is, the addition of four low-precision values.

[0058] For example, for two high-precision values , The addition of can be expressed as , assuming that the high-precision value can be Convert to the first low-precision value and the second lowest precision refers to , the high-precision value Convert to the first low-precision value and the second lowest precision value ,but:

[0059] In the above formula, the addition of four low-precision values, each step of the addition operation may produce errors compared with the actual result because the addition result does not conform to the range of the low-precision value. In view of this situation, the addition of the above four low-precision values ​​can be divided into the following four calculation items executed in sequence: Calculation item 1, adding the first low-precision values ​​of the two high-precision values ​​to obtain the first value, can be expressed as:

[0060] in, That is the first value.

[0061] Calculation item 2, adding the second low-precision values ​​of the two high-precision values ​​to obtain the second value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the first low-precision value of the second value, can be expressed as:

[0062] in, That is, the second value, That is, the first low-precision value of the second value. is the second lowest precision value of the first value, Indicates that in the original On the basis of As new .

[0063] Calculation item 3, adding the first low-precision value of the first value and the second low-precision value of the first value to obtain the updated first value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value, can be expressed as:

[0064] in, and are respectively a first low-precision value and a second low-precision value of the first value, The second lowest precision value of the second value. Indicates that the first low-precision value and the second low-precision value of the first value are added to form a new first value. Indicates that in the original On the basis of As new .

[0065] Calculation item 4, adding the first low-precision value of the updated first value and the second low-precision value of the updated first value, can be expressed as:

[0066] in, Indicates that the first low-precision value and the second low-precision value of the first value are added to form a new first value. Indicates that the new first value is calculated as the result of adding two high-precision values.

[0067] It should be noted that, in the above four calculation items executed sequentially, the addition in each calculation item may produce errors, so when calculating each calculation item, the approximate value and error value of the calculation item can be calculated respectively.

[0068] In addition, the subtraction of two high-precision values ​​can be regarded as the addition of a high-precision value and another high-precision value in the form of a negative number, for example That is, for the subtraction of two high-precision values, the calculation items can be split by referring to the addition of two high-precision values ​​in the above embodiment, which will not be described in detail here.

[0069] Based on any of the above embodiments, in step 120, when the high-precision calculation is the multiplication of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the multiplication of the two high-precision values ​​into the sum of three calculation items; The three calculation items include multiplying the first low-precision values ​​of each of the two high-precision values, multiplying the first low-precision value of one high-precision value by the second low-precision value of another high-precision value, and multiplying the second low-precision value of another high-precision value by the first low-precision value of another high-precision value.

[0070] Specifically, the multiplication of two high-precision values ​​can be regarded as the multiplication after the two high-precision values ​​are converted into two low-precision values ​​respectively.

[0071] For example, for two high-precision values , The multiplication of can be expressed as , assuming that the high-precision value can be Convert to two low-precision numbers and , the high-precision value Convert to two low-precision numbers and ,but:

[0072] From this we can get , , Three calculation items.

[0073] in, Indicates the multiplication of the first low-precision values ​​of two high-precision values. The first low-precision value representing a high-precision value is multiplied by the second low-precision value of another high-precision value. Represents multiplying the second lowest precision of another high precision value by the first lowest precision of another high precision value.

[0074] It is understandable that due to , Compared to , The value of is larger. In multiplication operations, the product overflow is more likely, so When calculating, you can calculate its approximate value and error value separately, and The error value and Add the final error value as the multiplication of two high-precision numbers.

[0075] Based on any of the above embodiments, in step 120, when the high-precision calculation is the division of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the division of the two high-precision values ​​into five calculation items to be performed sequentially; The five sequentially executed calculation items include dividing the first low-precision values ​​of two high-precision values ​​to obtain a first value, multiplying a high-precision value by the first value to obtain a second value, subtracting another high-precision value from the second value to obtain a third value, multiplying the first low-precision value of the third value by the reciprocal of the first low-precision value of the high-precision value to obtain a fourth value, and adding the first value to the fourth value.

[0076] Specifically, the division of two high-precision values ​​can be regarded as the division after converting the two high-precision values ​​into two low-precision values. In addition, since the value of the first low-precision value is much larger than the value of the second low-precision value for each high-precision value, the division of the two high-precision values ​​can be omitted as the division of the two first low-precision values.

[0077] In an embodiment of the present invention, the Newton-Raphson method can be used to implement the decomposition of division. Here, the Newton-Raphson method, also known as the Newton iteration method or the Newton-Raphson method, is a method for approximately solving equations in the real number domain and the complex number domain. It uses the first few terms of the Taylor series of the function to find the root of the equation.

[0078] Assume the division operation is , then you can construct the function , by solving for x to calculate Since in the Newton-Raphson method, The neighborhood of the root converges quadratically, so the first two terms of the Taylor polynomial can be taken as the approximate value of the division operation, which can be specifically expressed as:

[0079] By transforming the above formula, we can get:

[0080] in:

[0081] in, can be considered as an approximation of the division calculation, That is, it includes the approximate value and error value of the division calculation.

[0082] Based on the above formula, the triggering of two high-precision values ​​can be split into five sequentially executed calculation items: Calculation item 1: Divide the first low-precision values ​​of the two high-precision values ​​to obtain a first value, where the first value can be expressed as:

[0083] Here, two low-precision numbers are divided by applying the single-precision division that is natively supported by the artificial intelligence chip.

[0084] Calculation item 2: multiply a high-precision value by the first value to obtain a second value, where the second value can be expressed as:

[0085] Here, the multiplication of two values ​​can simulate high-precision multiplication, that is, when this calculation item is calculated, its approximate value and error value can be calculated.

[0086] Calculation item 3: Subtract another high-precision value from the second value to obtain a third value, where the third value can be expressed as:

[0087] Here, the subtraction of two values ​​can simulate high-precision subtraction, that is, when this calculation item is calculated, its approximate value and error value can be calculated.

[0088] Calculation item 4: multiplying the first low-precision value of the third value by the reciprocal of the first low-precision value of a high-precision value to obtain a fourth value, wherein the fourth value can be expressed as:

[0089] That is, the first low-precision value of the third value.

[0090] Here, the multiplication of two values ​​can be converted into the division of the first low-precision value of the third value by the first low-precision value of a high-precision value, by applying the single-precision division natively supported by the artificial intelligence chip.

[0091] Calculation item 5: Add the first value and the fourth value to obtain the calculation result, which can be expressed as:

[0092] Here, the addition of two numerical values ​​can simulate high-precision addition, that is, when this calculation item is calculated, its approximate value and error value can be calculated.

[0093] Based on any of the above embodiments, in step 130, when the calculation item includes addition, calculating each calculation item to obtain an approximate value and an error value of each calculation item includes: Adding two low-precision values ​​involved in the addition to obtain an approximate value of the addition; The approximate value of the addition and the two low-precision values ​​participating in the addition are used to determine the participating values ​​of the two low-precision values ​​in the addition; An error value of the addition is determined based on the two low-precision values ​​and the participation values ​​of the two low-precision values ​​in the addition.

[0094] Specifically, when any calculation item is addition, calculation is performed on the calculation item, that is, addition calculation is performed on two low-precision values. In order to ensure the addition accuracy of the two low-precision values, the approximate value and error value of the addition can be calculated respectively.

[0095] Among them, the two low-precision values ​​involved in the addition can be directly added to obtain an approximate value of the addition.

[0096] After that, the approximate value of addition can be combined with the two low-precision values ​​involved in the addition to calculate the actual numerical values ​​of the two low-precision values ​​in the calculation of the approximate value of addition, that is, to obtain the participation values ​​of the two low-precision values. For the calculation of the participation value of one of the low-precision values, the approximate value of addition can be subtracted from the other low-precision value, and the difference obtained by the subtraction can be used as the participation value of the low-precision value. In addition, the approximate value of addition can be subtracted from the participation value of the low-precision value, and the difference obtained by the subtraction can be used as the participation value of the other low-precision value.

[0097] After obtaining the participating values ​​of the two low-precision numbers, the difference between the two low-precision numbers themselves and their respective participating values ​​can be calculated, thereby obtaining the error value introduced by the two low-precision numbers in the addition calculation, and the two error values ​​can be added to obtain the error value of the addition.

[0098] For example, the approximate value and error value calculation of addition can be implemented by the following code: float s32, v32, e32 ; s32 = a32 + b32 ; v32 = s32 - a32 ; / / v32 is the actual value of b32 in the second row of operations, s32 - v32 is the actual value of a32 in the second row of operations

[0099] e32 = (a32 - (s32- v32)) + (b32 - v32); / / Calculate the total error based on the difference between the original value and the rounded value actually involved in the operation

[0100] return FLOAT2{s32, e32}; In the above code, three single-precision values ​​are defined, namely s32, v32, and e32, where s32 is the approximate value obtained by adding a32 and b32, v32 is the value of b32 in the addition, and e32 is the error value of the addition.

[0101] For example, assuming a32=5.623730e-07, b32=8.075688e-07, we can calculate that the approximate value of the addition of the two is 1.369941e-06, the participation value of a32 in the addition is 5.62373e-07, and the participation value of b32 in the addition is 8.07568e-07, so the error value of the addition is 8e-14.

[0102] Based on any of the above embodiments, in step 130, when the calculation item includes multiplication, calculating each calculation item to obtain an approximate value and an error value of each calculation item includes: Splitting two low-precision data involved in the multiplication into high-order terms and low-order terms respectively; Taking the product of the high-order terms of the two low-precision data as an approximate value of the multiplication; The product of the high-order term and the low-order term of the two low-precision data and the product of the low-order term of the two low-precision data are used as error values ​​of the multiplication.

[0103] Specifically, when any calculation item is a multiplication, the calculation is performed on the calculation item, that is, the multiplication calculation is performed on two low-precision values. In order to ensure the multiplication accuracy of the two low-precision values, the approximate value and the error value of the multiplication can be calculated respectively.

[0104] In multiplication calculations, since the calculation result may overflow because it is not suitable for the low-precision numerical range, the two low-precision numbers involved in the multiplication can be split into high-order terms and low-order terms before the calculation.

[0105] Among them, for any low-precision value, assume that the low-precision value is , the high-order and low-order terms of the low-precision value can be separated by the following steps:

[0106] In the above formula, it is assumed that is a variable of FP32 type, and They are The high-order and low-order terms of , The number of significant digits in the mantissa of a floating point number.

[0107] For example, take , , you can Split into high-order terms and low-order terms, where the high-order terms , low-order terms .

[0108] It can be understood that by splitting the low-precision numerical value into high-order terms and low-order terms, and putting the high-order terms and low-order terms of two low-precision numerical values ​​into multiplication calculation, the product can be adapted to the low-precision numerical range and no overflow will occur.

[0109] After obtaining the high-order term and low-order term of the two low-precision values, the high-order terms of the two low-precision values ​​can be multiplied as the approximate value of the multiplication. In addition, the sum of the product of the high-order term of a low-precision value and the low-order term of another low-precision value, the product of the low-order term of a low-precision value and the high-order term of another low-precision value, and the product of the low-order terms of the two low-precision values ​​can be used as the error value of the multiplication.

[0110] That is, the calculation of the approximate value and error value of multiplication can be expressed by the following formula:

[0111] In the formula, and for The high-order and low-order terms of and for The high-order and low-order terms of for The approximate value of for The error term of .

[0112] Based on any of the above embodiments, the method further includes: In the case where the original numerical value is low-precision data, the high-precision calculation is used as the calculation item.

[0113] Specifically, after obtaining two original values ​​for high-precision calculation, it can be determined whether the original values ​​are high-precision values ​​or low-precision values.

[0114] In the case where the original value itself is a low-precision value, there is no need to convert the original value, and the original value can be directly applied to participate in high-precision calculations. In this case, there is no need to split the high-precision calculations, and the high-precision calculations themselves can be directly used as a calculation item. It can be understood that the calculation items here are calculation items that can be directly run on the artificial intelligence chip, and the calculation items are all participated by two low-precision values. The low-precision values ​​participating in the calculation items here are the original values ​​themselves.

[0115] Based on any of the above embodiments, the simulation calculation method may include the following steps: For the case where the high-precision calculation is addition and the two original values ​​used for the high-precision calculation are both low-precision values, that is, the case where the high-precision calculation is single-precision addition, the addition can be directly used as the calculation item of the high-precision calculation, the sum of the two low-precision values ​​can be used as the approximate value of the addition, and the sum of the differences between the two low-precision values ​​themselves and the values ​​participating in the addition can be used as the error value of the addition. The calculation result of the single-precision addition can be simulated by the approximate value and error value of the addition.

[0116] For the case where the high-precision calculation is addition, and the two original values ​​used for the high-precision calculation are both high-precision values, that is, the high-precision calculation is FLOAT2 addition, the two high-precision values ​​can be split into two low-precision values ​​respectively, that is, four low-precision values ​​are obtained, and then the calculation items for FLOAT2 addition are split, thereby obtaining four sequentially executed calculation items and executing them sequentially. The four sequentially executed calculation items here are all additions. During the execution of each calculation item, the approximate value and error value of the item can be calculated, thereby realizing the accumulation of the error values ​​of each calculation item, and then obtaining the approximate value and error value of FLOAT2 addition to simulate the calculation result of FLOAT2 addition.

[0117] In the case where the high-precision calculation is multiplication, and the two original values ​​used for the high-precision calculation are both low-precision values, that is, the high-precision calculation is single-precision multiplication, the multiplication can be directly used as the calculation item of the high-precision calculation to calculate the multiplication calculation item. In this process, the two low-precision values ​​can be split into high-order terms and low-order terms, and the product of the high-order terms of the two low-precision values ​​is used as the approximate value of the multiplication, and the product of the high-order terms and low-order terms of the two low-precision values, and the sum of the products of the low-order terms are used as the error value of the multiplication, thereby simulating the calculation result of the single-precision multiplication.

[0118] For the case where the high-precision calculation is multiplication, and both the original values ​​used for the high-precision calculation are high-precision values, that is, the case where the high-precision calculation is FLOAT2 multiplication, the two high-precision values ​​can be first split into two low-precision values, that is, four low-precision values ​​are obtained, and then the calculation items for FLOAT2 multiplication are split, thereby obtaining the sum of three calculation items. Among the three calculation items, the calculation item of multiplying the first low-precision values ​​of the two high-precision values ​​can calculate the approximate value and the error value in the form of single-precision multiplication, and the other two calculation items, that is, multiplying the first low-precision value of a high-precision value by the second low-precision value of another high-precision value, and multiplying the second low-precision value of another high-precision value by the first low-precision value of another high-precision value, can directly regard the calculation result as the error value and accumulate it with the error value of the first calculation item, thereby obtaining the approximate value and error value of FLOAT2 multiplication to simulate the calculation result of FLOAT2 multiplication.

[0119] For the case where the high-precision calculation is division, and the two original values ​​used for the high-precision calculation are both high-precision values, that is, the case where the high-precision calculation is FLOAT2 division, the two high-precision values ​​can be split into two low-precision values, that is, four low-precision values ​​are obtained, and the first low-precision values ​​of the two high-precision values ​​are applied for calculation. In addition, the calculation items can be split for FLOAT2 division to obtain five sequentially executed calculation items. The five sequentially executed calculation items here include division, multiplication, subtraction, and addition, among which multiplication, subtraction, and addition can be used to calculate approximate values ​​and error values, and division can be implemented based on the single-precision calculation method natively supported by the artificial intelligence chip. The approximate value and error value of FLOAT2 division are thus obtained to simulate the calculation result of FLOAT2 division.

[0120] Based on any of the above embodiments, Figure 2 This is the second flow chart of the simulation calculation method provided by the present invention. Figure 2 As shown, the method can be applied to various types of artificial intelligence chips, and the method includes the following steps: Step 210: Receive a calculation instruction, where the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation.

[0121] Here, the computing instruction may be a pre-written instruction for instructing the artificial intelligence chip to perform computing, for example, it may be a computing instruction in a pre-written instruction sequence for implementing model reasoning or training. Alternatively, the computing instruction may also be an instruction input by a user, which is not specifically limited in the embodiment of the present invention.

[0122] The calculation instruction may include high-precision calculation and two original numerical values ​​used for high-precision calculation. That is, the calculation instruction is used to instruct the artificial intelligence chip to perform high-precision calculation based on two original data.

[0123] Here, high-precision calculation refers to high-precision floating-point calculation, which refers to a calculation technique with higher precision than the standard floating-point type. In the embodiment of the present invention, the high precision referred to in high-precision calculation can be the high precision of the calculated value or the high precision of the calculation technique.

[0124] For ease of explanation, the two values ​​used for high-precision calculations can be recorded as original values ​​in the embodiment of the present invention. Here, the original value can be a high-precision value, such as a double-precision double value of the FP64 type, or a low-precision value, such as a single-precision float value of the FP8, FP16 and FP32 types, and the embodiment of the present invention does not specifically limit this. It can be understood that when the original value itself is a high-precision value, the calculation used to implement the original value is a high-precision calculation; and when the original value itself is a low-precision value, the calculation process used to implement the original value may also involve a larger numerical range and precision, that is, it can also be a high-precision calculation.

[0125] Step 220, when it is determined that the high-precision calculation is not supported locally and the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least one calculation item, each calculation item being implemented by two low-precision values.

[0126] Specifically, after receiving the calculation instruction, it can first be determined whether the artificial intelligence chip itself supports the high-precision calculation indicated by the calculation instruction. If the artificial intelligence chip itself can support high-precision calculation, the two original values ​​carried in the calculation instruction can be directly applied to perform high-precision calculation and obtain the calculation result.

[0127] If the artificial intelligence chip itself does not support high-precision calculations, it is first necessary to determine whether the original value is a high-precision value or a low-precision value.

[0128] In the case where the original value itself is a high-precision value, it is necessary to convert the high-precision value, specifically, converting a high-precision value into two low-precision values, that is, two low-precision values ​​can be used to represent a high-precision value with higher precision than itself. For example, the high-precision value can be type-converted to convert the high-precision value into a low-precision value, and then the difference between the high-precision value and the low-precision value is calculated, thereby, a low-precision value obtained by conversion and another low-precision value as the difference can be used as two low-precision values ​​that can represent the high-precision value.

[0129] By converting high-precision values ​​into low-precision values, all values ​​involved in high-precision calculations can be expressed as low-precision values.

[0130] On this basis, the high-precision calculation itself can be split, thereby splitting the high-precision calculation into at least one calculation item. It can be understood that the calculation items here are calculation items that can be directly run on the artificial intelligence chip, and each calculation item is participated by two low-precision values. That is, by splitting the high-precision calculation, the high-precision calculation can be simulated by at least one calculation item, thereby enabling the simulation of high-precision calculation to be realized on an artificial intelligence chip that only supports low-precision calculation.

[0131] Here, the high-precision calculation itself is split, which can be achieved by substituting the low-precision value obtained by converting the original value to a high-precision value into the high-precision calculation.

[0132] Step 230, calculate each calculation item to obtain an approximate value and an error value of each calculation item.

[0133] Specifically, after completing the conversion of high-precision numerical values ​​and the splitting of high-precision calculations, each split calculation item can be calculated separately. In this process, due to the limited accuracy of running the calculation item on the artificial intelligence chip, in order to improve the calculation accuracy of the calculation item, the value directly calculated for the calculation item can be used as the approximate value of the calculation item, and the loss caused by the limited calculation accuracy during the operation of the calculation item can be used as the error value of the calculation item. Therefore, the calculation result of a calculation item can be characterized by two parts: the approximate value and the error value.

[0134] Among them, for a calculation item, the error value of the calculation item can be obtained by calculating the error between the original value of each low-precision numerical value participating in the calculation item and the value participating in the calculation in the actual calculation. Here, the error between the value participating in the calculation in the actual calculation and the low-precision numerical value itself is caused by the limited precision of the calculation itself. The limited precision of the calculation causes a loss of precision in the calculation process of the calculation item, which can be specifically reflected as the error between the value actually participating in the calculation and the low-precision numerical value itself. Here, taking the addition calculation item as an example, for a low-precision numerical value, the value actually participating in the calculation can be obtained by the difference between the approximate value of the calculation item and another low-precision numerical value.

[0135] Moreover, for different types of calculation items, the calculation method of the error value can be different. For example, for addition calculation items, the difference between the original and actual participating values ​​of each low-precision value can be summed as the error value of the addition calculation item. For another example, for multiplication calculation items, the low-order term of each low-precision value can be regarded as the part that fails to participate in the calculation, and the product of the low-order term and the high-order term of other low-precision values, as well as the sum of the products between the low-order terms of each low-precision value, can be regarded as the error value of the multiplication calculation item.

[0136] Step 240, determining a calculation result simulating the high-precision calculation based on the approximate value and the error value of each calculation item.

[0137] Specifically, after obtaining the approximate value and the error value of each calculation item, the approximate value and the error value of each calculation item can be accumulated to obtain the calculation result obtained by simulating high-precision calculation.

[0138] In the method provided in the embodiment of the present invention, a high-precision value can be converted into two low-precision values, thereby simulating high-precision calculations through calculations based on low-precision values. In addition, in this process, the approximate value and error value of each calculation item are calculated, and the calculation results of the high-precision calculations are simulated with the approximate value and the error value, further improving the calculation accuracy of the simulated calculation, and then obtaining a higher-precision calculation result through simulated calculation without increasing the hardware cost, effectively expanding the accuracy range supported by the artificial intelligence chip.

[0139] It should be noted that the simulation calculation method provided by the above embodiments of the present invention can be used for the training and reasoning of various models on artificial intelligence chips, for example, it can be applied to the training and reasoning of different types of data processing models such as speech, image text, and video. The applicable scenarios of various embodiments of the present invention depend on the type of model used for high-precision calculation in the present invention and its design purpose.

[0140] Specifically, for speech models such as speech recognition and speech synthesis, a speech data set containing various languages, accents, and environmental noise can be constructed as the input data of the speech model, and the required high-precision calculation simulation can be realized during the training and reasoning process of the speech model, thereby ensuring the accuracy of the artificial intelligence chip in speech processing through various embodiments of the present invention. In addition, for the speech model, it can include common operators such as convolution operators and pooling operators, and the calculation process of these operators can be realized through the above-mentioned simulation calculation.

[0141] For computer vision models such as image classification, target detection, and image segmentation, an image test set containing a variety of objects, scenes, and lighting conditions can be designed as the input data of the computer vision model, and the required high-precision calculation simulation can be realized in the training and reasoning process of the computer vision model, so as to ensure the accuracy of the artificial intelligence chip in computer vision processing through various embodiments of the present invention. In addition, for computer vision models, commonly used operators include various edge detection operators (such as Sobel operator, Canny operator, Prewitt operator, etc.), image filtering operators (such as Gaussian filtering, median filtering, bilateral filtering, etc.), morphological operators (such as corrosion, expansion, opening operation, closing operation, etc.), etc. The calculation process of these operators can be realized through the above-mentioned simulation calculation.

[0142] The simulation computing device provided by the present invention is described below. The simulation computing device described below and the simulation computing method described above can be referenced to each other.

[0143] Figure 3 is one of the structural schematic diagrams of the simulation computing device provided by the present invention, such as Figure 3 As shown, the device comprises: An acquisition unit 310 is used to acquire two original values ​​for high-precision calculation; A conversion unit 320 is used to convert the high-precision value into two low-precision values ​​when the original value is a high-precision value, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; A calculation unit 330, used to calculate each calculation item to obtain an approximate value and an error value of each calculation item; The simulation unit 340 is used to determine the calculation result of simulating the high-precision calculation based on the approximate value and the error value of each calculation item.

[0144] In the device provided by the embodiment of the present invention, a high-precision value can be converted into two low-precision values, thereby simulating high-precision calculations through calculations based on low-precision values. In addition, in this process, the approximate value and error value of each calculation item are calculated, and the calculation results of the high-precision calculations are simulated with the approximate value and the error value, further improving the calculation accuracy of the simulated calculation, and then obtaining a higher-precision calculation result through the simulated calculation without increasing the hardware cost, effectively expanding the accuracy range supported by the artificial intelligence chip.

[0145] Based on any of the above embodiments, the conversion unit is specifically used for: The high-precision value is subjected to precision reduction processing to obtain a first low-precision value, and the difference between the high-precision value and the one low-precision value is used as a second low-precision value.

[0146] Based on any of the above embodiments, when the high-precision calculation is the addition of two high-precision values, the conversion unit is specifically used to: Splitting the addition of the two high-precision values ​​into four calculation items to be performed sequentially; The four sequentially executed calculation items include adding the first low-precision values ​​of each of the two high-precision values ​​to obtain a first value, adding the second low-precision values ​​of each of the two high-precision values ​​to obtain a second value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the first low-precision value of the second value, adding the first low-precision value of the first value and the second low-precision value of the first value to obtain an updated first value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value, and adding the first low-precision value of the updated first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value.

[0147] Based on any of the above embodiments, when the high-precision calculation is the multiplication of two high-precision values, the conversion unit is specifically used to: Splitting the multiplication of the two high-precision values ​​into the sum of three calculation items; The three calculation items include multiplying the first low-precision values ​​of each of the two high-precision values, multiplying the first low-precision value of one high-precision value by the second low-precision value of another high-precision value, and multiplying the second low-precision value of another high-precision value by the first low-precision value of another high-precision value.

[0148] Based on any of the above embodiments, when the high-precision calculation is the division of two high-precision values, the conversion unit is specifically used to: Splitting the division of the two high-precision values ​​into five calculation items to be performed sequentially; The five sequentially executed calculation items include dividing the first low-precision values ​​of two high-precision values ​​to obtain a first value, multiplying a high-precision value by the first value to obtain a second value, subtracting another high-precision value from the second value to obtain a third value, multiplying the first low-precision value of the third value by the reciprocal of the first low-precision value of the high-precision value to obtain a fourth value, and adding the two first values ​​to the fourth value.

[0149] Based on any of the foregoing embodiments, when the calculation item includes addition, the calculation unit is specifically used to: Adding two low-precision values ​​involved in the addition to obtain an approximate value of the addition; The approximate value of the addition and the two low-precision values ​​participating in the addition are used to determine the participating values ​​of the two low-precision values ​​in the addition; An error value of the addition is determined based on the two low-precision values ​​and the participation values ​​of the two low-precision values ​​in the addition.

[0150] Based on any of the foregoing embodiments, when the calculation item includes multiplication, the calculation unit is specifically used to: Splitting two low-precision data involved in the multiplication into high-order terms and low-order terms respectively; Taking the product of the high-order terms of the two low-precision data as an approximate value of the multiplication; The product of the high-order term and the low-order term of the two low-precision data and the product of the low-order term of the two low-precision data are used as error values ​​of the multiplication.

[0151] Based on any of the above embodiments, the conversion unit is further used for: In the case where the original numerical value is low-precision data, the high-precision calculation is used as the calculation item.

[0152] Based on any of the above embodiments, Figure 4 This is the second structural diagram of the analog computing device provided by the present invention, such as Figure 4 As shown, the device comprises: A receiving unit 410 is used to receive a calculation instruction, where the calculation instruction includes a high-precision calculation and two original values ​​used for the high-precision calculation; A judgment conversion unit 420 is used to, when it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; A calculation unit 430, used to calculate each calculation item to obtain an approximate value and an error value of each calculation item; The simulation unit 440 is used to determine the calculation result of simulating the high-precision calculation based on the approximate value and error value of each calculation item.

[0153] In the device provided by the embodiment of the present invention, a high-precision value can be converted into two low-precision values, thereby simulating high-precision calculations through calculations based on low-precision values. In addition, in this process, the approximate value and error value of each calculation item are calculated, and the calculation results of the high-precision calculations are simulated with the approximate value and the error value, further improving the calculation accuracy of the simulated calculation, and then obtaining a higher-precision calculation result through the simulated calculation without increasing the hardware cost, effectively expanding the accuracy range supported by the artificial intelligence chip.

[0154] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the simulation calculation method, which includes: Get two raw values ​​for high-precision calculations; In the case where the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0155] Alternatively, the processor 510 may call the logic instructions in the memory 530 to execute the simulation calculation method, which includes: receiving a calculation instruction, wherein the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation; If it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0156] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0157] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can perform the simulation calculation method provided by the above methods, the method comprising: Get two raw values ​​for high-precision calculations; In the case where the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0158] Alternatively, a computer can execute the simulation calculation method provided by the above methods, which method includes: receiving a calculation instruction, wherein the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation; If it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0159] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the simulation calculation method provided by the above methods, the method comprising: Get two raw values ​​for high-precision calculations; In the case where the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0160] Alternatively, when the computer program is executed by a processor, the computer program is implemented to perform the simulation calculation method provided by the above methods, the method comprising: receiving a calculation instruction, wherein the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation; If it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

[0161] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A simulation calculation method, characterized in that: include: Get two raw values ​​for high-precision calculations; In the case where the original value is a high-precision value, the high-precision value is converted into two low-precision values, and the high-precision calculation is split into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

2. The simulation calculation method according to claim 1, characterized in that: The converting the high-precision value into two low-precision values ​​comprises: The high-precision value is subjected to precision reduction processing to obtain a first low-precision value, and the difference between the high-precision value and the one low-precision value is used as a second low-precision value.

3. The simulation calculation method according to claim 2, characterized in that: In the case where the high-precision calculation is the addition of two high-precision numerical values, splitting the high-precision calculation into at least two calculation items includes: Splitting the addition of the two high-precision values ​​into four calculation items to be performed sequentially; The four sequentially executed calculation items include adding the first low-precision values ​​of each of the two high-precision values ​​to obtain a first value, adding the second low-precision values ​​of each of the two high-precision values ​​to obtain a second value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the first low-precision value of the second value, adding the first low-precision value of the first value and the second low-precision value of the first value to obtain an updated first value, and updating the second low-precision value of the first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value, and adding the first low-precision value of the updated first value to the sum of the second low-precision value of the first value and the second low-precision value of the second value.

4. The simulation calculation method according to claim 2, characterized in that: In the case where the high-precision calculation is the multiplication of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the multiplication of the two high-precision values ​​into the sum of three calculation items; The three calculation items include multiplying the first low-precision values ​​of each of the two high-precision values, multiplying the first low-precision value of one high-precision value by the second low-precision value of another high-precision value, and multiplying the second low-precision value of another high-precision value by the first low-precision value of another high-precision value.

5. The simulation calculation method according to claim 2, characterized in that: In the case where the high-precision calculation is the division of two high-precision values, splitting the high-precision calculation into at least two calculation items includes: Splitting the division of the two high-precision values ​​into five calculation items to be performed sequentially; The five sequentially executed calculation items include dividing the first low-precision values ​​of two high-precision values ​​to obtain a first value, multiplying a high-precision value by the first value to obtain a second value, subtracting another high-precision value from the second value to obtain a third value, multiplying the first low-precision value of the third value by the reciprocal of the first low-precision value of the high-precision value to obtain a fourth value, and adding the two first values ​​to the fourth value.

6. The simulation calculation method according to any one of claims 1 to 5, characterized in that: In the case where the calculation item includes addition, the calculation of each calculation item to obtain an approximate value and an error value of each calculation item includes: Adding two low-precision values ​​involved in the addition to obtain an approximate value of the addition; The approximate value of the addition and the two low-precision values ​​participating in the addition are used to determine the participating values ​​of the two low-precision values ​​in the addition; An error value of the addition is determined based on the two low-precision values ​​and the participation values ​​of the two low-precision values ​​in the addition.

7. The simulation calculation method according to any one of claims 1 to 5, characterized in that: In the case where the calculation item includes multiplication, the calculation of each calculation item to obtain an approximate value and an error value of each calculation item includes: Splitting two low-precision data involved in the multiplication into high-order terms and low-order terms respectively; Taking the product of the high-order terms of the two low-precision data as an approximate value of the multiplication; The product of the high-order term and the low-order term of the two low-precision data and the product of the low-order term of the two low-precision data are used as error values ​​of the multiplication.

8. The simulation calculation method according to any one of claims 1 to 5, characterized in that: Also includes: In the case where the original numerical value is low-precision data, the high-precision calculation is used as the calculation item.

9. A simulation calculation method, characterized in that: include: receiving a calculation instruction, wherein the calculation instruction includes a high-precision calculation and two original numerical values ​​used for the high-precision calculation; If it is determined that the local computer does not support the high-precision calculation and the original value is a high-precision value, convert the high-precision value into two low-precision values, and split the high-precision calculation into at least two calculation items, each of which is implemented by two low-precision values; Calculate each calculation item to obtain the approximate value and error value of each calculation item; Based on the approximate value and the error value of each calculation item, a calculation result simulating the high-precision calculation is determined.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the simulation calculation method according to any one of claims 1 to 9 is implemented.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the simulation calculation method according to any one of claims 1 to 9 is implemented.