A neural network compression method, electronic device and computer readable medium

By decomposing and adjusting the weight matrix of the neural network, the model topology remains unchanged, solving the problem of irregular structure after pruning and improving calculation efficiency.

CN111353598BActive Publication Date: 2024-09-24CAMBRICON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201811585964.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-20
Publication Date
2024-09-24
Estimated Expiration
2039-10-29

AI Technical Summary

Technical Problem

Existing neural network models easily cause the topology to become irregular during the pruning process, which increases the demand for computing resources and storage resources. How to reduce model parameters while maintaining the same topology is an important issue.

Method used

By decomposing the weight matrix into multiple sub-matrices and adjusting the size of the sub-matrices according to the preset formula, the topology of the neural network model remains unchanged by training the compressed model to meet the preset accuracy and compression ratio.

Benefits of technology

It effectively reduces the calculation amount of the neural network, improves the computing speed, avoids the problem of irregular topology, and achieves deep compression of the neural network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111353598B
    Figure CN111353598B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a neural network compression method, device, electronic device and computer-readable medium, wherein the method comprises: compressing a first weight matrix by using a compression method until the compressed neural network model achieves a relatively good compression effect. Through the present application, the topological structure of the neural network model can be ensured to remain unchanged, thereby avoiding the irregularity of the topological structure of the neural network model and reducing the amount of computation of the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a neural network compression method, electronic equipment and computer-readable medium. Background Art

[0002] A neural network is an algorithmic mathematical model that imitates the behavioral characteristics of animal neural networks and performs distributed parallel information processing. This network is composed of a large number of nodes (or neurons) that are connected to each other. It simulates the information processing process of the human brain by adjusting the interconnected relationships between a large number of internal nodes and using input neuron data and weights to generate output data to process information and generate results after pattern recognition.

[0003] At present, neural networks are widely used in various fields of computer vision, such as image recognition, object detection, image segmentation, etc. However, in practical applications, neural network models often have a large number of model parameters (for example, ultra-large-scale weights). In this case, this means that the neural network requires a large amount of computing resources and storage resources. The overhead of a large amount of computing resources and storage resources will reduce the computing speed of the neural network, and the requirements for the transmission bandwidth and operator of the hardware will also be greatly increased. Therefore, how to reduce the computational complexity of the neural network while reducing the parameters of the neural network model becomes very important.

[0004] In the prior art, the parameters of the neural network model are adjusted by pruning methods to reduce the parameters of the neural network model and reduce the amount of calculation of the neural network. Taking the pruning of the weights of the neural network as an example, Figure 1A As shown in the figure, before the weights of the neural network are pruned, the topological structure of the neural network is regular. However, after the weights of the neural network are pruned, the original regular topological structure in the neural network model becomes irregular. Therefore, how to prevent the topological structure in the neural network model from becoming irregular is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The embodiments of the present invention provide a neural network compression method, an electronic device and a computer-readable medium. During the neural network compression process, the topological structure of the neural network model can be ensured to remain unchanged, thereby avoiding the irregularity of the topological structure of the neural network model and reducing the computational complexity of the neural network.

[0006] In a first aspect, an embodiment of the present invention provides a neural network compression method, the method comprising:

[0007] Acquire first input data; wherein the first input data includes a first weight matrix;

[0008] Compressing the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices;

[0009] A neural network calculation is performed according to second input data, wherein the second input data includes the second weight matrix and input neuron data.

[0010] Optionally, compressing the first weight matrix into a second weight matrix includes:

[0011] Decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices;

[0012] The size of each submatrix in the at least two submatrices is determined according to a first formula, wherein the first formula is Q≈Q1*Q2*...*Q n ; wherein, Q represents a first weight matrix; Q1 represents a first submatrix in the at least two submatrices; Q2 represents a second submatrix in the at least two submatrices; Q n represents the nth submatrix of the at least two submatrices;

[0013] The size of each submatrix of the at least two submatrices is adjusted, and a second weight matrix satisfying a preset accuracy is obtained by training a compressed machine learning model.

[0014] Optionally, the size of each submatrix in the at least two submatrices is determined according to a first formula, and the first formula is Q≈Q1*Q2*......*Q n ,include:

[0015] The size of each submatrix in the at least two submatrices is determined according to the first formula and the second formula, wherein the second formula is || Q-Q1*Q2*......*Q n ||≤T, where T represents a preset error threshold.

[0016] Optionally, adjusting the size of each submatrix of the at least two submatrices and training the compressed machine learning model to obtain a second weight matrix that meets a preset accuracy includes:

[0017] The size of each submatrix of the at least two submatrices is adjusted, and the compressed machine learning model is trained to obtain a second weight matrix that meets the preset accuracy and has a compression ratio that meets the preset compression ratio with the first weight matrix.

[0018] Optionally, the neural network is a fully connected layer neural network; the at least two sub-matrices include two sub-matrices; the first formula includes: M≈M1*M2; the two sub-matrices include a first sub-matrix M1 and a second sub-matrix M2, and M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, N in is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0019] Optionally, the neural network is a convolutional neural network; the convolutional neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0020] Optionally, the neural network is an LSTM layer neural network; the LSTM layer neural network includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: M j ≈M j_1 *M j_2 ; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j_1 and the second submatrix M j_2 , the M j_1 N in_j *S matrix, the M j_2 For S*N out_j Matrix; where S is the compression parameter, N in_j is the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the Mj_1 The number of output neurons and the M j_2 The number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.

[0021] In a second aspect, an embodiment of the present invention provides a neural network compression device, the device comprising a unit for executing the method of the first aspect. Specifically, the device comprises:

[0022] An acquisition unit, configured to acquire first input data; wherein the first input data includes a first weight matrix;

[0023] A compression unit, used for compressing the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices;

[0024] A computing unit is used to perform neural network calculation according to second input data, wherein the second input data includes the second weight matrix and input neuron data.

[0025] Optionally, the compression unit includes:

[0026] A decomposition unit, used for decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices;

[0027] A solving unit, configured to determine the size of each of the at least two sub-matrices according to a first formula, wherein the first formula is Q≈Q1*Q2*......*Q n ; wherein, Q represents a first weight matrix; Q1 represents a first submatrix in the at least two submatrices; Q2 represents a second submatrix in the at least two submatrices; Q n represents the nth submatrix of the at least two submatrices;

[0028] A training unit is used to adjust the size of each submatrix of the at least two submatrices and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model.

[0029] Optionally, the solving unit is specifically used for:

[0030] The size of each submatrix in the at least two submatrices is determined according to the first formula and the second formula, wherein the second formula is || Q-Q1*Q2*......*Q n ||≤T, where T represents a preset error threshold.

[0031] Optionally, the training unit is specifically used for:

[0032] The size of each submatrix of the at least two submatrices is adjusted, and the compressed machine learning model is trained to obtain a second weight matrix that meets the preset accuracy and has a compression ratio that meets the preset compression ratio with the first weight matrix.

[0033] Optionally, the neural network is a fully connected layer neural network; the at least two sub-matrices include two sub-matrices; the first formula includes: M≈M1*M2; the two sub-matrices include a first sub-matrix M1 and a second sub-matrix M2, and M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, N in is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0034] Optionally, the neural network is a convolutional neural network; the convolutional neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0035] Optionally, the neural network is an LSTM layer neural network; the LSTM layer neural network includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: M j ≈M j_1 *M j_2 ; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j_1 and the second submatrix M j_2 , the M j_1 N in_j *S matrix, the Mj_2 For S*N out_j Matrix; where S is the compression parameter, N in_j is the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the M j_1 The number of output neurons and the M j_2 The number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.

[0036] In a third aspect, an embodiment of the present invention provides another electronic device, comprising a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are interconnected, wherein the memory is used to store a computer program that supports the electronic device to execute the above method, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the above first aspect.

[0037] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect.

[0038] In a fifth aspect, an embodiment of the present invention provides a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect.

[0039] The embodiment of the present invention can obtain at least two sub-matrices containing compression parameters by decomposing the first weight matrix. Then, each of the at least two sub-matrices is solved according to the formula, and the compressed neural network is trained to obtain a second weight matrix that meets the preset accuracy. This solves the problem of irregular topological structure of the neural network that is easily caused by the use of the neural network pruning algorithm in the prior art, and can deeply compress the neural network, reduce the calculation amount of the neural network, and improve the operation speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.

