Data processing method, apparatus and system, and storage medium
By performing inverse transformation and precision processing on the triangle matrix in the triangle matrix equation, the problem of low resolution efficiency of triangle matrix equations in the prior art is solved, and more efficient data processing is achieved.
Patent Information
- Application Number
- PCT/CN2023/125947
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-30
- Filing Date
- 2023-10-23
- Publication Date
- 2025-03-06
AI Technical Summary
The existing triangular matrix equation solution method based on artificial intelligence chips cannot fully utilize the computing power of AI chips, resulting in low solution efficiency.
By inversely transforming the triangle matrix in the triangular matrix equation, an inverse triangle matrix is obtained, and the inverse triangle matrix and preset matrix are accurately processed according to the matrix calculation accuracy of the AI chip, which is converted into a matrix multiplication problem, and the calculation is performed using the matrix calculation ability of the AI chip.
It significantly improves the solution efficiency of triangular matrix equations, makes full use of the matrix computing capabilities of AI chips, and improves the efficiency of data processing.
Smart Images

Figure CN2023125947_06032025_PF_FP_ABST
Abstract
Description
Data processing method, device, system and storage medium Technical Field
[0001] The present application relates to the field of artificial intelligence chip technology, and in particular to a data processing method, device, system and storage medium. Background Art
[0002] Triangular matrix equations are widely used in diverse application fields, such as biocomputing, signal processing, statistics, and nuclear physics, playing a vital role in computational processes within these scientific fields. Due to the large number of triangular linear equations in these fields, the computational performance of solving triangular matrix equations has become a key concern within these fields.
[0003] In recent years, with the continuous advancement of science and technology and the continuous development of applications, data processing methods for triangular matrix equations based on artificial intelligence chips (AI chips) have been widely used. At present, the solution of triangular matrix equations based on AI chips mainly utilizes the vector computing capabilities of AI chips. However, this solution method cannot fully utilize the computing power of AI chips, resulting in low efficiency in solving triangular matrix equations. Therefore, how to fully utilize the computing power of AI chips to solve triangular matrix equations has become a technical problem that needs to be solved urgently.
[0004] Summary of the Invention
[0005] This application aims to solve at least one of the technical problems existing in the prior art. To this end, this application proposes a data processing method, device, system, and storage medium that can fully utilize the matrix computing capabilities of artificial intelligence chips to solve matrices, thereby significantly improving data processing efficiency.
[0006] The data processing method according to the first embodiment of the present application is applied to an artificial intelligence chip, wherein the artificial intelligence chip includes a matrix computing unit, including:
[0007] Obtaining a matrix to be solved, wherein the matrix to be solved, a triangular matrix, and a preset matrix construct an equation for a triangular matrix equation, wherein the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation;
[0008] Performing an inverse transformation on the triangular matrix to obtain an inverse triangular matrix;
[0009] According to the first floating-point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, the inverse triangular matrix and the preset matrix are precision-processed to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix;
[0010] The first matrix and the second matrix are input into the matrix calculation unit to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
[0011] According to the data processing method of the embodiment of the present application, there are at least the following beneficial effects: first, the matrix to be solved is obtained, wherein the matrix to be solved and the triangular matrix constitute a preset matrix; secondly, the triangular matrix is inversely transformed to obtain an inverse triangular matrix; thereafter, according to the first floating-point precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix, the inverse triangular matrix and the preset matrix are precision-processed to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix; finally, the first matrix and the second matrix are input into the matrix calculation unit to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved. The data processing method of the present application obtains an inverse triangular matrix by inverting the triangular matrix in the triangular matrix equation, and can convert the row-by-row solution problem of the vector represented by the triangular matrix equation into a matrix multiplication problem, so that the matrix computing capability of the artificial intelligence chip can be used for calculation, and finally the matrix to be solved represented by the matrix multiplication result is obtained. The matrix computing capability of AI chips is far stronger than their vector computing capability. Based on this, AI chips can significantly improve their utilization efficiency by performing matrix calculations, thereby significantly improving the data processing efficiency based on solving triangular matrix equations. Therefore, the data processing method of this application can fully utilize the matrix computing capability of AI chips to solve matrices, thereby significantly improving data processing efficiency.
[0012] According to some embodiments of the present application, before obtaining the matrix to be solved, the process includes:
[0013] Setting the preset matrix and the triangular matrix according to the problem to be solved;
[0014] A triangular matrix equation is constructed by the matrix to be solved, the triangular matrix, the preset matrix and the preset constants, wherein the triangular matrix equation is an equation, the multiplied matrix to be solved and the triangular matrix are located on one side of the equation, and the multiplied preset matrix and the preset constant are located on the other side of the equation.
[0015] According to some embodiments of the present application, the data processing method further includes:
[0016] Determine the initial matrix to be decomposed;
[0017] Divide the initial matrix into sub-matrices of equal length and width;
[0018] Starting from the submatrix with the first column from the left and the first row from the top, perform LU decomposition, panel decomposition, and triangular matrix solution on the submatrices on the diagonal to obtain the target matrix.
[0019] According to some embodiments of the present application, starting from the submatrix with the first column from the left and the first row from the top, the submatrix on the diagonal line is sequentially subjected to LU decomposition, panel decomposition, and triangular matrix solution to obtain a target matrix, including:
[0020] Step 400 , performing LU decomposition on the A11 submatrix with the first column from the left and the first row from the top to obtain an L11 matrix and a U11 matrix;
[0021] Step 410: Combine the U11 matrix and perform panel decomposition on all sub-matrices in the same column as the A11 sub-matrix to obtain L21 to Lm1 matrices, where m represents the number of rows of the initial matrix, and all sub-matrices do not include the A11 sub-matrix.
[0022] Step 420 , combining the L11 matrix and performing a triangular matrix solution on all sub-matrices in the same row as the A11 sub-matrix to obtain U12 to U1n matrices, where n represents the number of columns of the initial matrix;
[0023] Step 430 , starting from the A22 submatrix in the second column from the left and the second row from the top, perform gemm update on the submatrices except the first row and the first column;
[0024] Step 440 : Based on the updated A22 sub-matrix, repeat the calculation method from step 400 to step 430 until the Lmm matrix and the Unn matrix of the Amn sub-matrix are obtained, where m is equal to n.
[0025] According to some embodiments of the present application, the step of performing precision processing on the inverse triangular matrix and the preset matrix based on the first floating-point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix, includes:
[0026] When the first floating-point precision is inconsistent with the second floating-point precision of the matrix to be solved, the inverse triangular matrix and the preset matrix are numerically scaled to obtain the first matrix corresponding to the inverse triangular matrix and the second matrix corresponding to the preset matrix, wherein the first numerical range of the first matrix and the second numerical range of the second matrix are within a range that can be represented by the first floating-point precision.
[0027] According to some embodiments of the present application, numerically scaling the inverse triangular matrix and the preset matrix to obtain the first matrix corresponding to the inverse triangular matrix and the second matrix corresponding to the preset matrix includes:
[0028] Determining a first numerical range and a third floating-point precision of the inverse triangular matrix, and determining a second numerical range and a fourth floating-point precision of the preset matrix;
[0029] Determining a first scaling preset constant for the inverse triangular matrix according to the first numerical range, the third floating-point precision, and the first floating-point precision;
[0030] Determining a second scaling preset constant of the preset matrix according to the second numerical range, the fourth floating-point number precision, and the first floating-point number precision;
[0031] According to the first scaling preset constant, the inverse triangular matrix is precision-converted to obtain the first matrix, and according to the second scaling preset constant, the preset matrix is precision-converted to obtain the second matrix.
[0032] According to some embodiments of the present application, performing precision conversion on the inverse triangular matrix according to the first scaling preset constant to obtain the first matrix, and performing precision conversion on the preset matrix according to the second scaling preset constant to obtain the second matrix includes:
[0033] Multiplying the first scaling preset constant by the inverse triangular matrix to obtain a first product, and performing precision conversion on the first product according to the first floating-point precision to obtain the first matrix;
[0034] The second scaling preset constant is multiplied by the preset matrix to obtain a second product, and the second product is precision-converted according to the first floating-point number precision to obtain the second matrix.
[0035] A data processing device according to an embodiment of the second aspect of the present application includes:
[0036] an acquisition module, configured to acquire a matrix to be solved, wherein the matrix to be solved, a triangular matrix, and a preset matrix construct an equation for a triangular matrix equation, wherein the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation;
[0037] an inverse module, configured to perform an inverse transformation on the triangular matrix to obtain an inverse triangular matrix;
[0038] a precision processing module, configured to perform precision processing on the inverse triangular matrix and the preset matrix according to the first floating-point precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix;
[0039] A solution module is used to input the first matrix and the second matrix into the matrix calculation unit of the artificial intelligence chip to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
[0040] A data processing system according to an embodiment of the third aspect of the present application includes:
[0041] at least one memory;
[0042] at least one processor;
[0043] at least one program;
[0044] The programs are stored in the memory, and the processor executes at least one of the programs to implement the data processing method as described in the embodiment of the first aspect.
[0045] According to the computer-readable storage medium of the fourth embodiment of the present application, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the data processing method as described in the first embodiment.
[0046] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present application is further described below with reference to the accompanying drawings and embodiments, wherein:
[0048] FIG1 is a flow chart of a data processing method according to an embodiment of the present application;
[0049] FIG2 is a matrix diagram of a triangular matrix equation solving process provided by one embodiment of the present application;
[0050] FIG3 is a matrix diagram of a triangular matrix equation solving process provided by another embodiment of the present application;
[0051] FIG4 is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0052] FIG5 is a schematic diagram of the structure of the data processing system provided in an embodiment of the present application.
[0053] Reference numerals:
[0054] Acquisition module 100 , inversion module 110 , precision processing module 120 , solution module 130 , memory 200 , processor 300 . DETAILED DESCRIPTION
[0055] The following describes in detail embodiments of the present application. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application.
[0056] It should be noted that although the system diagrams illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the system or the sequence in the flowcharts. Terms used in the specification, claims, and drawings are intended to distinguish similar items and are not necessarily intended to describe a specific sequence or chronological order.
[0057] In the description of this application, "several" means more than one, "plurality" means more than two, "greater than," "less than," and "exceed" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. The use of "first" and "second" in the description is solely for the purpose of distinguishing technical features and should not be construed as indicating or implying relative importance, implicitly specifying the number of the indicated technical features, or implicitly specifying the order of the indicated technical features.
[0058] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.
[0059] In the description of this application, reference to the terms "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples.
[0060] Glossary:
[0061] Triangular matrix equations are a type of mathematical equation found widely across various fields. Their mathematical form is op(A) × X = α × B or X × op(A) = α × B. Here, matrix A is an upper or lower triangular matrix, op(A) represents itself or its transpose, and B is a given matrix, or a preset matrix. Both matrices A and B are set based on the problem being solved. α is a preset constant, and X is the matrix to be solved.
[0062] Artificial Intelligence (AI) Chips:
[0063] With the continuous advancement of science and technology and the continuous development of applications, large-scale heterogeneous parallel computing systems are gradually becoming the trend in the development of supercomputers today and in the future. This type of computing system is widely used in various fields such as scientific computing and data analysis due to its high performance, high energy efficiency, and low cost. Heterogeneous computing architectures use different types of processors / accelerators, such as GPUs, TPUs, and NPUs, and achieve higher computing performance through efficient parallelization technologies. In particular, artificial intelligence has developed rapidly in recent years. Such AI applications often involve a large number of matrix calculations. Various hardware manufacturers have also begun to integrate new hardware units into accelerators, enabling AI chips to provide higher-performance matrix computing capabilities.
[0064] Based on this, AI chips can provide matrix computing power at one or more precision levels. For example, the NVIDIA A100 chip offers matrix computing power at five precision levels: FP64, TF32, BFLOAT16, FP16, and INT8. Ascend chips currently offer matrix computing power at two precision levels: FP16 and INT8. Although some AI chips can provide high-precision FP64 matrix computing power, its peak performance is far lower than that of lower-precision matrix computing power.
[0065] GPU:
[0066] GPU, short for Graphics Processing Unit, is a specialized hardware device for parallel computing. Originally designed for graphics rendering, GPUs, due to their powerful parallel computing capabilities, have gradually been applied to a wider range of computing fields, such as machine learning, data science, and scientific computing. Compared to CPUs, GPUs have more cores and threads, enabling them to better handle the parallel processing of large amounts of data, leading to their widespread use in many computing fields.
[0067] Tensor cores are hardware units within the GPU specifically designed for deep learning. They perform efficient matrix multiplication operations and increase computational speed, which is particularly important for deep learning tasks. Compared to standard CUDA cores, Tensor cores feature more efficient matrix multiplication, enabling faster neural network training. Tensor cores are widely used in many deep learning frameworks, such as TensorFlow and PyTorch.
[0068] Ascend AI processor (Ascend chip):
[0069] The computing core of the Ascend AI processor is primarily composed of the AI Core, which, from a control perspective, can be viewed as a relatively simplified basic architecture of a modern microprocessor. The AI Core architecture is essentially designed to adapt to common applications and algorithms in a specific field, and is commonly referred to as a "Domain Specific Architecture" (DSA). It includes three basic computing resources: the Matrix Computing Unit (Cube Unit), the Vector Computing Unit (Vector Unit), and the Scalar Computing Unit (Scalar Unit). These three computing units each perform their respective functions, forming three independent execution pipelines that work together under the unified scheduling of the system software to achieve optimized computing efficiency. In addition, computing modes of varying precision and type are provided within the Matrix Computing Unit and the Vector Computing Unit.
[0070] Artificial intelligence has developed rapidly in recent years. Artificial intelligence applications usually involve a large amount of matrix calculations. Various hardware manufacturers have also begun to add new hardware units to accelerators to provide higher-performance matrix computing capabilities.
[0071] In existing solutions, solving triangular matrix equations generally calls the BLAS library. BLAS (Basic Linear Algebra Subprograms) is an application interface standard used to standardize the release of a numerical library for basic linear algebra operations. It provides an interface for solving triangular matrix equations. The program set was originally released in 1979 and was used to create larger numerical program packages (such as LAPACK). To improve performance, various software and hardware manufacturers optimize the BLAS interface implementation for their products, such as Intel's Intel MKL, AMD's ACML, Goto BLAS, and ATLAS, which are non-hardware manufacturer optimized versions, as well as CUBLAS implemented using GPU computing technology. Selecting the corresponding linear algebra library on different computing hardware can take advantage of the computing power of the hardware.
[0072] In addition, the existing technology for solving triangular matrix equations uses a row-by-row method, which can only utilize the vector computing capabilities of AI chips and has low performance.
[0073] The present invention proposes a data processing method that can effectively utilize the matrix computing power of various AI chips, significantly improve the efficiency of solving triangular matrix equations, and solve the problem that triangular matrix equations cannot be efficiently solved on AI chips.
[0074] Below, the data processing method of the embodiment of the present application is described based on Figures 1-3.
[0075] It is understood that, as shown in FIG1 , a data processing method is provided, which is applied to an artificial intelligence chip, and the artificial intelligence chip includes a matrix computing unit, including:
[0076] Step S100: obtaining a matrix to be solved, wherein the matrix to be solved, the triangular matrix, and the preset matrix construct an equation of a triangular matrix equation, wherein the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation;
[0077] Step S110, performing an inverse transformation on the triangular matrix to obtain an inverse triangular matrix;
[0078] Step S120, performing precision processing on the inverse triangular matrix and the preset matrix according to the first floating-point precision of the matrix operation of the artificial intelligence chip and the required precision of the matrix to be solved, to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix;
[0079] Step S130: Input the first matrix and the second matrix into a matrix calculation unit to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
[0080] First, obtain the matrix to be solved, wherein the matrix to be solved and the triangular matrix constitute a preset matrix; secondly, perform an inverse transformation on the triangular matrix to obtain an inverse triangular matrix; then, according to the first floating-point precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix, perform precision processing on the inverse triangular matrix and the preset matrix to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix; finally, input the first matrix and the second matrix into the matrix calculation unit to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved. The data processing method of the present application obtains an inverse triangular matrix by inverting the triangular matrix in the triangular matrix equation, which can convert the row-by-row solution problem of the vector represented by the triangular matrix equation into a matrix multiplication problem, so that the matrix computing power of the artificial intelligence chip can be used for calculation, and finally the matrix to be solved represented by the matrix multiplication result is obtained. The matrix computing power of the artificial intelligence chip is much stronger than the vector computing power. Based on this, the artificial intelligence chip can significantly improve the utilization efficiency of the artificial intelligence chip by performing matrix calculation, thereby significantly improving the data processing efficiency based on the solution of the triangular matrix equation. Therefore, the data processing method of the present application can fully utilize the matrix computing capability of the artificial intelligence chip to solve the matrix, thereby significantly improving data processing efficiency.
[0081] It should be noted that the matrix to be solved is X and the triangular matrix is op(A). In the triangular matrix equation op(A)×X=α×B or X×op(A)=α×B, the inverse matrix op(A) is obtained. -1 , solve the problem row by row by converting the original vector op(A)×X=α×B or X×op(A)=α×B into X=α×op(A) -1 ×B or X=α×B×op(A) -1 The reason for converting the row-by-row vector solution of triangular matrix equations into a matrix multiplication problem is that the matrix computing power of AI chips is much stronger than their vector computing power. Matrix multiplication problems can be calculated using the matrix computing power of AI chips.
[0082] It should be noted that X = α × op(A) -1 ×B or X=α×B×op(A) -1 ; can be converted to solve:
[0083] X T =α×B T ×op(A) -T or X T =α×op(A) -T ×B T , where T is the matrix transpose symbol.
[0084] It is understandable that before obtaining the matrix to be solved, it includes:
[0085] Set preset matrices and triangular matrices according to the problem to be solved;
[0086] A triangular matrix equation is constructed by the matrix to be solved, the triangular matrix, the preset matrix and the preset constants, wherein the triangular matrix equation is an equation, the multiplied matrix to be solved and the triangular matrix are on one side of the equation, and the multiplied preset matrix and the preset constant are on the other side of the equation.
[0087] It should be noted that the preset matrix is B and the preset constant is α.
[0088] It can be understood that the inverse transformation of the triangular matrix to obtain the inverse triangular matrix includes:
[0089] Perform an inverse transformation on the triangular matrix to obtain the inverse triangular matrix;
[0090] The equation to be solved is constructed by using the inverse triangular matrix, the preset matrix and the preset constants in the triangular matrix equation, wherein the equation to be solved is an equation, the matrix to be solved is on one side of the equation, and the multiplied inverse triangular matrix, the preset matrix and the preset constants are on the other side of the equation.
[0091] It should be noted that the inverse triangular matrix is op(A) -1 .
[0092] It is understandable that the data processing method also includes:
[0093] Determine the initial matrix to be decomposed;
[0094] Divide the initial matrix into sub-matrices of equal length and width;
[0095] Starting from the submatrix with the first column from the left and the first row from the top, perform LU decomposition, panel decomposition, and triangular matrix solution on the submatrices on the diagonal to obtain the target matrix.
[0096] It can be understood that starting from the submatrix with the first column from the left and the first row from the top, the submatrices on the diagonal are sequentially subjected to LU decomposition, panel decomposition, and triangular matrix solution to obtain the target matrix, including:
[0097] Step 400 , performing LU decomposition on the A11 submatrix with the first column from the left and the first row from the top to obtain an L11 matrix and a U11 matrix;
[0098] Step 410: Combine the U11 matrix and perform panel decomposition on all submatrices in the same column as the A11 submatrix to obtain matrices L21 to Lm1, where m represents the number of rows of the initial matrix. All submatrices do not include the A11 submatrix.
[0099] Step 420 , combining the L11 matrix and performing a triangular matrix solution on all sub-matrices in the same row as the A11 sub-matrix to obtain matrices U12 to U1n, where n represents the number of columns of the initial matrix;
[0100] Step 430 , starting from the A22 submatrix in the second column from the left and the second row from the top, perform gemm update on the submatrices except the first row and the first column;
[0101] Step 440 : Based on the updated A22 sub-matrix, repeat the calculation method from step 400 to step 430 until the Lmm matrix and the Unn matrix of the Amn sub-matrix are obtained, where m is equal to n.
[0102] It should be noted that to verify the practical effectiveness of the data processing method based on triangular matrix equations and AI chips proposed in this application, this application used this technology in the HPL-AI benchmark test based on the Ascend AI chip. The results showed that it significantly improved the computing performance of the HPL-AI program. The details are as follows:
[0103] As shown in Figure 2, the core of the HPL-AI algorithm is LU decomposition. LU decomposition is a matrix decomposition method that can decompose a matrix into the product of a lower triangular matrix and an upper triangular matrix.
[0104] In Figure 2(a), the initial matrix to be decomposed by LU is divided into small matrices with length and width of NB;
[0105] In Figure 2(b), the small matrix in the upper left corner is decomposed by LU to obtain L 11 and U 11 , perform panel factorization and triangular matrix solution (trsm update) on the small matrix blocks in the left column and upper row respectively, and update the remaining sub-matrices (general matrix multiplication gemm) to obtain the sub-matrix to be decomposed;
[0106] In Figures 2(c) to 2(e), the problem of solving the input matrix is converted into a decomposition problem of the remaining submatrices through the above steps. Subsequent iterations only require repeatedly applying the above three steps to the remaining submatrices to complete the solution of the entire problem. The problem of solving the input matrix can be understood as the matrix to be solved.
[0107] Furthermore, a specific calculation case is provided:
[0108] Step 1: Perform LU decomposition on the small matrix block A11 to obtain L11 and U11, where A11 = L11 * U11;
[0109] Step 2: Use U11 and A21 as inputs for panel decomposition to obtain L21, where A21 = L21*U11 + L22*0 = L21*U11. In this step, A21 can be understood as the B matrix in the triangular matrix equation, and U11 can be understood as the A matrix in the triangular matrix equation.
[0110] Step 3: Use L11 and A12 as inputs for trsm to obtain U12, where A12 = L11*U12 + 0*U22 = L11*U12. In this step, A12 can be understood as the B matrix in the triangular matrix equation, and L11 can be understood as the A matrix in the triangular matrix equation.
[0111] Step 4: Use L21, U12, and A22 as the input of gemm to obtain the updated A22, where A22new = A22-L21*U12;
[0112] Each time steps 1-4 are executed, the matrix block of the leftmost column and the topmost row can be decomposed. After updating, the remaining sub-matrix in the lower right corner repeats steps 1-4 until all matrix blocks are decomposed.
[0113] This application tested the performance of mixed-precision algorithms for solving triangular matrix equations on the Ascend AI chip 910A. The theoretical peak half-precision matrix computing power of the Ascend AI chip 910A is known to be 256 TFLOPS. For input matrices of varying sizes, the floating-point computing performance for solving triangular matrix equations can reach 119 to 217 TFLOPS. The experiments demonstrate that this application's technical solution effectively leverages the performance advantages of AI accelerators to improve the efficiency of solving triangular matrix equations.
[0114] It can be understood that, according to the first floating-point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, the inverse triangular matrix and the preset matrix are precision-processed to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix, including:
[0115] When the first floating-point number precision is inconsistent with the second floating-point number precision of the matrix to be solved, the inverse triangular matrix and the preset matrix are numerically scaled to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix, wherein the first numerical range of the first matrix and the second numerical range of the second matrix are within the range that can be represented by the first floating-point number precision.
[0116] It can be understood that numerical scaling is performed on the inverse triangular matrix and the preset matrix to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix, including:
[0117] Determine a first numerical range and a third floating-point precision of the inverse triangular matrix, and determine a second numerical range and a fourth floating-point precision of the preset matrix;
[0118] Determining a first scaling preset constant of the inverse triangular matrix according to the first numerical range, the third floating-point precision, and the first floating-point precision;
[0119] Determining a second scaling preset constant of the preset matrix according to the second numerical range, the fourth floating-point precision, and the first floating-point precision;
[0120] According to the first preset scaling constant, the inverse triangular matrix is precision-converted to obtain a first matrix, and according to the second preset scaling constant, the preset matrix is precision-converted to obtain a second matrix.
[0121] It can be understood that, according to the first scaling preset constant, the inverse triangular matrix is precision converted to obtain the first matrix, and according to the second scaling preset constant, the preset matrix is precision converted to obtain the second matrix, including:
[0122] Multiplying the first scaling preset constant by the inverse triangular matrix to obtain a first product, and performing precision conversion on the first product according to the first floating-point precision to obtain a first matrix;
[0123] The second scaling preset constant is multiplied by the preset matrix to obtain a second product, and the second product is precision-converted according to the first floating-point number precision to obtain a second matrix.
[0124] It should be noted that if the floating-point precision of the initial problem (which can be understood as the floating-point precision of the matrix to be solved) is inconsistent with the precision supported by the matrix computing power of the AI chip, it is necessary to change op(A) -1 and B for numerical scaling and precision conversion.
[0125] Specifically, suppose op(A) and B are FP32 single precision, while some AI chips only support FP16 half precision matrix multiplication. The exponent bit lengths of different precisions are inconsistent, and the representation range of FP32 is larger than that of FP16. That is, some values that can be represented by FP32 cannot be represented by FP16, and numerical scaling is required. The scaling process is to convert op(A) -1 Multiply the A and B matrices by a scaling factor s1 and s2 to get s1op(A) -1 and s2B. The values of the scaling factors s1 and s2 are determined according to op(A) -1 and the numerical range of the B matrix, op(A) -1 The floating point precision of the matrix and the floating point precision of the AI chip matrix computing power is determined to avoid floating point underflow and floating point overflow in the value after precision conversion. After the scaling is completed, the precision conversion is performed and s1op(A) is converted. -1and s2B are converted to low precision supported by AI chip matrix computing power, respectively (s1op(A) -1 ) low and (s2B) low Then use the matrix calculation unit of the AI chip to calculate (s1op(A) -1 ) low and (s2B) low The matrix multiplication result (s1op(A) -1 ) low ×(s2B) low or (s2B) low ×(s1op(A) -1 ) low If you need to restore the accuracy, then (s1op(A) -1 ) low ×(s2B) low or (s2B) low ×(s1op(A) -1 ) low Convert to the floating point precision of the original problem and then scale it back to get the matrix to be solved: X = (s1 -1 ×s2 -1 ×α)×(s1op(A) -1 ) low ×(s2B) low Or X=(s1 -1 ×s2 -1 ×α)×(s2B) low ×(s1op(A) -1 ) low .
[0126] The reasons for matrix scaling and the selection of scaling coefficients are further explained below.
[0127] First, it is necessary to clarify the computer's floating-point representation method, the representation range of each precision of floating-point numbers, and the meaning of floating-point overflow.
[0128] The computer's floating-point representation methods include: half precision (FP16), single precision (FP32), and double precision (FP64).
[0129] Double precision (FP64) is represented as follows:
[0130] Single precision (FP32) is represented as follows:
[0131] Half precision (FP16) is represented as follows:
[0132] In the single-precision 32-bit format, 1 bit is used to indicate whether the number is positive or negative. The exponent reserves 8 bits because it is binary, with 2 carried to the high-order bit, and the remaining 23 bits are used to represent the digits that make up the number, called the significand.
[0133] In double precision, the exponent is reserved for 11 bits and the significand is 52 bits, which greatly expands the range and size of numbers that can be represented. Half precision has a smaller range, with only 5 bits for the exponent and 10 bits for the significand.
[0134] The half-precision format is similar to the single-precision format. The leftmost bit is still the sign bit, the exponent is 5 bits wide and is stored as excess-16, and the mantissa is 10 bits wide but has an implicit 1.
[0135] As shown in the following table, sign is the sign bit, 0 indicates that the floating point number is positive, and 1 indicates that the floating point number is negative.
[0136] First, let's talk about the mantissa, then the exponent. The fraction is the mantissa, which is 10 bits long, but has an implicit 1. The mantissa can be understood as the number after the decimal point of a floating point number. For example, 1.11 has a mantissa of 1100000000(1). The final implicit 1 is mainly used in calculations, as the implicit 1 may be carried.
[0137] exponent is the exponent bit, which is 5 bits long. The specific values it represents are as follows:
[0138] When the exponent bits are all 0 and the mantissa bits are all 0, it represents 0.
[0139] When the exponent bits are all 0 and the mantissa bits are not all 0, it is represented as a subnormal value, a non-normalized floating-point number, which is a very small number.
[0140] When the exponent bits are all 1 and the mantissa bits are all 0, it represents infinity. At this time, if the sign bit is 0, it represents positive infinity, and if the sign bit is 1, it represents negative infinity.
[0141] When the exponent bits are all 1 and the mantissa bits are not all 0, it does not represent a number.
[0142] In other cases, the value of the exponent bit minus 15 is the exponent it represents, such as 11110 represents 30-15=15.
[0143] Therefore, we can obtain that the calculation method of the half-precision floating-point number is (-1)^sign×2^(value of the exponent bit)×(1+0.mantissa bit), where 0.mantissa bit means that if the mantissa bit is 0001110001, then 0.mantissa bit is 0.0001110001.
[0144] The maximum value that can be represented with half precision is:
[0145] 0 11110 1111111111The calculation method is: (-1)^0×2^(30-15)×1.1111111111=1.1111111111(b)×2^15=1.9990234375(d)×2^15=65504.
[0146] The minimum value representable with half precision (excluding subnormal values) is:
[0147] The calculation method for 0 00001 0000000000 is: (-1)^(-1)×2(1-15)=2^(-14), which is approximately equal to 6.104×10^(-5) in decimal.
[0148] Let's take another ordinary number, this time reversed, such as -1.5625 × 10^(-1). That is, -0.15625 = -0.00101 (decimal to binary) = -1.01 × 2^(-3). Therefore, the sign bit is 1, the exponent is -3 + 15 = 12, so the exponent bits are 01100, and the mantissa bits are 0100000000. Therefore, -1.5625 × 10^(-1) is represented as 1 01100 0100000000 using half-precision floating point.
[0149] The representation range of each precision of floating-point numbers is:
[0150] FP32 is a single-precision floating point number, which uses 8 bits to represent the exponent and 23 bits to represent the decimal, occupying 4 bytes;
[0151] FP16 half-precision floating point number, using 5 bits to represent the exponent and 10 bits to represent the decimal, occupying 2 bytes;
[0152] INT8, an eight-bit integer occupies one byte. INT8 is a fixed-point computing method that represents integer operations and is generally quantized from floating-point operations. In binary, a "0" or "1" is one bit, and INT8 means using 8 bits to represent a number. Therefore, although INT8 has lower precision than FP16, it has smaller data volumes, lower energy consumption, and relatively faster computing speed, making it more suitable for edge computing.
[0153] Mixed precision: Simply put, it uses FP16 for multiplication and storage, and only uses FP32 for addition operations to avoid cumulative errors;
[0154] The dynamic range of FP16 (6×10 -8 ~65504) is much lower than the dynamic range of FP32 (1.4×10 -45 ~1.7×10 +38 ); F16 accuracy (2 -10 ) is much coarser than the precision of FP32 (2 -23 ).
[0155] In terms of data representation range, the integer range represented by FP32 and BF16 is the same, but the decimal part is represented differently, resulting in rounding errors; the data range represented by FP32 and FP16 is different, and in big data calculations, FP16 has an overflow risk.
[0156] The following is an explanation of why the range of int8 is -128 to 127:
[0157] int8 occupies 1 byte, and 1 byte occupies 8 bits;
[0158] Among them, the highest bit represents the sign bit 1-negative sign; 0-positive sign;
[0159] Then the binary representation of the maximum value is: 0 1 1 1 1 1 1 1;
[0160] Converted to decimal and calculated from low to high: 0 1 1 1 1 1 1 1 =0*2^7+1*2^6+1*2^5+1*2^4+1*2^3+1*2^2+1*2^1+1*2^0 =0+64+32+16+8+4+2+1 =127;
[0161] The binary representation of the minimum value should be the opposite of the maximum value: 1 0 0 0 0 0 0 0;
[0162] Converted to decimal and calculated from low to high: 1 0 0 0 0 0 0 0 =1*2^7+0*2^6+0*2^5+0*2^4+0*2^3+0*2^2+0*2^1+0*2^0 =128+0+0+0+0+0+0+0=128.
[0163] There is actually another explanation that is quite understandable:
[0164] 1. int8 occupies 1 byte, which is 8 binary bits;
[0165] 2. Each binary bit can store two numbers, 0 and 1. There are 2^8=256 combinations of 8 binary bits (256 numbers can be stored).
[0166] 3. int8 is signed, so positive and negative numbers will evenly divide 256 numbers, 256 / 2=128;
[0167] 4. The minimum value of the 128 negative numbers is -128;
[0168] 5. There are 128 positive numbers, one of which is 0, and the maximum value is +127;
[0169] If it is uint8 (8-bit unsigned - no negative numbers) 2^8 = 256;
[0170] 0 occupies one number, so the maximum is 255.
[0171] Based on the description of the representation range of floating-point numbers of various precisions, floating-point numbers of various precisions have different dynamic ranges. If the absolute value of the value exceeds the upper limit of the dynamic range, it is a floating-point overflow. If the absolute value of the value is lower than the lower limit of the dynamic range, it is a floating-point underflow.
[0172] The meaning of floating-point overflow is explained below.
[0173] Overflow of fixed-point / floating-point numbers is divided into overflow and underflow.
[0174] Arithmetic overflow occurs when the result of an arithmetic operation performed by a computer exceeds the range that the machine can represent.
[0175] Overflow can be divided into overflow and underflow. In fixed-point computers and floating-point computers, the concepts of overflow and underflow are not exactly the same.
[0176] In the fixed-point computer:
[0177] Exceeding the representation range of a number in the positive direction is called overflow; exceeding the representation range of a number in the negative direction is called underflow.
[0178] The details are as follows:
[0179] In floating-point computers:
[0180] The representation range of floating-point numbers is mainly determined by the exponent.
[0181] Regardless of whether the sign of the number is positive or negative, if the exponent exceeds the exponent representation range in the positive direction, it is called overflow;
[0182] If the exponent exceeds the exponent representation range from the negative direction, or the mantissa is "0", it is collectively called underflow.
[0183] Generally speaking, computers automatically treat underflow of floating-point numbers as "0" and do not output error information (precision overflow).
[0184] If an overflow (range overflow) occurs, the computer will generate an "overflow interrupt" and output an overflow error message, or even stop the program from running.
[0185] Simple overflow judgment rules:
[0186] Overflow can only occur when adding two numbers of the same sign or subtracting two numbers of different signs. In other words, overflow only occurs when adding numbers of the same sign or subtracting numbers of different signs. For example, when adding two positive numbers, the sign bit of the result is 1 (the result is negative); when subtracting a positive number from a negative number, the sign bit of the result is 0 (the result is positive). When overflow occurs in fixed-point addition and subtraction, the result is incorrect.
[0187] It should be noted that the exponent bit lengths of different precisions vary. For example, the representation range of FP32 is larger than that of FP16. This means that some values that can be represented by FP32 cannot be represented by FP16, necessitating numerical scaling. Scaling is used to prevent floating-point overflow. The selection of the scaling factor depends on the floating-point precision of the matrix, the floating-point range of the matrix, and the floating-point precision of the AI chip's matrix computing power.
[0188] Next, let's take an example of how to get the value of the scaling factor:
[0189] Assume that matrix A is represented using FP32 single-precision floating-point. If the value of matrix A is greater than the upper bound of the FP16 dynamic range (65504.0), then FP16 precision will not be able to represent matrix A. Matrix A must be scaled by multiplying it by a factor so that the value of matrix A is less than the upper bound of the FP16 dynamic range. If the value of matrix A is less than the lower bound of the FP16 dynamic range (5.96*10^-8), then matrix A must be scaled by multiplying it by a factor so that the value of matrix A is greater than the lower bound of the FP16 dynamic range. In particular, the description of "the value of matrix A is greater than" is only a rough guideline, because matrix A contains many elements, and the selection of the specific scaling factor requires specific analysis of the specific problem.
[0190] It should be noted that, as shown in FIG3 , for the problem of solving a large-scale triangular matrix equation, the block technology can be used to convert it into a small-scale triangular matrix equation solution and matrix multiplication.
[0191] It should be noted that in application scenarios with very high accuracy requirements, a matrix multiplication accuracy repair method can be introduced based on the above method. For example, as the accuracy restoration method described above, if accuracy restoration is required, (s1op(A) -1 )low ×(s2B) low or (s2B) low ×(s1op(A) -1 ) low Convert to the floating point precision of the original problem and then scale it back to get the matrix to be solved: X = (s1 -1 ×s2 -1 ×α)×(s1op(A) -1 ) low ×(s2B) low Or X=(s1 -1 ×s2 -1 ×α)×(s2B) low ×(s1op(A) -1 ) low .
[0192] It should be noted that if the precision supported by the AI chip's matrix computing power is lower than the floating-point precision of the matrix to be solved, converting the triangular matrix and the preset matrix to the lower precision supported by the AI chip's matrix computing power may affect the calculation results in two ways:
[0193] 1. If the value range of the matrix cannot be represented by low precision, that is, a numerical overflow (including numerical overflow and numerical underflow) occurs, then an incorrect calculation result will be obtained. The solution is to use the numerical scaling method described above to scale the matrix value to a range that can be represented by low precision;
[0194] 2. The matrix is converted to low precision, which may result in slight errors in the calculation results. If you do not require high precision, you can leave it unchanged. If you cannot tolerate errors, you can use the precision repair solution described above.
[0195] It should be noted that the method for determining the scaling factor is:
[0196] Given the floating-point precision of the triangular matrix equation, the numerical range that can be expressed by the floating-point precision can be determined based on the floating-point representation method and the representation range of the floating-point precision of the computer described above;
[0197] Given the floating-point precision supported by the AI chip matrix computing power, we can determine the range of values that can be expressed by this floating-point precision based on the computer's floating-point representation method and the range of floating-point precision described above, primarily determining the upper and lower bounds of this range.
[0198] Given the triangular matrix equation op(A) -1 And the numerical range of B, judge op(A) -1 Will the conversion of A and B to the precision supported by the AI chip matrix computing power cause numerical overflow? If op(A) -1If the low-precision representation range is exceeded, then an arbitrary scaling preset constant s1 is selected so that s1op(A) -1 The value of does not exceed the low-precision representation range; if B exceeds the low-precision representation range, then an arbitrary scaling preset constant s2 is selected so that s2B does not exceed the low-precision representation range.
[0199] Specific examples:
[0200] The problem to be solved is X = α × op(A) -1 ×B, the matrix is represented using single precision, and AI chips only support half-precision matrix multiplication. Assume that the op(A) of this problem is -1 Each element of the matrix is -1.0*10 -8 to 1.0*10 -8 Each element of the B matrix is a random number between 10000.0 and 100000.0.
[0201] It is known that the lower limit of the half-precision floating-point representation range is 5.96*10 -8 , op(A) -1 Each element of the matrix is -1.0*10 -8 to 1.0*10 -8 The random numbers between cannot be represented by half precision, and directly converting to half precision will all become 0. Here you can select a scaling preset constant s1, such as 1.0*10 8 , so s1op(A) -1 The value range is between -1.0 and 1.0, which can be fully represented with half precision.
[0202] It is known that the upper limit of the half-precision floating point representation range is 65504. Each element of the B matrix is a random number between 10000.0 and 100000.0. Some numbers exceed the upper limit of the half-precision floating point representation range and cannot be represented using half precision. Here you can select a scaling preset constant s2, such as 1.0*10 -4 , so the value range of s2B is between 1.0 and 10.0, which can be fully represented with half precision.
[0203] It should be noted that the data processing method of this application pre-processes the triangular matrix equation so that the equation-solving problem can be processed by the matrix calculation unit of the artificial intelligence chip. In other words, through the data processing method of matrix inverse transformation, the problem of solving the triangular matrix equation is converted into the problem of solving matrix multiplication, thereby mobilizing the matrix computing power of the artificial intelligence chip. Therefore, the essence of this application lies in how to obtain data that meets the requirements through data processing and mobilize the matrix computing power of the artificial intelligence chip through this data. It is not a technical solution that simply solves the triangular matrix equation itself.
[0204] It is understood that, as shown in FIG4 , the present application further provides a data processing device, including:
[0205] An acquisition module 100 is configured to acquire a matrix to be solved, wherein the matrix to be solved, a triangular matrix, and a preset matrix form an equation for a triangular matrix equation, wherein the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation;
[0206] An inversion module 110 is used to perform an inverse transformation on the triangular matrix to obtain an inverse triangular matrix;
[0207] The precision processing module 120 is configured to perform precision processing on the inverse triangular matrix and the preset matrix according to the first floating-point precision of the matrix operation of the artificial intelligence chip and the required precision of the matrix to be solved, thereby obtaining a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix;
[0208] The solving module 130 is used to input the first matrix and the second matrix into the matrix calculation unit of the artificial intelligence chip to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
[0209] The data processing system according to an embodiment of the present application is described below with reference to FIG. 5 .
[0210] It is understood that, as shown in FIG5 , the data processing system includes:
[0211] at least one memory 200;
[0212] at least one processor 300;
[0213] at least one program;
[0214] Programs are stored in the memory 200, and the processor 300 executes at least one program to implement the above data processing method. FIG5 takes a processor 300 as an example.
[0215] The processor 300 and the memory 200 may be connected via a bus or other means. FIG5 takes the connection via a bus as an example.
[0216] Memory 200, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and signals, such as program instructions / signals corresponding to the data processing system in the embodiments of the present application. Processor 300 executes the non-transitory software programs, instructions, and signals stored in memory 200 to perform various functional applications and data processing, thereby implementing the data processing method of the above-mentioned method embodiment.
[0217] The memory 200 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store relevant data of the above-mentioned data processing method, etc. In addition, the memory 200 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 200 may optionally include a memory remotely arranged relative to the processor 300, and these remote memories may be connected to the data processing system via a network. Examples of the above-mentioned network include, but are not limited to, the Internet of Things, a software-defined network, a sensor network, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0218] One or more signals are stored in the memory 200, and when executed by one or more processors 300, the data processing method in any of the above method embodiments is executed, for example, the method in FIG1 described above is executed.
[0219] The following describes a computer-readable storage medium according to an embodiment of the present application with reference to FIG. 5 .
[0220] As shown in FIG5 , a computer-readable storage medium stores computer-executable instructions. The computer-executable instructions are executed by one or more processors 300, for example, by one processor 300 in FIG5 , to enable the one or more processors 300 to perform the data processing method in the above method embodiment, for example, the method in FIG1 described above.
[0221] The system embodiment described above is merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected based on actual needs to achieve the objectives of this embodiment.
[0222] From the description of the above embodiments, one skilled in the art will appreciate that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, or any suitable combination thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on computer-readable media, which may include computer storage media and communication media. As is well known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and that can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media generally contains computer-readable signals, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0223] The embodiments of the present application have been described in detail above with reference to the accompanying drawings. However, the present application is not limited to the above embodiments. Various modifications can be made within the scope of knowledge possessed by ordinary technicians in the relevant technical field without departing from the purpose of the present application. In addition, the embodiments of the present application and the features of the embodiments can be combined with each other unless there is a conflict.
Claims
1. A data processing method, characterized in that: Applied to an artificial intelligence chip, the artificial intelligence chip includes a matrix computing unit, including: Obtaining a matrix to be solved, wherein the matrix to be solved, a triangular matrix, and a preset matrix construct an equation of a triangular matrix equation, and the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation; Performing an inverse transformation on the triangular matrix to obtain an inverse triangular matrix; According to the first floating point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, the inverse triangular matrix and the preset matrix are precision processed to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix; The first matrix and the second matrix are input into the matrix calculation unit to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
2. The data processing method according to claim 1, characterized in that: Before obtaining the matrix to be solved, the following steps are included: Setting the preset matrix and the triangular matrix according to the problem to be solved; A triangular matrix equation is constructed by using the matrix to be solved, the triangular matrix, the preset matrix and the preset constants, wherein the triangular matrix equation is an equation, the multiplied matrix to be solved and the triangular matrix are located on one side of the equation, and the multiplied preset matrix and the preset constants are located on the other side of the equation.
3. The data processing method according to claim 1, characterized in that: The data processing method further includes: Determine the initial matrix to be decomposed; Divide the initial matrix into sub-matrices of equal length and width; Starting from the submatrix with the first column from the left and the first row from the top, perform LU decomposition, panel decomposition, and triangular matrix solution on the submatrices on the diagonal to obtain the target matrix.
4. The data processing method according to claim 3, characterized in that: Starting from the submatrix with the first column from the left and the first row from the top, the submatrix on the diagonal line is sequentially subjected to LU decomposition, panel decomposition, and triangular matrix solution to obtain a target matrix, including: Step 400, performing LU decomposition on the A11 submatrix with the first column from the left and the first row from the top to obtain an L11 matrix and a U11 matrix; Step 410, combining the U11 matrix, performing panel decomposition on all sub-matrices in the same column as the A11 sub-matrix, to obtain L21 to Lm1 matrices, where m represents the number of rows of the initial matrix, and all sub-matrices do not include the A11 sub-matrix; Step 420, combining the L11 matrix, performing triangular matrix solution on all sub-matrices in the same row as the A11 sub-matrix, to obtain U12 to U1n matrices, where n represents the number of columns of the initial matrix; Step 430, starting from the A22 submatrix in the second column from the left and the second row from the top, perform gemm update on the submatrices except the first row and the first column; Step 440, based on the updated A22 sub-matrix, repeat the calculation method of step 400 to step 430 until the Lmm matrix and the Unn matrix of the Amn sub-matrix are obtained, where m is equal to n.
5. The data processing method according to claim 1, characterized in that: The method performs precision processing on the inverse triangular matrix and the preset matrix according to the first floating point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, so as to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix, including: When the first floating-point number precision is inconsistent with the second floating-point number precision of the matrix to be solved, the inverse triangular matrix and the preset matrix are numerically scaled to obtain the first matrix corresponding to the inverse triangular matrix and the second matrix corresponding to the preset matrix, wherein the first numerical range of the first matrix and the second numerical range of the second matrix are within the range that can be represented by the first floating-point number precision.
6. The data processing method according to claim 5, characterized in that: The numerically scaling the inverse triangular matrix and the preset matrix to obtain the first matrix corresponding to the inverse triangular matrix and the second matrix corresponding to the preset matrix includes: Determine a first numerical range and a third floating point precision of the inverse triangular matrix, and determine a second numerical range and a fourth floating point precision of the preset matrix; Determine a first scaling preset constant of the inverse triangular matrix according to the first numerical range, the third floating-point number precision and the first floating-point number precision; Determine a second scaling preset constant of the preset matrix according to the second numerical range, the fourth floating-point number precision and the first floating-point number precision; According to the first scaling preset constant, the inverse triangular matrix is precision-converted to obtain the first matrix, and according to the second scaling preset constant, the preset matrix is precision-converted to obtain the second matrix.
7. The data processing method according to claim 6, characterized in that: The step of performing precision conversion on the inverse triangular matrix according to the first scaling preset constant to obtain the first matrix, and performing precision conversion on the preset matrix according to the second scaling preset constant to obtain the second matrix includes: Multiplying the first preset scaling constant by the inverse triangular matrix to obtain a first product, and performing precision conversion on the first product according to the first floating-point number precision to obtain the first matrix; The second scaling preset constant is multiplied by the preset matrix to obtain a second product, and the second product is precision-converted according to the first floating-point number precision to obtain the second matrix.
8. A data processing device, characterized in that include: An acquisition module, used for acquiring a matrix to be solved, wherein the matrix to be solved, a triangular matrix and a preset matrix construct an equation of a triangular matrix equation, and the matrix to be solved and the triangular matrix are located on one side of the equation, and the preset matrix is located on the other side of the equation; An inverse module, used for performing an inverse transformation on the triangular matrix to obtain an inverse triangular matrix; A precision processing module, used to perform precision processing on the inverse triangular matrix and the preset matrix according to the first floating point number precision of the matrix operation of the artificial intelligence chip and the operation precision required by the matrix to be solved, so as to obtain a first matrix corresponding to the inverse triangular matrix and a second matrix corresponding to the preset matrix; A solution module is used to input the first matrix and the second matrix into the matrix calculation unit of the artificial intelligence chip to obtain a matrix multiplication result, wherein the matrix multiplication result is used to represent the matrix to be solved.
9. A data processing system, characterized in that include: at least one memory; at least one processor; at least one program; The programs are stored in the memory, and the processor executes at least one of the programs to implement the data processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the data processing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Quickening method utilizing cooperative work of CPU and GPU to solve triangular linear equation set
CN101751376A
Parallel computing method and device for unstructured triangular sparse linear equation set
CN115455342A
Matrix calculation method, device and system, radar and storage medium
CN116186472A
Data processing method, device and system and storage medium
CN117216466A
Implementing Modified QR Decomposition in Hardware
US20140214910A1
Cited By
Matrix calculation device and method, electronic equipment and storage medium
CN121614112A