Operation Method, Device, Equipment and Medium for Coordinates in Artificial Intelligence Operators
Through the main control processor, the target coordinate operation parameters are provided, and the artificial intelligence chip performs simple calculations with high bit width, solving the problem of low efficiency of integer division in the artificial intelligence operator, improving performance and expanding applicable scenarios.
Patent Information
- Application Number
- CN202410956425.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2044-07-16
AI Technical Summary
Integer division in artificial intelligence operators is inefficient, poor performance, and limited applicable scenarios. The existing technology requires a large number of simple instructions to simulate integer division operations, resulting in cumbersome and complex coordinate operation process.
The front-end main control processor provides target coordinate operation parameters, and the artificial intelligence chip performs preset simple operations with high bit width, combining the heterogeneous framework of the main control processor and the artificial intelligence chip to simplify the coordinate operation process and quickly and accurately determine the coordinate operation results.
The operator coordinate operation time is shortened, the performance of artificial intelligence operators is improved, the applicable scenarios of operator coordinate operations are expanded, and the need to run a large number of instructions in artificial intelligence chips is reduced.
Smart Images

Figure CN118819467B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular, to a method, device, equipment and medium for coordinate operation in an artificial intelligence operator. Background Art
[0002] In artificial intelligence operators, frequent coordinate operations are usually involved, and coordinate operations usually require integer division and modulo operations on relevant data. Considering that although artificial intelligence chips support integer division operations, they cannot directly perform integer division operations through a simple instruction, but need a large number of other simple instructions to simulate integer division operations. The operator coordinate operation process is cumbersome and complex, and the entire coordinate operation process can only be implemented in artificial intelligence chips, resulting in very low efficiency of operator integer division, poor performance of artificial intelligence operators, and limited applicable scenarios for operator coordinate operations. Summary of the Invention
[0003] The present invention provides a method, device, equipment and medium for coordinate operation in an artificial intelligence operator, which is used to solve the defects that the efficiency of operator integer division in existing artificial intelligence operators is very low, the performance of artificial intelligence operators is poor, and the applicable scenarios of operator coordinate operations are limited. It greatly reduces the operator coordinate operation time, improves the performance of artificial intelligence operators, and at the same time expands the applicable scenarios of operator coordinate operations in the heterogeneous framework scenario of interaction between the front-end main control processor and the back-end artificial intelligence chip.
[0004] The present invention provides a method for coordinate operation in an artificial intelligence operator, which is applied to an artificial intelligence chip. The method includes the following steps.
[0005] In response to an operator coordinate operation instruction, obtain different target coordinate operation parameters after preprocessing of the target divisor in the coordinate operation of the artificial intelligence operator; each of the target coordinate operation parameters is provided by the main control processor; perform a preset simple operation with a high bit width based on each of the target coordinate operation parameters, and determine the coordinate operation result of the artificial intelligence operator based on the operation result.
[0006] According to the method for coordinate operation in an artificial intelligence operator provided by the present invention, the performing a preset simple operation with a high bit width based on each of the target coordinate operation parameters includes: when each of the target coordinate operation parameters includes a target coordinate rounding operation parameter and a target coordinate subtraction operation parameter, performing an integer multiplication operation with a preset number of bits of a high bit width on the target dividend corresponding to the target divisor and the target coordinate rounding operation parameter.
[0007] According to an operation method for coordinates in an artificial intelligence operator provided by the present invention, determining the coordinate operation result of the artificial intelligence operator based on the operation result includes: determining the quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter; performing a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain the remainder operation result generated by the coordinate operation in the artificial intelligence operator, and determining the quotient operation result and the remainder operation result as the coordinate operation result.
[0008] According to an operation method for coordinates in an artificial intelligence operator provided by the present invention, determining the quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter includes: shifting the integer multiplication operation result to the right by a preset number of bits to obtain a first right-shifted result; using the target coordinate subtraction operation parameter as the number of bits for right-shifting, and performing a right-shift operation on the first right-shifted result to obtain a second right-shifted result, and determining the second right-shifted result as the quotient operation result.
[0009] According to an operation method for coordinates in an artificial intelligence operator provided by the present invention, performing a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain the remainder operation result generated by the coordinate operation in the artificial intelligence operator includes: multiplying the target divisor by the quotient operation result; subtracting the target dividend from the multiplication result, and determining the subtraction result as the remainder operation result.
[0010] According to an operation method for coordinates in an artificial intelligence operator provided by the present invention, obtaining different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the artificial intelligence operator in response to an operator coordinate operation instruction includes: in response to the operator coordinate operation instruction, obtaining the different target coordinate operation parameters based on the target divisor carried in the operator coordinate operation instruction and the mapping relationship between the divisor and different coordinate operation parameters; the mapping relationship is established based on different coordinate operation parameters determined by the main control processor through preprocessing for different divisors in the artificial intelligence operator respectively.
[0011] According to an operation method of coordinates in an artificial intelligence operator provided by the present invention, the main control processor is configured to perform the following steps for each divisor in the artificial intelligence operator: determine an intermediate coordinate operation parameter corresponding to the divisor based on a logarithmic operation result of a first preset constant and the divisor; determine a power operation result corresponding to the intermediate coordinate operation parameter, and perform a division operation based on the power operation result and the divisor; perform a rounding operation on the division operation result to obtain a coordinate rounding operation parameter corresponding to the divisor; perform a subtraction operation on the intermediate coordinate operation parameter and a second preset constant, and determine the subtraction operation result as a coordinate subtraction operation parameter corresponding to the divisor.
[0012] The present invention also provides an operation device for coordinates in an artificial intelligence operator, which is applied to an artificial intelligence chip, and the device includes the following units.
[0013] A parameter acquisition unit, configured to obtain different target coordinate operation parameters after preprocessing of a target divisor in the coordinate operation of an artificial intelligence operator in response to an operator coordinate operation instruction; each of the target coordinate operation parameters is provided by the main control processor; a coordinate operation unit, configured to perform a preset simple operation with a high bit width based on each of the target coordinate operation parameters, and determine a coordinate operation result of the artificial intelligence operator based on the operation result.
[0014] The present invention also provides an electronic device, including a main control processor and an artificial intelligence chip connected in a heterogeneous framework form, where the artificial intelligence chip is configured to obtain different target coordinate operation parameters after preprocessing of a target divisor in the coordinate operation of an artificial intelligence operator in response to an operator coordinate operation instruction; perform a preset simple operation with a high bit width based on each of the target coordinate operation parameters, and determine a coordinate operation result of the artificial intelligence operator based on the operation result; the main control processor is configured to provide each of the target coordinate operation parameters to the artificial intelligence chip.
[0015] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the operation method of coordinates in an artificial intelligence operator as described in any one of the above.
[0016] The present invention provides a method, apparatus, device, and medium for coordinate operations in an artificial intelligence operator. In the method for coordinate operations in the artificial intelligence operator, when the artificial intelligence chip responds to an operator coordinate operation instruction, it first obtains different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the artificial intelligence operator, and then further performs a preset simple operation with a high bit width based on each target coordinate operation parameter, and determines the coordinate operation result of the artificial intelligence operator based on the operation result. Since each target coordinate operation parameter corresponding to the target divisor is provided by the main control processor, the coordinate operation result of the artificial intelligence operator can be quickly and accurately determined by the main control processor at the front end providing each target coordinate operation parameter for the number of rows and / or columns of the current matrix, and the artificial intelligence chip performs simple operations related to coordinates. The entire coordinate operation process is simple and easy to implement. It is neither necessary to run a large number of instructions in the artificial intelligence chip, nor to use the main control controller at the front end to assist the artificial intelligence operator at the back end to calculate the operator coordinates, rather than being limited to a single scenario of the artificial intelligence chip. This greatly reduces the operator coordinate operation time, improves the performance of the artificial intelligence operator, and at the same time, the heterogeneous framework scenario of the interaction between the main control processor at the front end and the artificial intelligence chip at the back end also expands the applicable scenarios of the operator coordinate operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0018] Figure 1 It is a flowchart showing the method for coordinate operations in the artificial intelligence operator provided by the present invention.
[0019] Figure 2 It is a schematic diagram comparing the flowcharts of the existing method and the method of the present invention provided by the present invention.
[0020] Figure 3 It is a schematic diagram showing the structure of the device for coordinate operations in the artificial intelligence operator provided by the present invention.
[0021] Figure 4 It is a schematic diagram showing the structure of the electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Apparently, the described embodiments are part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without making creative efforts fall within the scope of protection of the present invention.
[0023] In the embodiments of the present invention, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B may be singular or plural. In the written description of the present invention, the character " / " generally represents an "or" relationship between the associated objects before and after. In addition, it should be noted that the serial numbers assigned to the objects described in the present invention itself, such as "first", "second", etc., are only used to distinguish the described objects and do not have any sequential or technical meaning.
[0024] In artificial intelligence operators, frequent coordinate operations are usually involved. Coordinate operations usually require integer division and modulo operations on relevant data. Accelerating the relevant coordinate operation process can improve the training efficiency and inference efficiency of the artificial intelligence model. Considering that although the artificial intelligence chip supports integer division operations, it cannot directly perform integer division operations through a simple instruction. Therefore, in existing artificial intelligence chips, the operator coordinates are usually calculated by running a large number of other simple instructions to simulate integer division operations. For example, when using the switch function to simulate the division operation, a large number of simple instructions need to be executed. The operator coordinate operation process is cumbersome and complex, and the entire coordinate operation process can only be implemented in the artificial intelligence chip, resulting in very low operator integer division efficiency. At the same time, the performance of the artificial intelligence operator is poor, and the applicable scenarios of the operator coordinate operation are limited.
[0025] To solve the above technical problems, the present invention provides a method, device, equipment, and medium for coordinate operations in artificial intelligence operators. By providing each target coordinate operation parameter for the number of rows and / or columns of the current matrix by the front-end main control processor, and performing simple operations related to coordinates in the artificial intelligence chip, the coordinate operation result of the artificial intelligence operator can be quickly and accurately determined. The entire coordinate operation process is simple and easy to implement, without the need to run a large number of instructions in the artificial intelligence chip. At the same time, the front-end main control controller can be used to assist the back-end artificial intelligence operator in calculating the operator coordinates, rather than being limited to a single scenario of the artificial intelligence chip. This greatly reduces the operator coordinate operation time, improves the performance of the artificial intelligence operator, and at the same time expands the applicable scenarios of the operator coordinate operation by combining the heterogeneous framework scenario of the interaction between the front-end main control processor and the back-end artificial intelligence chip.
[0026] The following combines Figures 1 to 4 to describe the operation method, device, equipment and medium of coordinates in the artificial intelligence operator of the present invention. The execution subject of the operation method of coordinates in the artificial intelligence operator can be an artificial intelligence chip at the backend. This artificial intelligence chip is also called an artificial intelligence accelerator or a computing method, that is, a module specifically used to process a large number of computing tasks in artificial intelligence applications, such as GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural network Processing Unit), DPU (Deeplearning Processing Unit), APU (Accelerated Processing Unit), and GPGPU (General-Purpose computing on Graphics Processing Unit), etc. Further, the execution subject of the operation method of coordinates in the artificial intelligence operator can also be applied to the operation device of coordinates in the artificial intelligence operator provided in the artificial intelligence chip. The operation device of coordinates in the artificial intelligence operator can be implemented by software, hardware, or a combination of both. The following takes the execution subject of the operation method of coordinates in the artificial intelligence operator as an artificial intelligence chip as an example to describe the operation method of coordinates in the artificial intelligence operator.
[0027] Referring to Figure 1 , which is a schematic flowchart of the operation method of coordinates in the artificial intelligence operator provided by the present invention. As Figure 1 shown, the operation method of coordinates in the artificial intelligence operator includes step 110 and step 120.
[0028] Step 110: In response to the operator coordinate operation instruction, obtain different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the artificial intelligence operator; each target coordinate operation parameter is provided by the main control processor.
[0029] Among them, the target divisor can be the number of rows and / or columns of the current matrix processed by the artificial intelligence operator.
[0030] The main control processor can be a processor with at least other operation functions such as logarithmic operation function and division function, such as a main control chip, a main control module, a Central Processing Unit (CPU), an Advanced RISC Machine (ARM) processor, and an X86 processor, etc.
[0031] The operator coordinate instruction can be an instruction automatically generated when a certain element in the current matrix is read, or it can also be an instruction automatically generated when the artificial intelligence operator runs to the current matrix and needs to save a specific data during the implementation of its algorithm logic.
[0032] The number of target divisors is the same as and in one-to-one correspondence with the number of preprocessing times.
[0033] Each target divisor is preprocessed to obtain a set of target coordinate operation parameters respectively, and the preprocessing process for each target divisor runs in the front-end main control processor, aiming to simplify the division operation process in the artificial intelligence chip and assist the artificial intelligence chip to quickly and accurately calculate the coordinate result.
[0034] Each preprocessing can include but is not limited to logarithmic operation, division operation, rounding operation, addition operation, and subtraction operation.
[0035] Specifically, when the artificial intelligence chip responds to the operator coordinate operation instruction, it first obtains different target coordinate operation parameters after preprocessing of the target divisor in the coordinate operation of the artificial intelligence operator. The obtaining method can directly read a set of target coordinate operation parameters corresponding to the target divisor from its memory when a set of coordinate operation parameters corresponding to different divisors provided by the main control processor are pre-stored in the memory of the artificial intelligence chip; or, it can also call a set of target coordinate operation parameters corresponding to the target divisor from the cloud server when a set of coordinate operation parameters corresponding to different divisors provided by the main control processor are pre-stored in the cloud server; or, the artificial intelligence chip can also feedback the parameter obtaining instruction carrying the target divisor to the front-end main control processor through communication transmission or copying, so that the main control processor preprocesses the target divisor to obtain a corresponding set of target coordinate operation parameters and sends this set of target coordinate operation parameters to the artificial intelligence chip. The present invention does not make specific limitations on this.
[0036] Step 120: Perform a preset simple operation with a high width based on each target coordinate operation parameter, and determine the coordinate operation result of the artificial intelligence operator based on the operation result.
[0037] Among them, the preset simple operation with a high width can include multiplying the target dividend participating in the coordinate operation by a specified target coordinate operation parameter, such as performing a 64-bit integer multiplication operation.
[0038] Specifically, for each target divisor in the artificial intelligence information, a simple operation such as a high-width integer division operation and a modulo operation can be performed on a set of target coordinate operation parameters corresponding to the target divisor, so as to replace the existing low-width integer division operation, thereby obtaining the coordinate operation result of the artificial intelligence operator, that is, the two-dimensional coordinates of the artificial intelligence operator. Here, the low-width integer division operation only directly participates in the integer division operation of the dividend and the divisor, such as performing a division operation on the low 32 bits.
[0039] It should be noted that the processing object of the artificial intelligence operator is usually a matrix, and the divisor is usually relatively fixed during the coordinate calculation of the artificial intelligence operator, such as the number of rows and / or columns of the matrix. Considering that the divisor is usually an integer, by performing simple operations such as high-width integer division on a corresponding set of target coordinate operation parameters, the truncation of the high-width significant bit data in the operation result can be avoided.
[0040] In addition, it should be noted that although the division operation can be realized by shifting to the right when the divisor is 2, 4, 8, 16, etc. or other integer powers of 2 during the coordinate operation of the artificial intelligence operator, when the divisor is an integer such as 3, 5, 11, etc. that is not an integer power of 2, the division operation cannot be performed by shifting to the right. Therefore, the present invention uses the main control processor to provide a set of target coordinate operation parameters corresponding to the target divisor for the artificial intelligence chip, so that the artificial intelligence chip performs simple operations such as high-width integer multiplication on this set of target coordinate operation parameters, thereby obtaining the coordinate operation result of the artificial intelligence operator.
[0041] In the coordinate operation method of the artificial intelligence operator provided by the present invention, when the artificial intelligence chip responds to the operator coordinate operation instruction, it first obtains different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the artificial intelligence operator, and then further performs a high-width preset simple operation on each target coordinate operation parameter, and determines the coordinate operation result of the artificial intelligence operator based on the operation result. Since each target coordinate operation parameter corresponding to the target divisor is provided by the main control processor, the coordinate operation result of the artificial intelligence operator can be quickly and accurately determined by the artificial intelligence chip executing simple operations related to coordinates through the target coordinate operation parameters provided by the front-end main control processor for the number of rows and / or columns of the current matrix. The entire coordinate operation process is simple and easy to implement. It not only does not require a large number of instructions to run in the artificial intelligence chip, but also can use the front-end main control controller to assist the back-end artificial intelligence operator in calculating the operator coordinates, rather than being limited to a single scenario of the artificial intelligence chip. This greatly reduces the operator coordinate operation time, improves the performance of the artificial intelligence operator, and at the same time, the heterogeneous framework scenario of the interaction between the front-end main control processor and the back-end artificial intelligence chip also expands the applicable scenario of the operator coordinate operation.
[0042] Based on the aboveFigure 1 For the operation method of coordinates in the artificial intelligence operator shown, in an exemplary embodiment, in step 120, the artificial intelligence chip at the backend performs a preset simple operation with a high width based on each target coordinate operation parameter, and its specific implementation process includes:
[0043] When each target coordinate operation parameter includes a target coordinate rounding operation parameter and a target coordinate subtraction operation parameter, an integer multiplication operation with a high width of preset bits is performed on the target dividend corresponding to the target divisor and the target coordinate rounding operation parameter.
[0044] Among them, the number of target dividends corresponding to the target divisor can be 1 or multiple. Each target dividend can be the dividend corresponding to the artificial intelligence operator when performing a division operation on the current matrix during the operation of its algorithm logic.
[0045] Specifically, for the case where the main control processor preprocesses the target divisor to obtain the target coordinate rounding operation parameter and the target coordinate subtraction operation parameter the artificial intelligence chip first determines at least 1 target dividend corresponding to the target divisor. When 1 of the target dividends is it is possible to perform an integer multiplication operation with a high width on the target dividend being and the target coordinate rounding operation parameter
[0046] Exemplarily, when the target divisor is a 32-bit signed integer, multiplying the target dividend being and the target coordinate rounding operation parameter is an integer multiplication operation with a high width of 64 bits.
[0047] Based on the operation method of coordinates in the artificial intelligence operator shown above Figure 1 in an exemplary embodiment, the artificial intelligence chip at the backend determines the coordinate operation result of the artificial intelligence operator based on the operation result, and its specific implementation process includes:
[0048] First, based on the integer multiplier operation result and the target coordinate subtraction operation parameter, determine the quotient operation result generated by the coordinate operation in the artificial intelligence operator; then, perform a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain the remainder operation result generated by the coordinate operation in the artificial intelligence operator, and determine the quotient operation result and the remainder operation result as the coordinate operation result.
[0049] Specifically, after the artificial intelligence chip performs an integer multiplication operation with a high-bit-width preset bit on the target dividend corresponding to the target divisor and the rounding operation parameter of the target coordinate, a division operation can be performed on the obtained integer multiplication operation result and the target coordinate subtraction operation parameter by shifting to the right, so as to obtain the quotient operation result generated by the coordinate operation in the artificial intelligence operator. At this time, by combining the remainder operation result obtained after performing a remainder operation on the target dividend, the target divisor, and the quotient operation result, the two-dimensional coordinate containing the quotient operation result and the remainder operation result is determined as the coordinate operation result.
[0050] Based on the above Figure 1 shown coordinate operation method in the artificial intelligence operator, in an exemplary embodiment, the artificial intelligence chip at the backend determines the quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter. The specific implementation process includes:
[0051] First, shift the integer multiplication operation result to the right by a preset number of bits to obtain a first right shift result; then, use the target coordinate subtraction operation parameter as the number of bits for right shift, and perform a right shift operation on the first right shift result to obtain a second right shift result, and determine the second right shift result as the quotient operation result.
[0052] Specifically, the artificial intelligence chip at the backend can and the rounding operation parameter of the target coordinate After performing a high-bit-width integer multiplication operation, the integer multiplication operation result can be first shifted to the right for the first time, and then the first shift result can be further shifted to the right for the second time, and the result obtained after the second right shift is determined as the quotient operation result generated by the coordinate operation in the artificial intelligence operator.
[0053] Exemplarily, the quotient operation result generated by the coordinate operation in the artificial intelligence operator can be calculated by formula (1) .
[0054] (1).
[0055] In formula (1), represents a right shift, and the target divisor After preprocessing, the rounding operation parameter of the target coordinate and the target coordinate subtraction operation parameter ; represents the preset number of bits for right shift required for shifting, and its value can be the same as the value of the target divisor; represents the first right shift result; represents the second right shift result, that is, the quotient operation result .
[0056] Exemplarily, when the target divisor is a 32-bit signed integer, the right shift by a preset number of bits can be 32.
[0057] It should be noted that for the first right shift result corresponding to the integer multiplication operation result, it can also be directly obtained through the high-order register when the integer multiplication operation result is a 64-bit calculation result and the 64-bit calculation result is stored in two consecutive 32-bit registers, with the low-order register storing the low 32 bits of the result and the high-order register storing the high 32 bits of the result.
[0058] Based on the above Figure 1 In one exemplary embodiment of the operation method of coordinates in the artificial intelligence operator shown above, the artificial intelligence chip at the backend performs a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain the remainder operation result generated by the coordinate operation in the artificial intelligence operator. The specific implementation process includes:
[0059] First, multiply the target divisor by the quotient operation result; then, subtract the multiplication operation result from the target dividend, and determine the subtraction operation result as the remainder operation result.
[0060] Specifically, the artificial intelligence chip at the backend determines the subtraction operation result of subtracting the multiplication result from the target dividend after multiplying the target divisor by the quotient operation result as the remainder operation result generated by the coordinate operation in the artificial intelligence operator.
[0061] Exemplarily, the remainder operation result generated by the coordinate operation in the artificial intelligence operator can be calculated by formula (2) .
[0062] (2).
[0063] In formula (2), represents the quotient operation result calculated by the foregoing formula (1), represents the target dividend corresponding to the target divisor corresponding to.
[0064] It should be noted that when the number of target dividends corresponding to the target divisor is at least two, two-dimensional coordinates each containing a corresponding quotient operation result and a corresponding remainder operation result can be calculated according to formula (1) and formula (2), that is, the number of two-dimensional coordinates is the same as the number of target dividends and they are in one-to-one correspondence.
[0065] Based on the above Figure 1 In one exemplary embodiment of the operation method of coordinates in the artificial intelligence operator shown above, the specific implementation process of step 110 may include:
[0066] In response to an operator coordinate operation instruction, different target coordinate operation parameters are obtained based on the target divisor carried in the operator coordinate operation instruction and the mapping relationship between the divisor and different coordinate operation parameters; the mapping relationship is established based on different coordinate operation parameters determined by the main control processor through preprocessing for different divisors in the artificial intelligence operator respectively.
[0067] Specifically, when the artificial intelligence operator needs to read an element in the current matrix during the process of running its algorithm logic, an operator coordinate operation instruction carrying the number of rows and / or columns of the current matrix can be automatically generated, that is, the number of rows and / or columns of the current matrix can be used as the target divisor.
[0068] At this time, the artificial intelligence chip can call the mapping relationship between the divisor and different coordinate operation parameters pre-determined and established by the main control processor. This mapping relationship can be stored in the memory of the main control processor and obtained through the information interaction between the artificial intelligence chip and the main control processor. For example, the artificial intelligence chip requests the main control processor to obtain each target coordinate operation parameter corresponding to the target divisor, and then receives the feedback of the above-mentioned each target coordinate operation parameter from the main control processor; alternatively, the above mapping relationship can also be established by the main control processor and then communicated or copied to the memory of the artificial intelligence chip for storage, so that the artificial intelligence chip can obtain the above-mentioned each target coordinate operation parameter by searching for the above mapping relationship from its own memory based on the target divisor.
[0069] Or, different coordinate operation parameters determined by the main control processor through preprocessing for different divisors in the artificial intelligence operator respectively can be obtained first, and then the main control processor packs the different coordinate operation parameters corresponding to each divisor and communicates or copies them to the memory of the artificial intelligence chip. The artificial intelligence chip establishes the above mapping relationship based on this and stores it in its own memory or sends it to the cloud for storage.
[0070] It should be noted that since the integer division operation of the artificial intelligence operator usually uses the number of rows and / or columns of the matrix as the divisor, therefore, in the main control processor, for all matrices involved in the integer division operation of the artificial intelligence operator, the number of rows and / or columns of each matrix can be used as the divisor to calculate the corresponding different coordinate operation parameters respectively. When the same number of rows or the same number of columns are encountered during the calculation process, they can be ignored; then the mapping relationship between the divisor and different coordinate operation parameters is established; further, when a new matrix appears and the number of rows and / or columns of the new matrix do not exist in the above mapping relationship, the corresponding different coordinate operation parameters can be recalculated based on the number of rows and / or columns of the new matrix, and the above mapping relationship is updated accordingly.
[0071] In addition, it should be noted that when the above target divisor does not exist in the above mapping relationship, the artificial intelligence chip first generates a parameter request instruction carrying this target divisor and sends the parameter request instruction to the main control processor to request the main control processor to calculate various different target coordinate operation parameters corresponding to this target divisor. Then, while performing subsequent corresponding two-dimensional coordinate operations based on the various different target coordinate operation parameters fed back by the main control processor, the above mapping relationship is updated.
[0072] Based on the above Figure 1 shown operation method of coordinates in the artificial intelligence operator, in an exemplary embodiment, it should be noted for the main control processor that:
[0073] The main control processor is used to perform the following steps for each divisor in the artificial intelligence operator: First, based on the logarithmic operation result of the first preset constant and the divisor, determine the intermediate coordinate operation parameter corresponding to the divisor; then determine the power operation result corresponding to the intermediate coordinate operation parameter, and perform a division operation based on the power operation result and the divisor; then, after performing a rounding operation on the division operation result, obtain the coordinate rounding operation parameter corresponding to the divisor; finally, perform a subtraction operation on the intermediate coordinate operation parameter and the second preset constant, and determine the subtraction operation result as the coordinate subtraction operation parameter corresponding to the divisor.
[0074] Specifically, for the main control processor, it can respectively use the number of rows and / or columns of each matrix involved in the artificial intelligence operator as the divisor to calculate the corresponding coordinate rounding operation parameter and coordinate subtraction operation parameter; until all matrices are traversed, so as to obtain the coordinate rounding operation parameter and coordinate subtraction operation parameter corresponding to each divisor in the artificial intelligence operator; when encountering the same number of rows or the same number of columns during the calculation process, it can be ignored.
[0075] For each divisor of the artificial intelligence operator, by adding the logarithmic operation result of the first preset constant and the corresponding divisor, determine the intermediate coordinate operation parameter corresponding to the corresponding divisor.
[0076] Exemplarily, for a certain divisor of the artificial intelligence operator , the intermediate coordinate operation parameter corresponding to the divisor can be calculated through Equation (3). .
[0077] (3).
[0078] In Equation (3), represents the first preset constant, represents the logarithmic operation with base 2 for the divisor , represents the ceiling operation.
[0079] For each divisor of the artificial intelligence operator, by first performing a power operation on the intermediate coordinate operation parameter corresponding to the corresponding divisor, then performing a division operation based on the result of the power operation and the corresponding divisor, and finally performing a rounding operation on the result of the division operation, the coordinate rounding operation parameter corresponding to the corresponding divisor is obtained.
[0080] Exemplarily, for a certain divisor of the artificial intelligence operator , the divisor can be calculated by Equation (4) The corresponding coordinate rounding operation parameter .
[0081] (4).
[0082] In Equation (4), represents the power operation of 2 times, represents the intermediate coordinate operation parameter calculated using Equation (3), represents the ceiling operation.
[0083] For each divisor of the artificial intelligence operator, by subtracting the corresponding intermediate coordinate operation parameter from the second preset constant, the coordinate subtraction operation parameter corresponding to the corresponding divisor is determined.
[0084] Exemplarily, for a certain divisor of the artificial intelligence operator The corresponding intermediate coordinate operation parameter , the divisor can be calculated by Equation (5) The corresponding coordinate rounding operation parameter .
[0085] (5).
[0086] In Equation (5), represents the intermediate coordinate operation parameter calculated using Equation (3), represents the second preset constant.
[0087] It should be noted that for the first preset constant in Equation (3), its specific value can be determined by the maximum value that can be represented by the data type of the divisor ; for example, when the divisor is a 32-bit signed integer, the maximum value it can represent is 2 31 -1, and at this time, the value of the first preset constant can be determined to be 31; or, when the divisor is a 32-bit unsigned integer, the maximum value it can represent is 2 32-1, and at this time, the first preset constant can also be determined takes the value of 32.
[0088] For the second preset constant in formula (5) , its specific value can be the same as the right shift preset number of bits in the foregoing formula (1) .
[0089] Exemplarily, referring to Figure 2 the schematic diagram comparing the processes of the existing method and the method of the present invention shown, in Figure 2 , when the main control processor is specifically a central processing unit, the method process in the left half containing the central processing unit and the artificial intelligence chip belongs to the method of the present invention, and the method process in the right half containing only the artificial intelligence chip belongs to the existing method.
[0090] From Figure 2 it can be seen that when the target divisor is , the target divisor can be preprocessed according to the foregoing formulas (3) to (5) to obtain the corresponding target coordinate rounding operation parameter and the target coordinate subtraction operation parameter , and then the target coordinate rounding operation parameter and the target coordinate subtraction operation parameter are communicated and transmitted or copied to the memory of the artificial intelligence chip, and the artificial intelligence chip is based on the target divisor corresponding target dividend , the target coordinate rounding operation parameter and the target coordinate subtraction operation parameter to perform other operations. Here, the number of other operations is the same as the number of target dividends. That is, when the target dividend corresponding target dividend specifically includes the dividend and the dividend , respectively based on the dividend , the target coordinate rounding operation parameter and the target coordinate subtraction operation parameter perform high-width integer division and modulo operations, and based on the dividend , the target coordinate rounding operation parameter and the target coordinate subtraction operation parameter perform high-width integer division and modulo operations; thus obtaining two linear coordinates.
[0091] Through Figure 2As can be understood from the existing method flowchart of the right half shown, every time the artificial intelligence chip of the existing method needs to perform integer division and modulo-related calculations, a large number of simple instructions need to be executed to obtain the corresponding coordinate calculation results.
[0092] By comparison Figure 2 As can be seen from the method of the present invention and the existing method shown, compared with the existing method, although the preprocessing process in the front-end central processing unit of the present invention is complex, it is only calculated once; while in the coordinate calculation of the artificial intelligence chip, division calculations need to be performed multiple times. Therefore, using the method of the present invention can effectively reduce the time consumed by the operator in the coordinate calculation part of the entire calculation process, greatly reduce the time-consuming of the operator's coordinate calculation part, and improve the operator performance.
[0093] The operation device for coordinates in the artificial intelligence operator provided by the present invention will be described below. The operation device for coordinates in the artificial intelligence operator described below can be mutually corresponding and referred to the operation method for coordinates in the artificial intelligence operator described above.
[0094] Referring to Figure 3 , which is a schematic structural diagram of the operation device for coordinates in the artificial intelligence operator provided by the present invention. As Figure 3 shown, the operation device 300 for coordinates in the artificial intelligence operator is applied to an artificial intelligence chip and includes: a parameter acquisition unit 310 and a coordinate operation unit 320.
[0095] The parameter acquisition unit 310 is configured to obtain different target coordinate operation parameters after preprocessing of the target divisor in the coordinate operation of the artificial intelligence operator in response to an operator coordinate operation instruction; each target coordinate operation parameter is provided by the main control processor.
[0096] The coordinate operation unit 320 is configured to perform a preset simple operation with a high bit width based on each target coordinate operation parameter, and determine the coordinate operation result of the artificial intelligence operator based on the operation result.
[0097] Optionally, the coordinate operation unit 320 is specifically configured to perform an integer multiplication operation with a high bit width on the target dividend corresponding to the target divisor and the target coordinate rounding operation parameter when each target coordinate operation parameter includes a target coordinate rounding operation parameter and a target coordinate subtraction operation parameter.
[0098] Optionally, the coordinate operation unit 320 is specifically configured to determine the quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter; perform a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain the remainder operation result generated by the coordinate operation in the artificial intelligence operator, and determine the quotient operation result and the remainder operation result as the coordinate operation result.
[0099] Optionally, the coordinate operation unit 320 is specifically configured to right-shift the integer multiplication operation result by a preset number of bits to obtain a first right-shifted result; use the target coordinate subtraction operation parameter as the number of bits for right-shifting, perform a right-shifting operation on the first right-shifted result to obtain a second right-shifted result, and determine the second right-shifted result as the quotient operation result.
[0100] Optionally, the coordinate operation unit 320 is specifically configured to perform a multiplication operation on the target divisor and the quotient operation result; perform a subtraction operation on the target dividend and the multiplication operation result, and determine the subtraction operation result as the remainder operation result.
[0101] Optionally, the parameter acquisition unit 310 is specifically configured to, in response to an operator coordinate operation instruction, obtain different target coordinate operation parameters based on the target divisor carried in the operator coordinate operation instruction and the mapping relationship between the divisor and different coordinate operation parameters; the mapping relationship is established based on different coordinate operation parameters determined by the main control processor after preprocessing different divisors in the artificial intelligence operator respectively.
[0102] Optionally, the main control processor in the parameter acquisition unit 310 is specifically configured to perform the following steps for each divisor in the artificial intelligence operator: determine the intermediate coordinate operation parameter corresponding to the divisor based on the logarithmic operation result of the first preset constant and the divisor; determine the power operation result corresponding to the intermediate coordinate operation parameter, and perform a division operation based on the power operation result and the divisor; perform a rounding operation on the division operation result to obtain the coordinate rounding operation parameter corresponding to the divisor; perform a subtraction operation on the intermediate coordinate operation parameter and the second preset constant, and determine the subtraction operation result as the coordinate subtraction operation parameter corresponding to the divisor.
[0103] Figure 4 An example of the physical structure diagram of an electronic device is shown in Figure 4As shown in the figure, the electronic device may include: an Artificial Intelligence (AI) chip 410, a Communications Interface 420, a memory 430, a communication bus 440, and a main control processor connected to the AI chip 410 in a heterogeneous framework form. Among them, the AI chip 410, the communication interface 420, and the memory 430 complete communication with each other through the communication bus 440. The AI chip 410 can call the logical instructions in the memory 430 to execute the operation method of coordinates in the AI operator. The method includes: in response to the operator coordinate operation instruction, obtaining different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the AI operator; performing a preset simple operation with a high bit width based on each target coordinate operation parameter, and determining the coordinate operation result of the AI operator based on the operation result; the main control processor is used to provide each target coordinate operation parameter to the AI chip 410.
[0104] In addition, when the logical instructions in the above-mentioned memory 430 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0105] On the other hand, the present invention also provides a computer program product. The computer program product includes 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 execute the operation method of coordinates in the AI operator provided by the above-mentioned various methods. The method includes: in response to the operator coordinate operation instruction, obtaining different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the AI operator; each target coordinate operation parameter is provided by the main control processor; performing a preset simple operation with a high bit width based on each target coordinate operation parameter, and determining the coordinate operation result of the AI operator based on the operation result.
[0106] In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements an operation method for coordinates in the artificial intelligence operators provided by the above-mentioned various methods. The method includes: in response to an operator coordinate operation instruction, obtaining different target coordinate operation parameters after preprocessing the target divisor in the coordinate operation of the artificial intelligence operator; each target coordinate operation parameter is provided by the main control processor; performing a preset simple operation with a high bit width based on each target coordinate operation parameter, and determining the coordinate operation result of the artificial intelligence operator based on the operation result.
[0107] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative labor.
[0108] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disc, etc., and includes several instructions for causing 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 embodiments.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for calculating coordinates in an artificial intelligence operator, characterized in that, Applied to an artificial intelligence chip, the method includes: In response to an operator coordinate operation instruction, obtaining different target coordinate operation parameters after preprocessing of a target divisor in the coordinate operation of an artificial intelligence operator; each of the target coordinate operation parameters is provided by a main control processor; wherein, each target divisor is preprocessed to obtain a set of target coordinate operation parameters respectively; Performing a preset simple operation of high bit width based on each of the target coordinate operation parameters, and determining the coordinate operation result of the artificial intelligence operator based on the operation result.
2. The method for calculating coordinates in the artificial intelligence operator according to claim 1, characterized in that The performing a preset simple operation of high bit width based on each of the target coordinate operation parameters includes: When each of the target coordinate operation parameters includes a target coordinate rounding operation parameter and a target coordinate subtraction operation parameter, performing an integer multiplication operation of a preset number of bits of high bit width on a target dividend corresponding to the target divisor and the target coordinate rounding operation parameter.
3. The method for calculating coordinates in the artificial intelligence operator according to claim 2, wherein The determining the coordinate operation result of the artificial intelligence operator based on the operation result includes: Determining a quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter; Performing a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain a remainder operation result generated by the coordinate operation in the artificial intelligence operator, and determining the quotient operation result and the remainder operation result as the coordinate operation result.
4. The method for calculating coordinates in the artificial intelligence operator according to claim 3, characterized in that, The determining a quotient operation result generated by the coordinate operation in the artificial intelligence operator based on the integer multiplication operation result and the target coordinate subtraction operation parameter includes: Shifting the integer multiplication operation result to the right by a preset number of bits to obtain a first right shift result; Using the target coordinate subtraction operation parameter as the number of bits for right shift, performing a right shift operation on the first right shift result to obtain a second right shift result, and determining the second right shift result as the quotient operation result.
5. The method for calculating coordinates in the artificial intelligence operator according to claim 3, wherein The performing a remainder operation based on the quotient operation result, the target divisor, and the target dividend to obtain a remainder operation result generated by the coordinate operation in the artificial intelligence operator includes: Performing a multiplication operation on the target divisor and the quotient operation result; Performing a subtraction operation on the target dividend and the multiplication operation result, and determining the subtraction operation result as the remainder operation result.
6. The method for calculating coordinates in the artificial intelligence operator according to any one of claims 1 to 5, characterized in that, The obtaining different target coordinate operation parameters after preprocessing of a target divisor in the coordinate operation of an artificial intelligence operator in response to an operator coordinate operation instruction includes: In response to the operator coordinate operation instruction, based on the target divisor carried in the operator coordinate operation instruction and the mapping relationship between the divisor and different coordinate operation parameters, obtaining the different target coordinate operation parameters; the mapping relationship is established based on different coordinate operation parameters determined by the main control processor through preprocessing for different divisors in the artificial intelligence operator respectively.
7. The method for calculating coordinates in the artificial intelligence operator according to claim 6, characterized in that, The main control processor is used to execute the following steps for each divisor in the artificial intelligence operator: Based on the logarithmic operation result of a first preset constant and the divisor, determining an intermediate coordinate operation parameter corresponding to the divisor; Determine the power operation result corresponding to the intermediate coordinate operation parameter, and perform a division operation based on the power operation result and the divisor; After performing a rounding operation on the division operation result, obtain the coordinate rounding operation parameter corresponding to the divisor; Perform a subtraction operation on the intermediate coordinate operation parameter and a second preset constant, and determine the subtraction operation result as the coordinate subtraction operation parameter corresponding to the divisor.
8. An operation device for coordinates in an artificial intelligence operator, characterized in that, Applied to an artificial intelligence chip, the device includes: A parameter acquisition unit, configured to obtain different target coordinate operation parameters after preprocessing a target divisor in the coordinate operation of an artificial intelligence operator in response to an operator coordinate operation instruction; each of the target coordinate operation parameters is provided by a main control processor; wherein, each target divisor is preprocessed to obtain a set of target coordinate operation parameters respectively; A coordinate operation unit, configured to perform a preset simple operation operation with a high bit width based on each of the target coordinate operation parameters, and determine the coordinate operation result of the artificial intelligence operator based on the operation result.
9. An electronic device, characterized in that, Including a main control processor and an artificial intelligence chip connected in the form of a heterogeneous framework, the artificial intelligence chip is configured to obtain different target coordinate operation parameters after preprocessing a target divisor in the coordinate operation of an artificial intelligence operator in response to an operator coordinate operation instruction; perform a preset simple operation operation with a high bit width based on each of the target coordinate operation parameters, and determine the coordinate operation result of the artificial intelligence operator based on the operation result; the main control processor is configured to provide each of the target coordinate operation parameters to the artificial intelligence chip.
10. 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, it implements the method for operating coordinates in the artificial intelligence operator according to any one of claims 1 to 7.
Citation Information
Patent Citations
Interpolation method under network coordinate system based on artificial intelligence, storage medium and system
CN110007787A
Complex computing device and method, artificial intelligence chip and electronic equipment
CN111782580A