[0041] Figure 1A is a schematic diagram of an operation of pruning a neural network provided in an embodiment of the present application;

[0042] Figure 1BIt is a flowchart of a neural network compression method provided in an embodiment of the present application;

[0043] Figure 2A is a schematic diagram of a neural network architecture provided in an embodiment of the present application;

[0044] Figure 2B is a schematic diagram of a fully connected layer weight matrix provided in an embodiment of the present application;

[0045] Figure 2C This is a schematic diagram of an operation of compressing a fully connected layer weight matrix provided in an embodiment of the present application;

[0046] Figure 2D It is a schematic diagram of the structure of a convolution kernel in a convolution layer provided in an embodiment of the present application;

[0047] Figure 2E is a schematic diagram of a fully connected layer weight matrix provided by another embodiment of the present application;

[0048] Figure 2F This is a schematic diagram of an operation of compressing an LSTM layer provided in an embodiment of the present application;

[0049] Figure 3A is a structural schematic diagram of a neural network compression device provided in an embodiment of the present application;

[0050] Figure 3B is a structural schematic diagram of a compression unit provided in an embodiment of the present application;

[0051] Figure 4 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;

[0052] Figure 5 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0053] Figure 6 It is a structural schematic diagram of a control unit provided in an embodiment of the present application;

[0054] Figure 7 It is a flowchart of a neural network operation method provided in an embodiment of the present application;

[0055] Figure 8 is a schematic diagram of the structure of another computing device provided in an embodiment of the present application;

[0056] Fig. 9 is a structural diagram of a main processing circuit provided in an embodiment of the present application;

[0057] Fig.10 is a schematic diagram of the structure of another computing device provided in an embodiment of the present application;

[0058] Fig.11 It is a structural diagram of a tree-type module provided in an embodiment of the present application;

[0059] Fig.12 is a structural diagram of another computing device provided in an embodiment of the present application;

[0060] Fig.13 is a structural diagram of another computing device provided in an embodiment of the present application;

[0061] Fig.14 is a structural diagram of another computing device provided in an embodiment of the present application;

[0062] Fig.15 is a structural diagram of a combined processing device provided in an embodiment of the present application;

[0063] Fig.16 is a structural diagram of another combined processing device provided in an embodiment of the present application;

[0064] Fig.17 It is a structural schematic diagram of a board provided in an embodiment of the present application. DETAILED DESCRIPTION

[0065] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0066] In a specific implementation, the electronic devices described in the embodiments of the present invention include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with touch-sensitive surfaces (e.g., touch screen displays and / or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., touch screen displays and / or touch pads).

[0067] In the following discussion, an electronic device including a display and a touch-sensitive surface is described. However, it should be understood that the electronic device may include one or more other physical user interface devices such as a physical keyboard, a mouse, and / or a joystick.

[0068] The electronic device supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a game application, a telephone application, a video conferencing application, an email application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital camcorder application, a web browsing application, a digital music player application, and / or a digital video player application.

[0069] Various applications that can be executed on an electronic device can use at least one common physical user interface device such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the electronic device can be adjusted and / or changed between applications and / or within corresponding applications. In this way, a common physical architecture of an electronic device (e.g., a touch-sensitive surface) can support a variety of applications with user interfaces that are intuitive and transparent to the user.

[0070] Combine the following Figure 1B The flowchart of the neural network compression method provided by the embodiment of the present invention is shown, which specifically explains how the present invention implements compression of the first weight matrix to obtain the second weight matrix, and may include but is not limited to the following steps:

[0071] Step S100: Obtain first input data; wherein the first input data includes a first weight matrix.

[0072] In a specific implementation, the weight data in the first weight matrix can be any real number. Here, the weight data refers to the connection value between the neural network layers, that is, the information transmission strength between neurons.

[0073] Step S102: compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices.

[0074] In one implementation manner, adjusting the first weight matrix to a second weight matrix includes:

[0075] Decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices;

[0076] The size of each submatrix in the at least two submatrices is determined according to a first formula, wherein the first formula is Q≈Q1*Q2*...*Q n ; wherein, Q represents a first weight matrix; Q1 represents a first submatrix in the at least two submatrices; Q2 represents a second submatrix in the at least two submatrices; Q n represents the nth submatrix of the at least two submatrices;

[0077] The size of each submatrix of the at least two submatrices is adjusted, and a second weight matrix satisfying a preset accuracy is obtained by training a compressed machine learning model.

[0078] In a specific implementation, the operation symbol “*” in the first formula represents a matrix multiplication operation.

[0079] In one implementation manner, when the third weight matrix includes two sub-matrices, the first formula can be expressed as:

[0080] Q≈Q1*Q2 (1.1)

[0081] Wherein, Q represents the first weight matrix, Q1 represents the first sub-matrix of the two sub-matrices; and Q2 represents the second sub-matrix of the two sub-matrices.

[0082] In another embodiment, when the third weight matrix includes at least two sub-matrices, the first formula can be expressed as:

[0083] Q≈Q1*Q2*......*Q n (1.2)

[0084] In the above formula (1.2), n is a positive integer greater than 2.

[0085] In a specific implementation, in the process of compressing the first weight matrix into the second weight matrix, when applied to different neural networks (for example, a fully connected layer neural network, a convolutional layer neural network, an LSTM layer neural network), the above-mentioned decomposition operation on the first weight matrix, solving each of the at least two sub-matrices, and adjusting each of the at least two sub-matrices to obtain a second weight matrix that meets the preset accuracy will be different, which will be specifically explained below:

[0086] (1) Fully connected layer neural network:

[0087] A fully connected layer means that for layers n-1 and n, any node in layer n-1 is connected to all nodes in layer n. Figure 2A , is a schematic diagram of the structure of a one-dimensional fully connected layer of a neural network provided by an embodiment of the present invention, such as Figure 2A As shown in , the neural network includes an input layer, a hidden layer, and an output layer, wherein the two-dimensional parameter matrix of the fully connected layer between the input layer and the hidden layer is (3,4). The two-dimensional parameter matrix (3,4) indicates that in the fully connected layer structure between the input layer and the hidden layer, the number of input neurons is 3, the number of output neurons is 4, and the number of weights is 12. In the specific implementation, these 12 weights can be represented as a weight matrix with 4 rows and 3 columns. The weight matrix can be expressed as follows Figure 2B shown.

[0088] In a fully connected layer neural network, the first formula includes: M≈M1*M2; the two sub-matrices refer to a first sub-matrix M1 and a second sub-matrix M2, where M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, Nin is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0089] As mentioned above, the process of adjusting the size of each of the two sub-matrices is actually a dynamic change process of the compression parameter K value to find the optimal compression parameter K. In practical applications, a binary search method can be used to determine the compression parameter K value in the fully connected layer neural network, so as to obtain a second weight matrix that meets the preset accuracy. In one embodiment, the compression parameter K determined by the binary search method can make the second weight matrix meet the preset accuracy. In another embodiment, the compression parameter K determined by the binary search method can make the second weight matrix meet the preset accuracy while the compression ratio of the first weight matrix to the second weight matrix meets the preset compression ratio, that is, a better compression effect is obtained for the compression of the neural network model.

[0090] In the specific implementation, the compression parameter K has different values, that is, the first weight matrix is ​​compressed based on multiple different compression ratios. Here, in the fully connected layer neural network, the compression ratio is

[0091] Next, we will explain in detail how to use binary search to determine the compression parameter K value. First, we set two parameters KL and KR. In the initialization, let KL = 1, KR = min(N in , N out ). In the process of adjusting parameters, K=(KL+KR) / 2. If the second weight matrix represented by M1*M2 causes the accuracy of the compressed neural network model to decrease by X% (here, X=1-10, etc.), adjust the parameter KL so that KL=K. If the second weight matrix represented by M1*M2 causes the compressed neural network model to meet the preset accuracy, then adjust KR so that KR=K, and repeat the above steps until the end condition K=KL or K=KR is met.

[0092] by Figure 2A Taking the fully connected layer between the input layer and the hidden layer as an example, the compression parameter K is a positive integer greater than 0 and less than or equal to 3. The compression parameter K=2 is determined by the above binary search method, that is, the first submatrix M1 in the second weight matrix that meets the preset accuracy is a (3,2) matrix, and the second submatrix M2 is a (2,4) matrix. Specifically, for Figure 2A The compression of this fully connected layer between the input layer and the hidden layer can be as follows Figure 2C shown.

[0093] In one embodiment, when the first formula is expressed as shown in formula (1.2), that is, the number of sub-matrices in the third weight matrix is ​​n, where n is a positive integer greater than 2, and the number of compression parameters K is (n-1). In practical applications, an adaptive algorithm (e.g., a genetic algorithm) can be used to determine the (n-1) compression parameter K values ​​in the fully connected layer neural network, thereby obtaining a second weight matrix that meets the preset accuracy and / or meets the compression effect. The following specifically describes how to use a genetic algorithm to determine the (n-1) compression parameter K values ​​in the fully connected layer neural network:

[0094] Step 1: Randomly generate a population: Set the size of the population to P and the maximum number of iterations to T max , for example, T max =100. In the initial state, set the iteration counter t=0; crossover probability Pc=A (for example, A=0.4), mutation probability Pm=B (for example, B=0.6), each row of the population matrix represents a gene string individual, and each column represents the number of individuals; here, each individual is a set of compression parameters K (for example, K j ) value solution;

[0095] Step 2: Calculate the fitness of each individual in the population; here, fitness refers to the compression ratio and / or accuracy of the first weight matrix and the second weight matrix corresponding to the individual, where the compression ratio is used to characterize the compression effect on the neural network.

[0096] Step 3: Apply the selection operator to the population and directly pass the optimized individuals to the next generation;

[0097] Step 4: Apply the crossover operator to the population. For any two individuals, randomly generate several gene string position points and exchange the values ​​of the two individuals at that position.

[0098] Step 5: Apply the mutation operator to the population. For any individual, randomly generate several gene string positions and then change the values ​​at these positions. Here, mutation refers to randomly changing K j The value of

[0099] Step 6: Keep the individuals with the highest fitness in each generation and enter the next generation;

[0100] Step 7: Determine whether the maximum number of iterations T has been reached max , if t = T max , then output the individual with the maximum fitness and terminate the calculation; otherwise, jump to step 2 to continue execution.

[0101] Therefore, the (n-1) compression parameter K values ​​in the fully connected layer neural network can be determined according to the above genetic algorithm.

[0102] (2) Convolutional neural network:

[0103] Take the convolutional layer of a neural network as an example, Figure 2D As shown, the convolutional layer can be considered as a four-dimensional matrix (N fin ,N fout ,K x ,K y ), where N fin is the number of input feature images, N fout is the number of output feature images, (K x ,K y ) is the size of the convolution kernel in the convolution layer.

[0104] In the convolutional neural network, the convolutional neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0105] As mentioned above, the process of adjusting the size of each of the two sub-matrices is actually a dynamic change process of the compression parameter R value to find the best compression parameter R. In practical applications, a binary search method can be used to determine the compression parameter R value in the convolutional layer neural network, so as to obtain a second weight matrix that meets the preset accuracy.

[0106] In the specific implementation, the compression parameter R value is different, that is, the first weight matrix is ​​compressed based on multiple different compression ratios. Here, in the convolutional layer neural network, the compression ratio

[0107] In the embodiment of the present invention, the implementation process of determining the value of the compression parameter R by using a binary search method is described in the above text and will not be elaborated here.

[0108] For example, Figure 2DIn the convolutional neural network structure shown in the figure, the convolutional layer includes 4 convolution kernels, and the convolution kernel size is 3*3. In the first convolution kernel, N fin =4,N fout =6, the compression parameter R is a positive integer greater than 0 and less than or equal to 4. The compression parameter R=4 is determined by the binary search method, that is, the first sub-convolution kernel F1 in the first convolution kernel that meets the preset accuracy is a (3,4) matrix, and the second sub-convolution kernel F2 is a (4,3) matrix. In one embodiment, for Figure 2D The other convolution kernels shown may adopt the same compression method as the first convolution kernel, or may adopt a compression method different from the first convolution kernel, which is not specifically limited in the embodiment of the present invention.

[0109] In one embodiment, when the first formula is expressed as shown in formula (1.2), an adaptive algorithm (for example, a genetic algorithm) can be used to determine the value of the compression parameter R in the convolutional layer neural network. Please refer to the above description for the specific implementation process, which will not be elaborated here.

[0110] (3) LSTM layer neural network:

[0111] Taking the LSTM layer of the neural network as an example, the weight of the LSTM layer is composed of multiple fully connected layer weights. Assume that the weight of the LSTM layer is composed of t fully connected layer weights, t is a positive integer greater than 0. For example, the weights of the jth fully connected layer are (N in_j ,N out_j ), where N in_j represents the number of input neurons in the jth fully connected layer, N out_j represents the number of output neurons in the jth fully connected layer, and the number of weights in the jth fully connected layer is N in_j *N out_j .

[0112] In the LSTM layer neural network, the LSTM layer includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: M j ≈M j_1 *M j_2 ; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j_1 and the second submatrix M j_2 , the M j_1 N in_j *S matrix, the M j_2 For S*N out_j Matrix; where S is the compression parameter, N in_jis the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the M j_1 The number of output neurons and the M j_2 The number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.

[0113] As mentioned above, the process of adjusting the size of each of the two sub-matrices is actually a dynamic change process of the compression parameter S value to find the best compression parameter S. In practical applications, a binary search method can be used to determine the compression parameter S value in the convolutional layer neural network, so as to obtain a second weight matrix that meets the preset accuracy.

[0114] In the specific implementation, for the jth fully connected layer, the compression parameter S value is different, that is, the first weight matrix is ​​compressed based on multiple different compression ratios. Here, in the jth fully connected layer, the compression ratio

[0115] In the embodiment of the present invention, the implementation process of determining the value of the compression parameter S in the j-th fully connected layer by using a binary search method is described in the above text and will not be repeated here.

[0116] by Figure 2A Take the neural network architecture shown in the figure as an example. The neural network includes an input layer, a hidden layer, and an output layer. The first fully connected layer is between the input layer and the hidden layer, and the second fully connected layer is between the hidden layer and the output layer. For the detailed description of the fully connected layer structure between the input layer and the hidden layer (that is, the first fully connected layer), please refer to the above description, which will not be elaborated here. Figure 2A It can be seen that the two-dimensional parameter matrix of the fully connected layer between the hidden layer and the output layer is (4,2). The two-dimensional parameter matrix (4,2) indicates that in the fully connected layer structure between the hidden layer and the output layer, the number of input neurons is 4, the number of output neurons is 2, and the number of weights is 8. In the specific implementation, these 8 weights can be expressed as a 2-row 4-column weight matrix, and the weight matrix can be expressed as follows Figure 2E As shown. Then, in this case, the compression parameter S value is a positive integer greater than 0 and less than or equal to 2. The compression parameter S=2 is determined by binary search, that is, in the second fully connected layer, the first submatrix M in the second weight matrix that meets the preset accuracy 2_1 is a (4,2) matrix, the second submatrix M 2_2 is a (2,2) matrix. Specifically, for Figure 2AThe compression of the fully connected layer between the input layer and the hidden layer and the fully connected layer between the hidden layer and the output layer can be as follows Figure 2F shown.

[0117] In one embodiment, when the first formula is expressed as shown in formula (1.2), an adaptive algorithm (for example, a genetic algorithm) can be used to determine the compression parameter S value in the LSTM layer neural network. For the specific implementation process, please refer to the above description and will not be elaborated here.

[0118] Step S104: performing neural network calculation according to second input data, wherein the second input data includes a second weight matrix and neuron data.

[0119] In practical applications, the neural network calculations involved here may include artificial neural network operations, convolutional neural network operations, and so on.

[0120] Taking artificial neural network operation as an example, for artificial neural network operation, if the artificial neural network operation has multi-layer operation, the input neurons and output neurons of the multi-layer operation do not refer to the neurons in the input layer and the neurons in the output layer of the entire neural network, but for any two adjacent layers in the network, the neurons in the lower layer of the network forward operation are the input neurons, and the neurons in the upper layer of the network forward operation are the output neurons. Taking convolutional neural network as an example, suppose a convolutional neural network has L layers, K = 1, 2, ..., L-1, for the Kth layer and the K+1th layer, we call the Kth layer the input layer, the neurons therein are the input neurons, and the K+1th layer is called the output layer, the neurons therein are the output neurons. That is, except for the top layer, each layer can be used as an input layer, and the next layer is the corresponding output layer.

[0121] In a specific implementation, the operation in the neural network can be the operation of a layer in the neural network. For a multi-layer neural network, the implementation process is that in the forward operation, after the execution of the previous layer of artificial neural network is completed, the operation instruction of the next layer will use the output neuron calculated in the operation unit as the input neuron of the next layer for operation (or perform certain operations on the output neuron and then use it as the input neuron of the next layer), and at the same time, the weights are also replaced by the weights of the next layer; in the reverse operation, when the reverse operation of the previous layer of artificial neural network is completed, the operation instruction of the next layer will use the input neuron gradient calculated in the operation unit as the output neuron gradient of the next layer for operation (or perform certain operations on the input neuron gradient and then use it as the output neuron gradient of the next layer), and at the same time, the weights are replaced by the weights of the next layer.

[0122] The embodiment of the present invention can obtain at least two sub-matrices containing compression parameters by decomposing the first weight matrix. Then, each of the at least two sub-matrices is solved according to the formula, and the compressed neural network is trained to obtain a second weight matrix that meets the preset accuracy. This solves the problem of irregular topological structure of the neural network that is easily caused by the use of the neural network pruning algorithm in the prior art, and can deeply compress the neural network, reduce the calculation amount of the neural network, and improve the operation speed.

[0123] In order to better implement the above-mentioned solution of the embodiment of the present invention, the present invention also provides a neural network compression device, which is described in detail below with reference to the accompanying drawings:

[0124] like Figure 3A The structure diagram of the neural network compression device provided by the embodiment of the present invention is shown, and the neural network compression device includes: an acquisition unit 300, a compression unit 13 and a calculation unit 304;

[0125] Wherein, the acquisition unit 300 is used to acquire first input data; wherein, the first input data includes a first weight matrix;

[0126] The compression unit 13 is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices;

[0127] The calculation unit 304 is used to perform neural network calculation according to the second input data, wherein the second input data includes the second weight matrix and input neuron data.

[0128] In one embodiment, if Figure 3B As shown, the compression unit 13 includes a decomposition unit 130, a solution unit 131 and a training unit 132;

[0129] The decomposition unit 130 is used to decompose the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices;

[0130] The solving unit 131 is used to determine the size of each submatrix in the at least two submatrices according to a first formula, wherein the first formula is Q≈Q1*Q2*......*Q n ; wherein, Q represents the first weight matrix; Q1 represents the first submatrix of the two submatrices; Q2 represents the second submatrix of the two submatrices; Q n represents the nth submatrix of the at least two submatrices;

[0131] The training unit 132 is used to adjust the size of each sub-matrix of the at least two sub-matrices, and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model.

[0132] Optionally, the solving unit 131 is specifically configured to determine the size of each submatrix in the at least two submatrices according to the first formula and the second formula, wherein the second formula is || Q-Q1*Q2*......*Q n ||≤T, where T represents a preset error threshold.

[0133] Optionally, the training unit 132 is specifically used to adjust the size of each sub-matrix of the at least two sub-matrices, and to obtain a second weight matrix that meets a preset accuracy and has a compression ratio that meets a preset compression ratio with the first weight matrix by training the compressed machine learning model.

[0134] Optionally, the neural network includes a fully connected layer neural network; the first formula includes: M≈M1*M2; the two sub-matrices include a first sub-matrix M1 and a second sub-matrix M2, and M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, N in is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0135] Optionally, the neural network includes a convolutional layer neural network; the convolutional layer neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0136] Optionally, the neural network includes an LSTM layer neural network, the LSTM layer includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: M j ≈M j_1 *M j_2 ; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j_1 and the second submatrix M j_2 , the M j_1 N in_j *S matrix, the M j_2 For S*N out_j Matrix; where S is the compression parameter, N in_j is the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the M j_1 The number of output neurons and the M j_2 The number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.

[0137] The embodiment of the present invention can obtain at least two sub-matrices containing compression parameters by decomposing the first weight matrix. Then, each of the at least two sub-matrices is solved according to the formula, and the compressed neural network is trained to obtain a second weight matrix that meets the preset accuracy. This solves the problem of irregular topological structure of the neural network that is easily caused by the use of the neural network pruning algorithm in the prior art. The deep compression of the neural network can reduce the calculation amount of the neural network and improve the operation speed.

[0138] In order to better implement the above solution of the embodiment of the present invention, the present invention also provides another electronic device, which is described in detail below with reference to the accompanying drawings:

[0139] like Figure 4The structural diagram of the electronic device provided by the embodiment of the present invention is shown, the electronic device 40 may include a processor 401, a memory 404 and a communication module 405, and the processor 401, the memory 404 and the communication module 405 may be interconnected via a bus 406. The memory 404 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 404 may optionally be at least one storage system located away from the aforementioned processor 401. The memory 404 is used to store application code, and may include an operating system, a network communication module, a user interface module and a data processing program. The communication module 405 is used to interact with external devices for information; the processor 401 is configured to call the program code and perform the following steps:

[0140] Acquire first input data; wherein the first input data includes a first weight matrix;

[0141] Compressing the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices;

[0142] A neural network calculation is performed according to second input data, wherein the second input data includes the second weight matrix and input neuron data.

[0143] The processor 401 compresses the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices, which may include:

[0144] Decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices;

[0145] Determine the size of each submatrix in the at least two submatrices, the first formula is Q≈Q1*Q2*......*Q n ; wherein, Q represents the first weight matrix; Q1 represents the first submatrix of the two submatrices; Q2 represents the second submatrix of the two submatrices; Q n represents the nth submatrix of the at least two submatrices;

[0146] The size of each submatrix of the at least two submatrices is adjusted, and a second weight matrix satisfying a preset accuracy is obtained by training a compressed machine learning model.

[0147] The processor 401 determines each sub-matrix of the at least two sub-matrices according to a first formula, wherein the first formula is Q≈Q1*Q2*......*Qn , which may include:

[0148] The size of each of the two sub-matrices is determined according to the first formula and the second formula, wherein the second formula is || Q-Q1*Q2*......*Q n ||≤T, where T represents a preset error threshold.

[0149] The processor 401 adjusts the size of each of the at least two sub-matrices and obtains a second weight matrix that satisfies a preset accuracy by training the compressed machine learning model, which may include:

[0150] The size of each submatrix of the at least two submatrices is adjusted, and the compressed machine learning model is trained to obtain a second weight matrix that meets the preset accuracy and has a compression ratio that meets the preset compression ratio with the first weight matrix.

[0151] Wherein, the neural network is a fully connected layer neural network; the first formula includes: M≈M1*M2; the two sub-matrices refer to a first sub-matrix M1 and a second sub-matrix M2, wherein M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, N in is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0152] Wherein, the neural network is a convolutional neural network; the convolutional neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0153] Wherein, the neural network is an LSTM layer neural network; the LSTM layer neural network includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: M j ≈M j_1 *M j_2 ; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j_1 and the second submatrix M j_2 , the M j_1 N in_j *S matrix, the M j_2 For S*N out_j Matrix; where S is the compression parameter, N in_j is the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the M j_1 The number of output neurons and the M j_2 The number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.

[0154] It should be noted that the execution steps of the processor in the electronic device 40 in the embodiment of the present invention can refer to the above-mentioned method embodiments. Figure 1B The specific implementation method of the operation of the electronic device in the embodiment will not be repeated here.

[0155] In practical applications, the processor 401 in the electronic device 40 includes but is not limited to only one. In one embodiment, the electronic device 40 also includes a graphics processor GPU (GPU, Graphic ProcessingUni) for processing images, and may also include an embedded neural network processor (NPU, Neural-network Process Units). In this case, the compression method for the neural network can be integrated into the NPU. In one embodiment, the processor 401 can control the NPU to execute the compression method for the first weight matrix.

[0156] In a specific implementation, as mentioned above, the electronic device 40 may include a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a camcorder, a projector, a watch, a headset, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device, which is not specifically limited in the embodiments of the present invention.

[0157] The embodiment of the present invention also provides a computer storage medium for storing the above Figure 1B The computer software instructions used by the electronic device shown include a program for executing the above method embodiment. By executing the stored program, the first weight matrix can be compressed to obtain a second weight matrix that meets the preset accuracy, thereby avoiding irregular topological structure of the neural network model and reducing the amount of computation of the neural network.

[0158] As mentioned above, the compression unit provided by the present application can be used to compress the first weight matrix to obtain the second weight matrix to avoid the problem of irregular topological structure of the neural network model. In practical applications, the above compression unit can be used in neural network calculations, specifically, in a computing device for performing neural network calculations. Figure 5 The computing device shown is used to describe the present invention.

[0159] See also Figure 5 , Figure 5 1 is a schematic diagram of a structure of a computing device provided by an embodiment of the present invention, the computing device is used to perform machine learning calculations, the computing device includes: a controller unit 11, a computing unit 12 and a compression unit 13, wherein the controller unit 11 is connected to the computing unit 12 and the compression unit 13 respectively;

[0160] The controller unit 11 is used to obtain a compression request for first input data, and instruct the compression unit to compress the first input data according to the compression request; wherein the first input data includes a first weight matrix; in an optional solution, the compression request can be triggered by a data input and output unit, and the data input and output unit can specifically be one or more data I / O interfaces or I / O pins;

[0161] The compression unit 13 is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices;

[0162] In a specific implementation, the compression unit 13 includes a decomposition unit 131, a solution unit 132 and a training unit 133. The decomposition unit 131 is used to decompose the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices; the solution unit 132 is used to determine the size of each sub-matrix in the at least two sub-matrices according to a first formula, and the first formula is Q≈Q1*Q2*......*Q n ; wherein, Q represents the first weight matrix; Q1 represents the first submatrix of the two submatrices; Q2 represents the second submatrix of the two submatrices; Q nRepresents the nth submatrix in the at least two submatrices; a training unit 133 is used to adjust the size of each submatrix in the at least two submatrices, and to obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model.

[0163] The controller unit 11 is also used to obtain second input data and calculation instructions; the second input data includes a second weight matrix and input neuron data; in an optional scheme, specifically, the second input data and calculation instructions can be obtained through a data input and output unit, which can specifically be one or more data I / O interfaces or I / O pins.

[0164] The controller unit 11 is further used to parse the calculation instruction to obtain multiple operation instructions, and send the multiple operation instructions and the second input data to the operation unit;

[0165] The operation unit 12 is used to obtain the operation instruction and perform neural network calculation according to the operation instruction and the second input data.

[0166] In one implementation, considering that a "compression instruction" is provided in the above-mentioned computing device, in this case, the controller unit 11 is used to obtain first input data and a compression instruction; wherein, the first input data includes a first weight matrix; in an optional scheme, specifically, the first input data and the compression instruction method can be obtained through a data input and output unit, and the data input and output unit can specifically be one or more data I / O interfaces or I / O pins.

[0167] The controller unit 11 is further configured to parse the compression instruction to obtain a plurality of operation instructions, and send the plurality of operation instructions and the first weight matrix to the compression unit;

[0168] The compression unit 13 is used to compress the first weight matrix into a second weight matrix according to the multiple operation instructions;

[0169] The controller unit 11 is also used to obtain second input data and calculation instructions; the second input data includes the second weight matrix and input neuron data; in an optional scheme, specifically, the second input data and calculation instruction method can be obtained through a data input and output unit, and the data input and output unit can specifically be one or more data I / O interfaces or I / O pins.

[0170] The controller unit 11 is further used to parse the calculation instruction to obtain multiple operation instructions, and send the multiple operation instructions and the second input data to the operation unit;

[0171] The operation unit 12 is used to obtain the operation instruction and perform neural network calculation according to the operation instruction and the second input data.

[0172] In a specific implementation, the operation unit 12 includes a master processing circuit 101 and a plurality of slave processing circuits 102, wherein the master processing circuit 101 is configured to perform pre-order processing on the second input data and transmit data and operation instructions between the plurality of slave processing circuits;

[0173] A plurality of slave processing circuits 102, configured to perform intermediate operations in parallel according to data and operation instructions transmitted from the master processing circuit to obtain a plurality of intermediate results, and transmit the plurality of intermediate results to the master processing circuit;

[0174] The main processing circuit 101 is used to perform subsequent processing on the multiple intermediate results to obtain the calculation result of the calculation instruction.

[0175] Optionally, the second input data may specifically include: a second weight matrix and input neuron data. The calculation result may specifically be: the result of the neural network operation, ie, the output neuron data.

[0176] In one embodiment, the computing device may further include: the storage unit 10 and a direct memory access unit 50. The storage unit 10 may include: one or any combination of a register and a cache. Specifically, the cache is used to store the computing instructions; the register is used to store the input data and scalars; the cache is a high-speed temporary cache. The direct memory access unit 50 is used to read or store data from the storage unit 10.

[0177] In the present application embodiment, Figure 6 As shown, the controller unit 11 includes: an instruction cache unit 110, an instruction processing unit 111, a dependency processing unit 112 and a storage queue unit 113;

[0178] The instruction cache unit 110 is used to store the computing instructions associated with the artificial neural network operation. When the zeroth computing instruction is being executed, other instructions that have not been submitted for execution are cached in the instruction cache unit 110. After the zeroth computing instruction is executed, if the first computing instruction is the earliest instruction among the instructions that have not been submitted in the instruction cache unit 110, the first computing instruction will be submitted. Once submitted, the change of the device state caused by the operation performed by the instruction cannot be undone.

[0179] The instruction processing unit 111 is used to obtain the calculation instruction from the instruction cache unit, and parse the calculation instruction to obtain multiple operation instructions;

[0180] The dependency processing unit 112 is used to determine whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction when there are multiple operation instructions. If the first operation instruction has an association relationship with the zeroth operation instruction, the first operation instruction is stored in the instruction queue unit 113. After the zeroth operation instruction is executed, the association relationship between the first operation instruction and the zeroth operation instruction is released, and the first operation instruction is extracted from the instruction queue unit 113 and transmitted to the operation unit.

[0181] The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises:

[0182] The first storage address interval of the data (e.g., a matrix) required in the first operation instruction is extracted according to the first operation instruction, and the zeroth storage address interval of the matrix required in the zeroth operation instruction is extracted according to the zeroth operation instruction. If the first storage address interval and the zeroth storage address interval have an overlapping area, it is determined that the first operation instruction and the zeroth operation instruction have an associated relationship. If the first storage address interval and the zeroth storage address interval do not have an overlapping area, it is determined that the first operation instruction and the zeroth operation instruction have no associated relationship.

[0183] The storage queue unit 113 is used to store an instruction queue, which includes: a plurality of operation instructions or calculation instructions to be executed in the order of the queue.

[0184] In the present application embodiment, Figure 6 As shown, the instruction processing unit 111 includes an instruction fetch module, a decoding module and an instruction queue, wherein the instruction fetch module is used to obtain the calculation instructions of the neural network from the instruction cache unit 110; the decoding module is used to decode the calculation instructions obtained by the instruction fetch module to obtain the operation instructions of the neural network; the instruction queue is used to sequentially store the operation instructions obtained after decoding in the order to be executed.

[0185] For example, in an optional technical solution, the main operation processing circuit may also include a controller unit, which may include a main instruction processing unit, specifically for decoding instructions into microinstructions. Of course, in another optional solution, the slave operation processing circuit may also include another controller unit, which includes a slave instruction processing unit, specifically for receiving and processing microinstructions. The above-mentioned microinstructions may be the next level instructions of the instructions, which may be obtained by splitting or decoding the instructions, and can be further decoded into control signals for each component, each unit or each processing circuit.

[0186] In an optional solution, the structure of the calculation instruction may be as shown in the following table.

[0187] Table 1

[0188] Operation Code Register or immediate value Register / Immediate ...

[0189] The ellipsis in the above table indicates that multiple registers or immediate values ​​can be included.

[0190] In another optional solution, the computing instruction may include: one or more operation domains and an operation code. The computing instruction may include a neural network operation instruction, and may also include the compression instruction involved above. Taking the neural network operation instruction as an example, as shown in Table 1, register number 0, register number 1, register number 2, register number 3, and register number 4 may be operation domains. Each register number 0, register number 1, register number 2, register number 3, and register number 4 may be the number of one or more registers.

[0191] Table 2

[0192]

[0193] The above-mentioned registers can be off-chip memories, and of course in practical applications, they can also be on-chip memories for storing data. The data can specifically be n-dimensional data, where n is an integer greater than or equal to 1. For example, when n=1, it is 1-dimensional data, i.e., a vector; when n=2, it is 2-dimensional data, i.e., a matrix; and when n=3 or more, it is a multi-dimensional tensor.

[0194] In the embodiment of the present invention, the process of the computing device performing the neural network operation is as follows: Figure 7 As shown, including:

[0195] Step S1: The controller unit receives a compression instruction, decodes the compression instruction into a plurality of operation instructions, and sends the plurality of operation instructions to the compression unit.

[0196] After the controller unit reads the compression instruction from the storage unit, it parses the compression instruction into an operation instruction and sends the operation instruction to the compression unit. Specifically, the instruction fetch module of the instruction processing unit 111 in the controller unit 11 obtains the compression instruction from the instruction cache unit 110, and transmits the instruction to the decoding module, the decoding module decodes the compression instruction to obtain the operation instruction, and splits the operation instruction into an operation code and various operation domains according to the preset instruction rule, wherein the composition and function of the operation code and the operation domain can be referred to the foregoing, and will not be repeated here. The decoding module transmits the operation instruction obtained after decoding to the instruction queue for sequential storage, in which the data address of the to-be-processed data corresponding to the instruction is obtained according to the operation code and operation of the operation instruction in the instruction queue, and the data address is transmitted to the dependency processing unit 112, the dependency processing unit analyzes whether there is an association relationship between the instruction and the instruction being executed, if so, the operation instruction is stored in the storage queue unit 113 until the association relationship is resolved, if there is no association relationship, the operation instruction is sent to the compression unit to perform the corresponding operation.

[0197] S2. The compression unit receives the operation instruction sent by the control unit, and performs compression processing according to the first weight matrix read from the storage unit to obtain a second weight matrix that meets a preset accuracy.

[0198] In a specific implementation, for the specific implementation of compressing the first weight matrix to obtain the second weight matrix, please refer to the above text description, which will not be elaborated here.

[0199] S3. The controller unit obtains second input data and calculation instructions, wherein the second input data includes a second weight matrix and input neuron data.

[0200] S4. The controller unit parses the calculation instruction into an operation instruction, and sends the operation instruction and the second input data to the operation unit.

[0201] In a specific implementation, the controller unit obtains calculation instructions and parses the calculation instructions to obtain implementation methods of multiple operation instructions. Please refer to the text description of the controller unit obtaining compression instructions mentioned above, and no further details will be given here.

[0202] S5. The operation unit receives the operation instruction sent by the controller unit, and performs neural network calculation according to the operation instruction and the second input data.

[0203] In practical applications, the neural network calculations involved here may include artificial neural network operations, convolutional neural network operations, and so on.

[0204] Taking artificial neural network operation as an example, for artificial neural network operation, if the artificial neural network operation has multi-layer operation, the input neurons and output neurons of the multi-layer operation do not refer to the neurons in the input layer and the neurons in the output layer of the entire neural network, but for any two adjacent layers in the network, the neurons in the lower layer of the network forward operation are the input neurons, and the neurons in the upper layer of the network forward operation are the output neurons. Taking convolutional neural network as an example, suppose a convolutional neural network has L layers, K = 1, 2, ..., L-1, for the Kth layer and the K+1th layer, we call the Kth layer the input layer, the neurons therein are the input neurons, and the K+1th layer is called the output layer, the neurons therein are the output neurons. That is, except for the top layer, each layer can be used as an input layer, and the next layer is the corresponding output layer.

[0205] In a specific implementation, the operation in the neural network can be the operation of a layer in the neural network. For a multi-layer neural network, the implementation process is that in the forward operation, after the execution of the previous layer of artificial neural network is completed, the operation instruction of the next layer will use the output neuron calculated in the operation unit as the input neuron of the next layer for operation (or perform certain operations on the output neuron and then use it as the input neuron of the next layer), and at the same time, the weights are also replaced by the weights of the next layer; in the reverse operation, when the reverse operation of the previous layer of artificial neural network is completed, the operation instruction of the next layer will use the input neuron gradient calculated in the operation unit as the output neuron gradient of the next layer for operation (or perform certain operations on the input neuron gradient and then use it as the output neuron gradient of the next layer), and at the same time, the weights are replaced by the weights of the next layer.

[0206] Taking the forward operation process of the neural network as an example, first, the operation unit reads the second input data from the storage unit, wherein the second input data includes a second weight matrix and input neuron data.

[0207] Secondly, the main processing circuit reads the corresponding neuron data and broadcasts the neuron data to each slave processing circuit in the specified order. In practical applications, the neuron data can be broadcast only once, and the slave processing circuit temporarily stores the data in a cache or register after receiving the data, so as to facilitate its reuse. In addition, the neuron data can also be broadcast multiple times, and the slave processing circuit can use the data directly after receiving it without multiplexing. In one possible implementation, the main processing circuit directly broadcasts the neuron data after reading the neuron data.

[0208] Afterwards, each slave processing circuit performs an inner product operation on the read neuron data and the second weight matrix according to the operation instruction, and then transmits the inner product result back to the master processing circuit.

[0209] In one of the embodiments, the slave processing circuit may transmit the partial sum obtained from each inner product operation back to the main processing circuit for accumulation; in one of the embodiments, the partial sum obtained from each inner product operation performed by the slave processing circuit may be stored in the register and / or on-chip cache of the slave processing circuit, and transmitted back to the main processing circuit after the accumulation is completed; in one of the embodiments, the partial sum obtained from each inner product operation performed by the slave processing circuit may be stored in the register and / or on-chip cache of the slave processing circuit for accumulation in some cases, and transmitted to the main processing circuit for accumulation in some cases, and transmitted back to the main processing circuit after the accumulation is completed.

[0210] Finally, the main processing circuit accumulates and activates the results of each slave processing circuit until the forward operation process of the neural network is completed, and the error value between the predicted result and the actual result, that is, the neuron gradient data of the last layer, is obtained and saved in the storage unit.

[0211] In the embodiment of the present invention, the computing unit 12 can be configured as a one-master-multiple-slave structure. Figure 8 As shown, it may include a master processing circuit 101 and a plurality of slave processing circuits 102. In one embodiment, as Figure 8 As shown, multiple slave processing circuits are distributed in an array; each slave processing circuit is connected to other adjacent slave processing circuits, and the master processing circuit is connected to k slave processing circuits of the multiple slave processing circuits, and the k slave processing circuits are: n slave processing circuits in the first row, n slave processing circuits in the mth row, and m slave processing circuits in the first column. It should be noted that, as Figure 8 The K slave processing circuits shown include only n slave processing circuits in the 1st row, n slave processing circuits in the mth row, and m slave processing circuits in the 1st column, that is, the k slave processing circuits are slave processing circuits directly connected to the master processing circuit among the multiple slave processing circuits.

[0212] K slave processing circuits are used to forward data and instructions between the master processing circuit and multiple slave processing circuits.

[0213] Optional, such as Fig. 9 As shown, the main processing circuit may further include: one or any combination of a conversion processing circuit 110, an activation processing circuit 111, and an addition processing circuit 112;

[0214] The conversion processing circuit 110 is used to perform an exchange between a first data structure and a second data structure (e.g., conversion between continuous data and discrete data) on a data block or an intermediate result received by the main processing circuit; or perform an exchange between a first data type and a second data type (e.g., conversion between a fixed-point type and a floating-point type) on a data block or an intermediate result received by the main processing circuit;

[0215] An activation processing circuit 111 is used to perform activation operations on data in the main processing circuit;

[0216] The addition processing circuit 112 is used to perform addition operations or accumulation operations.

[0217] The master processing circuit is used to determine that the input neuron is broadcast data, the weight is distribution data, distribute the distribution data into multiple data blocks, and send at least one data block of the multiple data blocks and at least one operation instruction of the multiple operation instructions to the slave processing circuit;

[0218] The multiple slave processing circuits are used to perform operations on the received data blocks according to the operation instructions to obtain intermediate results, and transmit the operation results to the master processing circuit;

[0219] The main processing circuit is used to process the intermediate results sent by the multiple slave processing circuits to obtain the result of the calculation instruction, and send the result of the calculation instruction to the controller unit.

[0220] The slave processing circuit includes: a multiplication processing circuit;

[0221] The multiplication processing circuit is used to perform a product operation on the received data block to obtain a product result;

[0222] A forwarding processing circuit (optional) is used to forward the received data block or product result.

[0223] The accumulation processing circuit is used to perform an accumulation operation on the product result to obtain the intermediate result.

[0224] In another embodiment, the operation instruction is a matrix multiplication instruction, an accumulation instruction, an activation instruction, or the like.

[0225] The following is an explanation of the neural network operation instructions. Figure 5 The specific calculation method of the calculation device shown in the figure. For the neural network operation instruction, the formula that actually needs to be executed can be: s=s(∑wx i +b), where the weight w is multiplied by the input data x i , sum it up, then add the bias b and do the activation operation s(h) to get the final output result s.

[0226] In an alternative embodiment, Fig.10As shown, the operation unit includes: a tree module 40, the tree module includes: a root port 401 and multiple branch ports 404, the root port of the tree module is connected to the main processing circuit, and the multiple branch ports of the tree module are respectively connected to one of the multiple slave processing circuits; the above-mentioned tree module has a transceiver function, and the tree module has a transceiver function for forwarding data blocks, weights and operation instructions between the main processing circuit and the multiple slave processing circuits, that is, the data of the main processing circuit can be transmitted to each slave processing circuit, and the data of each slave processing circuit can also be transmitted to the main processing circuit.

[0227] Optionally, the tree module is an optional result of the computing device, which may include at least one layer of nodes, the nodes are line structures with forwarding functions, and the nodes themselves may not have computing functions. If the tree module has zero-layer nodes, the tree module is not needed.

[0228] Optionally, the tree module may be an n-ary tree structure, for example, Fig.11 The binary tree structure shown in the figure can of course also be a ternary tree structure, and n can be an integer greater than or equal to 2. The specific implementation of the present application does not limit the specific value of n, and the number of layers can also be 2. The slave processing circuit can connect nodes of other layers except the penultimate layer nodes, for example, it can connect nodes such as Fig.11 The nodes of the penultimate layer are shown.

[0229] Optionally, the above computing unit may carry a separate cache, such as Fig.12 As shown, it may include: a neuron cache unit, wherein the neuron cache unit 63 caches the input neuron vector data and the output neuron value data of the slave processing circuit.

[0230] like Fig.13 As shown, the operation unit may further include: a weight cache unit 64, which is used to cache the weight data required by the slave processing circuit during the calculation process.

[0231] In an optional embodiment, the computing unit 12 is as follows: Fig.14 As shown, it may include a branch processing circuit 103; its specific connection structure is as follows Fig.12 As shown,

[0232] The master processing circuit 101 is connected to the branch processing circuit 103 (one or more), and the branch processing circuit 103 is connected to one or more slave processing circuits 102;

[0233] The branch processing circuit 103 is used to forward data or instructions between the main processing circuit 101 and the slave processing circuit 102 .

[0234] In an optional embodiment, taking the full connection operation in the neural network operation as an example, the process can be: y = f (wx + b), where x is the input neuron matrix, w is the weight matrix, b is the bias scalar, and f is the activation function, which can be: sigmoid function, any one of tanh, relu, and softmax functions. Here, it is assumed that the binary tree structure has 8 slave processing circuits, and the implementation method can be:

[0235] The controller unit obtains the input neuron matrix x, the weight matrix w and the full connection operation instruction from the storage unit, and transmits the input neuron matrix x, the weight matrix w and the full connection operation instruction to the main processing circuit;

[0236] The master processing circuit determines that the input neuron matrix x is broadcast data, determines that the weight matrix w is distributed data, splits the weight matrix w into 8 sub-matrices, and then distributes the 8 sub-matrices to 8 slave processing circuits through the tree module, and broadcasts the input neuron matrix x to the 8 slave processing circuits.

[0237] The slave processing circuit performs multiplication and accumulation operations of the eight sub-matrices and the input neuron matrix x in parallel to obtain eight intermediate results, and sends the eight intermediate results to the master processing circuit;

[0238] The main processing circuit is used to sort the 8 intermediate results to obtain the operation result of wx, perform the operation of bias b on the operation result and then perform the activation operation to obtain the final result y, and send the final result y to the controller unit, and the controller unit outputs or stores the final result y in the storage unit.

[0239] like Figure 5 The method for the computing device shown to execute the neural network forward operation instruction may specifically be:

[0240] The controller unit extracts the neural network forward operation instruction, the operation domain corresponding to the neural network operation instruction and at least one operation code from the instruction storage unit, transmits the operation domain to the data access unit, and sends the at least one operation code to the operation unit.

[0241] The controller unit extracts the weight w and bias b corresponding to the operation domain from the storage unit (when b is 0, there is no need to extract bias b), and transmits the weight w and bias b to the main processing circuit of the operation unit. The controller unit extracts the input data Xi from the storage unit and sends the input data Xi to the main processing circuit.

[0242] The main processing circuit determines that the at least one operation code is a multiplication operation, determines that the input data Xi is broadcast data, determines that the weight data is distribution data, and splits the weight w into n data blocks;

[0243] The instruction processing unit of the controller unit determines the multiplication instruction, the bias instruction and the accumulation instruction according to the at least one operation code, and sends the multiplication instruction, the bias instruction and the accumulation instruction to the main processing circuit, the main processing circuit sends the multiplication instruction and the input data Xi to multiple slave processing circuits in a broadcast manner, and distributes the n data blocks to the multiple slave processing circuits (for example, if there are n slave processing circuits, then each slave processing circuit sends a data block); multiple slave processing circuits are used to perform multiplication operations on the input data Xi and the received data blocks according to the multiplication instruction to obtain an intermediate result, and send the intermediate result to the main processing circuit, the main processing circuit performs accumulation operations on the intermediate results sent by the multiple slave processing circuits according to the accumulation instruction to obtain an accumulation result, adds the bias b to the accumulation result according to the bias instruction to obtain a final result, and sends the final result to the controller unit.

[0244] In addition, the order of addition and multiplication operations can be reversed.

[0245] The technical solution provided by the present application realizes the multiplication operation and bias operation of the neural network through one instruction, namely the neural network operation instruction. The intermediate results of the neural network calculation do not need to be stored or extracted, which reduces the storage and extraction operations of the intermediate data. Therefore, it has the advantages of reducing the corresponding operation steps and improving the calculation effect of the neural network.

[0246] The present application also discloses a machine learning computing device, which includes one or more computing devices mentioned in the present application, and is used to obtain data to be calculated and control information from other processing devices, perform specified machine learning operations, and transmit the execution results to peripheral devices through I / O interfaces. Peripheral devices include cameras, displays, mice, keyboards, network cards, wifi interfaces, and servers. When more than one computing device is included, the computing devices can be linked and data can be transmitted through a specific structure, for example, interconnected and data can be transmitted through a PCIE bus to support larger-scale machine learning operations. At this time, the same control system can be shared, or each independent control system can be provided; memory can be shared, or each accelerator can have its own memory. In addition, the interconnection method can be any interconnection topology.

[0247] The machine learning computing device has high compatibility and can be connected to various types of servers through a PCIE interface.

[0248] The present application also discloses a combined processing device, which includes the above-mentioned machine learning computing device, a universal interconnection interface, and other processing devices. The machine learning computing device interacts with other processing devices to jointly complete the operation specified by the user. Fig.15 A schematic diagram of a combined processing device.

[0249] Other processing devices include one or more types of processors such as central processing unit (CPU), graphics processing unit (GPU), neural network processor, and other general / special processors. There is no limit on the number of processors included in other processing devices. Other processing devices serve as interfaces between the machine learning computing device and external data and control, including data handling, to complete basic control of the machine learning computing device such as starting and stopping; other processing devices can also collaborate with the machine learning computing device to complete computing tasks.

[0250] A universal interconnection interface is used to transmit data and control instructions between the machine learning computing device and other processing devices. The machine learning computing device can obtain the required input data from other processing devices and write it into the storage device on the machine learning computing device chip; it can obtain control instructions from other processing devices and write them into the control cache on the machine learning computing device chip; it can also read data in the storage module of the machine learning computing device and transmit it to other processing devices.

[0251] Optionally, the structure is Fig.16 As shown, a storage device may also be included, and the storage device is connected to the machine learning operation device and the other processing device respectively. The storage device is used to store data in the machine learning operation device and the other processing device, and is particularly suitable for data that cannot be fully stored in the internal storage of the machine learning operation device or other processing devices.

[0252] The combined processing device can be used as a SOC chip system for mobile phones, robots, drones, video surveillance equipment and other devices, effectively reducing the core area of ​​the control part, improving the processing speed, and reducing the overall power consumption. In this case, the universal interconnection interface of the combined processing device is connected to certain components of the device. Certain components include cameras, displays, mice, keyboards, network cards, and wifi interfaces.

[0253] In some embodiments, a chip is also applied for, which includes the above-mentioned machine learning computing device or combined processing device.

[0254] In some embodiments, a chip packaging structure is applied for, which includes the above-mentioned chip.

[0255] In some embodiments, a board is applied for, which includes the above chip packaging structure. Fig.17 , Fig.17 A board is provided. In addition to the chip 389, the board may also include other supporting components, including but not limited to: a storage device 390, an interface device 391 and a control device 392;

[0256] The memory device 390 is connected to the chip in the chip package structure through a bus for storing data. The memory device may include multiple groups of storage units 393. Each group of storage units is connected to the chip through a bus. It is understood that each group of storage units may be DDR SDRAM (English: Double Data Rate SDRAM, double rate synchronous dynamic random access memory).

[0257] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read out on the rising and falling edges of the clock pulse. The speed of DDR is twice that of standard SDRAM. In one embodiment, the storage device may include 4 groups of storage units. Each group of storage units may include multiple DDR4 particles (chips). In one embodiment, the chip may include 4 72-bit DDR4 controllers, 64 bits of the above 72-bit DDR4 controllers are used to transmit data, and 8 bits are used for ECC verification. It can be understood that when DDR4-3200 particles are used in each group of storage units, the theoretical bandwidth of data transmission can reach 25600MB / s.

[0258] In one embodiment, each group of the storage units includes a plurality of double rate synchronous dynamic random access memories arranged in parallel. DDR can transmit data twice in one clock cycle. A controller for controlling DDR is arranged in the chip to control the data transmission and data storage of each of the storage units.

[0259] The interface device is electrically connected to the chip in the chip packaging structure. The interface device is used to realize data transmission between the chip and an external device (such as a server or a computer). For example, in one embodiment, the interface device can be a standard PCIE interface. For example, the data to be processed is transmitted to the chip by the server through the standard PCIE interface to realize data transfer. Preferably, when the PCIE 3.0X 16 interface is used for transmission, the theoretical bandwidth can reach 16000MB / s. In another embodiment, the interface device can also be other interfaces. This application does not limit the specific forms of expression of the above-mentioned other interfaces. The interface unit can realize the switching function. In addition, the calculation results of the chip are still transmitted back to the external device (such as a server) by the interface device.

[0260] The control device is electrically connected to the chip. The control device is used to monitor the state of the chip. Specifically, the chip and the control device can be electrically connected via an SPI interface. The control device may include a single-chip microcomputer (Micro Controller Unit, MCU). For example, the chip may include multiple processing chips, multiple processing cores or multiple processing circuits, which can drive multiple loads. Therefore, the chip can be in different working states such as multi-load and light load. The control device can realize the regulation of the working states of multiple processing chips, multiple processing and / or multiple processing circuits in the chip.

[0261] In some embodiments, an electronic device is applied for, which includes the above-mentioned board.

[0262] Electronic devices include data processing devices, robots, computers, printers, scanners, tablet computers, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cloud servers, cameras, camcorders, projectors, watches, headphones, mobile storage, wearable devices, vehicles, household appliances, and / or medical devices.

[0263] The transportation means include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical equipment includes magnetic resonance imaging, ultrasound machines and / or electrocardiographs.

[0264] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0265] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0266] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.

[0267] 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 distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0268] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.

[0269] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.

[0270] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.

[0271] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A neural network compression device, characterized in that: include: An acquisition unit, configured to acquire first input data; wherein the first input data comprises a first weight matrix; A compression unit, used for compressing the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two sub-matrices; A computing unit, configured to perform neural network calculation according to second input data, wherein the second input data includes the second weight matrix and input neuron data; and the neural network is a convolutional layer neural network; The compression unit comprises: A decomposition unit, used for decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two sub-matrices; A solving unit, configured to determine the size of each submatrix of the at least two submatrices according to a first formula; A training unit, used for adjusting the size of each submatrix of the at least two submatrices, and obtaining a second weight matrix satisfying a preset accuracy by training the compressed machine learning model; The convolutional neural network includes N fin *N fout convolution kernels; the first formula includes: F≈F1*F2; where F represents the N fin *N fout Any convolution kernel among the convolution kernels; F1 is the first sub-convolution kernel; F2 is the second sub-convolution kernel; the first sub-convolution kernel F1 is (K x , R), the second sub-convolution kernel F2 is (R, K y ), (K x , K y ) represents the size of the convolution kernel, R is a compression parameter, and R is greater than 0 and less than or equal to min(K x , K y ) is a positive integer; The computing unit comprises: a master processing circuit and a plurality of slave processing circuits; The master processing circuit is used to perform pre-order processing on the second input data and transmit data and operation instructions between the plurality of slave processing circuits; The multiple slave processing circuits are used to perform intermediate operations in parallel according to the data and operation instructions transmitted from the master processing circuit to obtain multiple intermediate results, and transmit the multiple intermediate results to the master processing circuit; The main processing circuit is used to perform subsequent processing on the multiple intermediate results to obtain the calculation result of the calculation instruction.

2. The device according to claim 1, characterized in that The compression unit comprises: The first formula is Q≈Q1*Q2*......*Q n ; wherein, Q represents a first weight matrix; Q1 represents a first submatrix in the at least two submatrices; Q2 represents a second submatrix in the at least two submatrices; Q n represents the nth submatrix of the at least two submatrices.

3. The device according to claim 2, characterized in that The solving unit is specifically used for: The size of each submatrix in the at least two submatrices is determined according to the first formula and the second formula, wherein the second formula is || Q-Q1*Q2*......*Q n ||≤T, where T represents a preset error threshold.

4. The device according to claim 2 or 3, characterized in that The training unit is specifically used for: The size of each submatrix of the at least two submatrices is adjusted, and the compressed machine learning model is trained to obtain a second weight matrix that meets the preset accuracy and has a compression ratio that meets the preset compression ratio with the first weight matrix.

5. The device according to any one of claims 2 to 4, characterized in that: The neural network is a fully connected layer neural network; the at least two sub-matrices include two sub-matrices; the first formula includes: M≈M1*M2; the two sub-matrices include a first sub-matrix M1 and a second sub-matrix M2, and M1 is N in *K matrix, the M2 is K*N out Matrix; where K is the compression parameter, N in is the number of input neurons of the neural network, N out is the number of output neurons of the neural network; the compression parameter is used to characterize the number of output neurons of M1 and the number of input neurons of M2, and K is greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

6. The device according to any one of claims 2 to 4, characterized in that: The neural network is an LSTM layer neural network; The LSTM layer neural network includes N fully connected layers, where N is a positive integer greater than 0; for the jth fully connected layer, the first formula includes: j ≈M j _1*M j _2; The two sub-matrices in the j-th fully connected layer include the first sub-matrix M j _1 and the second submatrix M j _2, the M j _1 is N in_j *S matrix, the M j _2 is S*N out_j Matrix; where S is the compression parameter, N in_j is the number of input neurons in the jth fully connected layer of the neural network, N out_j is the number of output neurons of the jth fully connected layer of the neural network; the compression parameter is used to characterize the M j _1 the number of output neurons and the M j _2, the number of input neurons, where S is greater than 0 and less than or equal to min(N in_j , N out_j ) is a positive integer.