A computing device and related products

By decomposing the weight matrix of the neural network model into multiple summations and adjusting their sizes, the problem of irregular topology after pruning is solved, and the deep compression and operation speed of the neural network are improved.

CN111382848BActive Publication Date: 2024-08-23CAMBRICON TECH CO LTD

Patent Information

Application Number
CN201811619060.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-27
Publication Date
2024-08-23
Estimated Expiration
2039-09-20

AI Technical Summary

Technical Problem

In the existing technology, the neural network model easily causes the topology structure to become irregular during the pruning process, which increases the demand for computing resources and storage resources and reduces the computing speed.

Method used

By compressing the first weight matrix into a second weight matrix, where the second weight matrix includes at least two summation terms, each summation term includes multiple compression parameters, ensuring that the topology of the neural network model remains unchanged , reduce the amount of calculation.

Benefits of technology

It effectively avoids the problem of the neural network model topology becoming irregular, reduces the computing resource requirements, and improves the computing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111382848B
    Figure CN111382848B
Patent Text Reader

Abstract

The present application provides a computing device and related products, wherein the computing device includes a compression unit, a computing unit, and a controller unit; a first weight matrix is ​​compressed 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 application relates to the field of information processing technology, and in particular to a computing device and related products. 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 application provide a computing device and related products, which can ensure that the topological structure of the neural network model remains unchanged during the neural network compression process, thereby avoiding the irregularity of the topological structure of the neural network model and reducing the amount of computation of the neural network.

[0006] In a first aspect, a computing device is provided, the computing device being used to perform machine learning calculations of a machine learning model, the computing device comprising: a compression unit, an operation unit, and a controller unit;

[0007] The controller unit is configured 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;

[0008] The compression unit is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items;

[0009] The controller unit is further used to obtain second input data and calculation instructions; the second input data includes the second weight matrix and input neuron data;

[0010] The controller unit is further configured to parse the calculation instruction to obtain a plurality of operation instructions, and send the plurality of operation instructions and the second input data to the operation unit;

[0011] The operation unit obtains the operation instruction and performs neural network calculation according to the operation instruction and the second input data.

[0012] Through the present application, the first weight matrix can be compressed by a compression unit to obtain a second weight matrix, wherein the second weight matrix includes at least two summation items, and each of the two summation items includes multiple compression parameters. Then, neural network calculations can be performed according to the second weight matrix and input neuron data, which solves the problem of irregular topological structure of the neural network that is easily caused by the use of neural network pruning algorithms in the prior art. The neural network can be deeply compressed, the calculation amount of the neural network can be reduced, and the operation speed can be improved.

[0013] In a second aspect, an embodiment of the present application provides a machine learning computing device, which includes one or more computing devices described in the first aspect. The machine learning computing device is used to obtain data to be computed and control information from other processing devices, and perform specified machine learning operations, and transmit the execution results to other processing devices through an I / O interface;

[0014] When the machine learning computing device includes a plurality of computing devices, the plurality of computing devices may be linked and transmit data through a specific structure;

[0015] Among them, multiple computing devices are interconnected and transmit data through a PCIE bus to support larger-scale machine learning operations; multiple computing devices share the same control system or have their own control systems; multiple computing devices share memory or have their own memory; the interconnection method of multiple computing devices is any interconnection topology.

[0016] In a third aspect, an embodiment of the present application provides a combined processing device, which includes a machine learning processing device, a universal interconnection interface, and other processing devices as described in the third aspect. The machine learning operation device interacts with the above-mentioned other processing devices to jointly complete the operation specified by the user. The combined processing device may also include a storage device, which is respectively connected to the machine learning operation device and the other processing device, and is used to save data of the machine learning operation device and the other processing device.

[0017] In a fourth aspect, an embodiment of the present application provides a neural network chip, which includes the computing device described in the first aspect, the machine learning computing device described in the second aspect, or the combined processing device described in the third aspect.

[0018] In a fifth aspect, an embodiment of the present application provides a neural network chip packaging structure, which includes the neural network chip described in the fourth aspect above.

[0019] In a sixth aspect, an embodiment of the present application provides a board card, which includes the neural network chip packaging structure described in the fifth aspect above.

[0020] In a seventh aspect, an embodiment of the present application provides an electronic device, which includes the neural network chip described in the sixth aspect or the board described in the sixth aspect.

[0021] In an eighth aspect, an embodiment of the present application further provides a calculation method for executing a machine learning model, wherein the calculation method is applied to a computing device, and the computing device is used to perform machine learning calculations; the computing device includes: a compression unit, a computing unit, and a controller unit; the method includes:

[0022] The controller unit obtains a compression request for first input data, and instructs the compression unit to compress the first input data according to the compression request; wherein the first input data includes a first weight matrix;

[0023] The compression unit is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items;

[0024] The controller unit is further used to obtain second input data and calculation instructions; the second input data includes the second weight matrix and input neuron data;

[0025] The controller unit is further configured to parse the calculation instruction to obtain a plurality of operation instructions, and send the plurality of operation instructions and the second input data to the operation unit;

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

[0027] In some embodiments, the electronic device includes 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.

[0028] In some embodiments, the means of transportation 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 equipment and / or electrocardiographs. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

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

[0031] Figure 1B is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;

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

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

[0034] Figure 4 It is a flowchart of a neural network compression method provided in an embodiment of the present application;

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

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

[0037] Figure 5C It is a schematic diagram of the structure of a convolution kernel in a convolution layer provided in an embodiment of the present application;

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

[0039] Figure 7 is a structural diagram of a main processing circuit provided in an embodiment of the present application;

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

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

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

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

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

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

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

[0047] Fig.15 This is a schematic diagram of the structure of a board provided in an embodiment of the present application.

[0048] Fig.16 It is a flowchart of a neural network compression method provided in an embodiment of the present application;

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

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

[0051] Fig.18 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0053] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0054] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0055] The present application provides a compression element for compressing a first weight matrix into a second weight matrix, which solves the problem that the topological structure of the neural network is easily irregular due to the use of a neural network pruning algorithm in the prior art. 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 1B The computing device shown is used to describe the present invention.

[0056] See also Figure 1B , Figure 1B 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;

[0057] 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;

[0058] 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 summation items;

[0059] 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 summation items; the solution unit 132 is used to determine the size of each summation item in the at least two summation items 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 summation term of the at least two summation terms, Q1 = A 11 *A 12 *......*A 1n1 ; Q2 represents the second summation term of the at least two summation terms, Q2 = B 21 *B 22 *......*B 2n2 ; Q n represents the nth summation term in the at least two summation terms, Q n =X n1 *X n2 *......*X nnn ; A training unit 133 is used to adjust the size of each of the at least two summation items, and to obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model.

[0060] 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.

[0061] 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;

[0062] 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.

[0063] 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.

[0064] 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;

[0065] The compression unit 13 is used to compress the first weight matrix into a second weight matrix according to the multiple operation instructions; wherein the second weight matrix includes at least two summation items;

[0066] 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.

[0067] 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;

[0068] 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.

[0069] 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;

[0070] 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;

[0071] 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.

[0072] 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.

[0073] 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.

[0074] In the present application embodiment, Figure 2 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;

[0075] 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.

[0076] 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;

[0077] 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 storage 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 storage queue unit 113 and transmitted to the operation unit.

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

[0079] 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.

[0080] 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.

[0081] In the present application embodiment, Figure 2 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.

[0082] 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.

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

[0084] Table 1

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

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

[0087] 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.

[0088] Table 2

[0089]

[0090] 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.

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

[0092] 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.

[0093] 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 the instruction queue, 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, 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 there is, 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.

[0094] 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.

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

[0096] Step S21: decompose the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two summation items.

[0097] 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.

[0098] In one embodiment, the third weight matrix includes two summation items, for example, the first summation item The first summation term includes (n1-1) compression parameter K1 values; the second summation term Among them, the second summation term includes (n2-1) compression parameter K2 values. Here, the compression parameter K1 and the compression parameter K2 are unknown, that is, when the first weight matrix is ​​decomposed, it can be determined that the first weight matrix can be decomposed into two summation terms, but the specific sizes of the two summation terms are uncertain. Here, when n1 and n2 are different, it means that Q1 and Q2 can be matrices of different numbers. When n1 and n2 are the same, it means that Q1 and Q2 are matrices of the same number.

[0099] In another embodiment, the number of summation items in the third weight matrix is ​​n, where n is a positive integer greater than 2. The number of compression parameters K included in the n summation items is , where D = n. Taking the example of dividing the first weight matrix into three summation items, the compression parameters K to be solved may include (n1-1) compression parameters K1, (n2-1) compression parameters K2, and (n3-1) compression parameters K3.

[0100] Step S22: Determine the size of each summation term in the at least two summation terms according to a first formula, wherein the first formula is Q≈Q1+Q2+...+Q n ; wherein, the Q represents a first weight matrix; the Q1 represents a first summation term in the at least two summation terms, Q2 represents the second summation term of the at least two summation terms, The Qn represents the nth summation term in the at least two summation terms,

[0101] In a specific implementation, n in the first formula represents the number of summation items, and the “*” in the first summation item and the second summation item represents a matrix product operation.

[0102] In one implementation manner, when the third weight matrix includes two summation items, the first formula can be expressed as:

[0103] Q≈Q1+Q2(1.1)

[0104] In another embodiment, when the third weight matrix includes at least two summation items, the first formula can be expressed as:

[0105] Q≈Q1+Q2+...+Q n (1.2)

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

[0107] In a specific implementation, the size of each summation item in the at least two summation items 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.

[0108] In a specific implementation, the preset error threshold involved here may be between 5% and 10%. It is understandable that the smaller the preset error threshold is, the better the at least two summation terms determined according to the first formula and the second formula can represent the attribute characteristics of the first weight matrix.

[0109] Step S23: adjust the size of each of the at least two summation items, and obtain a second weight matrix that meets the preset accuracy by training the compressed machine learning model.

[0110] In a specific implementation, the process of adjusting the size of each of the at least two summation items is actually a dynamic change process of the compression parameter K value to find the optimal compression parameter K. As the compression parameter K value changes, the compression ratio between the first weight matrix and the second weight matrix will also change.

[0111] Taking the application scenario of speech recognition as an example, in a certain sequence of words, some words may be inserted, deleted or replaced by mistake. For example, for a segment of initial recognition text containing N words, if I words are inserted, D words are deleted and E words are replaced, then the word error rate WER (Word Error Rate, WER) is:

[0112] WER=(I+D+E) / N(1.4)

[0113] Among them, the error rate WER is usually expressed as a percentage.

[0114] When the neural network model is used to recognize the word sequence, the detection accuracy of the word error rate of the word sequence can be obtained. In the embodiment of the present invention, the preset accuracy involved here is the detection accuracy of the neural network model for the word error rate WER before compression. For example, the preset accuracy is 70%. In general, the error rate WER of the compressed neural network will increase, which means that the accuracy of the compressed neural network will deteriorate.

[0115] In an embodiment of the invention, the detection accuracy of the word error rate of the neural network model corresponding to different compression ratios (different values ​​of the compression parameter K) is measured to obtain a second weight matrix that meets the preset accuracy.

[0116] In a preferred embodiment, the training unit is used to adjust the size of each of the at least two summation items and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model, including:

[0117] The training unit is specifically used to adjust the size of each of the at least two summation items, 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.

[0118] It can be understood that, in this embodiment, the compression parameter K value in the current state can not only enable the neural network model to obtain the best compression effect, but also enable the compressed neural network model to meet the preset accuracy when detecting the word error rate WER. When the neural network model is in the best compression effect, the amount of computation of the neural network can be further reduced.

[0119] Taking the fully connected layer of a neural network as an example, a fully connected layer means that for the n-1 layer and the n layer, any node in the n-1 layer is connected to all nodes in the n layer. For details, see Figure 5A , 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 5AAs 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 5B shown.

[0120] In a fully connected layer neural network, the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, and the first summation term The first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K1 among the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K1 To characterize the The number of input neurons; the second summation term The second summation term M2 includes (n2-1) compression parameters K2, the first compression parameter K of the (n2-1) compression parameters 21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0121] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter K value to find the best compression parameter K. In the specific implementation, the compression parameter K value is different, 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

[0122]

[0123] In practical applications, adaptive algorithms (e.g., genetic algorithms) can be used to determine the number of nodes in the fully connected neural network. The compression parameter K value, where D refers to the number of summation items in the first formula, is used to obtain a second weight matrix that meets the preset accuracy and / or compression effect. The following is a detailed description of how to use genetic algorithms to determine the weight matrix in the fully connected layer neural network. A compression parameter K (for example, K ij ) value:

[0124] 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 ij ) value solution;

[0125] 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.

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

[0127] 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.

[0128] 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 ij The value of

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

[0130] 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.

[0131] Therefore, the genetic algorithm can be used to determine the A compression parameter K value.

[0132] In one embodiment, the adaptive algorithm determines The compression parameter K can make the second weight matrix meet the preset accuracy.

[0133] In another embodiment, the adaptive algorithm determines The compression parameter K 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.

[0134] Take the convolutional layer of a neural network as an example, Figure 5C 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.

[0135] 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 summation term; F2 is the second summation term; The first summation term The first summation term F1 includes (n1-1) compression parameters R1; the second summation term The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0136] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter R value to find the optimal compression parameter R. In practical applications, an adaptive algorithm can be used to determine For details, please refer to the above description and will not be elaborated here.

[0137] 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

[0138]

[0139] 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 .

[0140] 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 summation terms in the jth fully connected layer include the first summation term M j_1 and the second summation term M j_2 , the first summation term The first summation term M j_1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j_1 The number of output neurons, the (n1-1)th compression parameter S1 To characterize the The number of input neurons; the second summation term The second summation term M j_2 The compression parameters S2 include (n2-1) compression parameters, wherein the first compression parameter S j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0141] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter S value to find the optimal compression parameter S. In practical applications, the above adaptive algorithm can be used to determine the convolutional layer neural network. A compression parameter S value is calculated to obtain a second weight matrix that meets the preset accuracy.

[0142] 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

[0143]

[0144] Through the embodiment of the present invention, after obtaining the compression instruction, the controller unit can parse it to obtain multiple operation instructions, and then send these multiple operation instructions and the first weight matrix to the compression unit, and then the compression unit can obtain the second weight matrix by decomposing the first weight matrix. In a specific implementation, the second weight matrix includes at least two summation items, and then by adjusting the size of each of the at least two summation items, and combining the machine learning model after training compression, a second weight matrix that meets the preset accuracy is obtained, which solves the problem of irregular topological structure of the neural network that is easily caused by the use of neural network pruning algorithms in the prior art. In addition, compressing the neural network can reduce the amount of calculation of the neural network, thereby improving the calculation speed.

[0145] 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.

[0146] 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.

[0147] 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.

[0148] 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.

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

[0150] 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.

[0151] 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.

[0152] 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.

[0153] 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.

[0154] 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.

[0155] 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.

[0156] 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.

[0157] In the embodiment of the present invention, the computing unit 12 can be configured as a one-master-multiple-slave structure. Figure 6 As shown, it may include a master processing circuit 101 and a plurality of slave processing circuits 102. In one embodiment, as Figure 6 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 6 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.

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

[0159] Optional, such as Figure 7 As shown, the main processing circuit may further include: one or any combination of a conversion processing circuit 120, an activation processing circuit 121, and an addition processing circuit 122;

[0160] The conversion processing circuit 120 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 the data block or 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 the data block or intermediate result received by the main processing circuit;

[0161] An activation processing circuit 121, used to perform activation operations on data in the main processing circuit;

[0162] The addition processing circuit 122 is used to perform addition operations or accumulation operations.

[0163] 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;

[0164] 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;

[0165] 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.

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

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

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

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

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

[0171] The following is an explanation of the neural network operation instructions. Figure 1B 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.

[0172] In an alternative embodiment, Figure 8As 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.

[0173] 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.

[0174] Optionally, the tree module may be an n-ary tree structure, for example, Fig. 9 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. 9 The nodes of the penultimate layer are shown.

[0175] Optionally, the above computing unit may carry a separate cache, such as Fig.10 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.

[0176] like Fig.11 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.

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

[0178] 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;

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

[0180] 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:

[0181] 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;

[0182] 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.

[0183] 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;

[0184] 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.

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

[0186] 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.

[0187] 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.

[0188] The main processing circuit determines that the multiplication operation is performed according to the at least one operation code, 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;

[0189] 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.

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

[0191] 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.

[0192] 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.

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

[0194] 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.13 A schematic diagram of a combined processing device.

[0195] 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.

[0196] 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.

[0197] Optionally, the structure is as follows Fig.14 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.

[0198] 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.

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

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

[0201] In some embodiments, a board is applied for, which includes the above chip packaging structure. Fig.15 , Fig.15 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;

[0202] 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).

[0203] 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.

[0204] 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.

[0205] 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.

[0206] 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.

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

[0208] 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.

[0209] 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.

[0210] In the embodiment of the present invention, it is considered that the compression method for the neural network can be applied to the above-mentioned computing device, but can also be applied to other scenarios, for example, to reduce the accuracy loss of the neural network. Fig.16 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:

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

[0212] 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.

[0213] Step S102: compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items.

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

[0215] Decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two summation items;

[0216] The magnitude of each summation term in the at least two summation terms is determined according to a first formula, wherein the first formula is Q≈Q1+Q2+...+Q n ; wherein, the Q represents a first weight matrix; the Q1 represents a first summation term in the at least two summation terms, Q2 represents the second summation term of the at least two summation terms, The Q n represents the nth summation term in the at least two summation terms,

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

[0218] In a specific implementation, n in the first formula represents the number of summation items, and the “*” in the first summation item and the second summation item represents a matrix product operation.

[0219] In one implementation manner, when the third weight matrix includes two summation items, the first formula can be expressed as:

[0220] Q≈Q1+Q2(1.1)

[0221] In another embodiment, when the third weight matrix includes at least two summation items, the first formula can be expressed as:

[0222] Q≈Q1+Q2+...+Q n (1.2)

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

[0224] For example, the first formula can be expressed as follows:

[0225]

[0226] 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 summation items, and adjusting each of the at least two summation items to obtain a second weight matrix that meets the preset accuracy will be different, which will be specifically explained below:

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

[0228] 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 5A , 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 5A 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 5B shown.

[0229] In a fully connected layer neural network, the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, and the first summation term The first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K1 among the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K1 To characterize the The number of input neurons; the second summation term The second summation term M2 includes (n2-1) compression parameters K2, the first compression parameter K of the (n2-1) compression parameters 21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0230] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter K value to find the best compression parameter K. In the specific implementation, the compression parameter K value is different, 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

[0231]

[0232] In practical applications, adaptive algorithms (e.g., genetic algorithms) can be used to determine the number of nodes in the fully connected neural network. The compression parameter K value, where D refers to the number of summation items in the first formula, is used to obtain a second weight matrix that meets the preset accuracy and / or compression effect. The following is a detailed description of how to use genetic algorithms to determine the weight matrix in the fully connected layer neural network. A compression parameter K (for example, K ij ) value:

[0233] 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 ij ) value solution;

[0234] 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.

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

[0236] 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.

[0237] 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 ij The value of

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

[0239] 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.

[0240] Therefore, the genetic algorithm can be used to determine the A compression parameter K value.

[0241] In one embodiment, the adaptive algorithm determines The compression parameter K can make the second weight matrix meet the preset accuracy.

[0242] In another embodiment, the adaptive algorithm determines The compression parameter K 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.

[0243] (2) Convolutional neural network:

[0244] Take the convolutional layer of a neural network as an example, Figure 5C 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.

[0245] 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 summation term; F2 is the second summation term; The first summation term The first summation term F1 includes (n1-1) compression parameters R1; the second summation term The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0246] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter R value to find the optimal compression parameter R. In practical applications, an adaptive algorithm can be used to determine For details, please refer to the above description and will not be elaborated here.

[0247] 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

[0248]

[0249] (3) LSTM layer neural network:

[0250] 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 .

[0251] 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 summation terms in the jth fully connected layer include the first summation term M j_1 and the second summation term M j_2 , the first summation term The first summation term M j_1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j_1 The number of output neurons, the (n1-1)th compression parameter S1 To characterize the The number of input neurons; the second summation term The second summation term M j_2 The compression parameters S2 include (n2-1) compression parameters, wherein the first compression parameter S j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0252] As mentioned above, the process of adjusting the size of each summation item of the two summation items is actually a dynamic change process of the compression parameter S value to find the optimal compression parameter S. In practical applications, the above adaptive algorithm can be used to determine the convolutional layer neural network. A compression parameter S value is calculated to obtain a second weight matrix that meets the preset accuracy.

[0253] 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

[0254]

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

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

[0257] 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.

[0258] 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.

[0259] The embodiment of the present invention can obtain at least two summation items including multiple compression parameters by decomposing the first weight matrix. Then, each of the at least two summation items 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.

[0260] 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:

[0261] like Fig.17A 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;

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

[0263] 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 summation items;

[0264] 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.

[0265] In one embodiment, if Fig. 17B As shown, the compression unit 13 includes a decomposition unit 130, a solution unit 131 and a training unit 132;

[0266] 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 summation items;

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

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

[0269] Optionally, the solving unit 131 is specifically configured to determine the size of each summation item in the at least two summation items 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.

[0270] Optionally, the training unit 132 is specifically used to adjust the size of each of the at least two summation items, 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.

[0271] Optionally, the neural network includes a fully connected layer neural network; the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, and the first summation term The first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K1 among the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K1 To characterize the The number of input neurons; the second summation term The second summation term M2 includes (n2-1) compression parameters K2, the first compression parameter K of the (n2-1) compression parameters21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0272] 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 summation term; F2 is the second summation term; The first summation term The first summation term F1 includes (n1-1) compression parameters R1; the second summation term The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0273] 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 summation terms in the jth fully connected layer include the first summation term M j_1 and the second summation term M j_2 , the first summation term The first summation term M j_1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j_1 The number of output neurons, the (n1-1)th compression parameter S in the (n1-1) compression parameter S1 j_1(n1-1) To characterize the M j_1n1 The number of input neurons; the second summation term M j_2 =M j_21 *M j_22 *......*Mj_2n2 , the second summation term M j_2 The compression parameters S2 include (n2-1) compression parameters, wherein the first compression parameter S j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter S j_2(n2-1) To characterize the M j_2n2 The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0274] The embodiment of the present invention can obtain at least two summation items including compression parameters by decomposing the first weight matrix. Then, each of the at least two summation items 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.

[0275] 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:

[0276] like Fig.18 The 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:

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

[0278] Compressing the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items;

[0279] 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.

[0280] The processor 401 compresses the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items, which may include:

[0281] Decomposing the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two summation items;

[0282] The magnitude of each summation term in the at least two summation terms is determined 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 summation term of the at least two summation terms, Q1 = A 11 *A 12 *......*A 1n1 ; Q2 represents the second summation term of the at least two summation terms, Q2 = B 21 *B 22 *......*B 2n2 ; Q n represents the nth summation term in the at least two summation terms, Q n =X n1 *X n2 *......*X nnn ;

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

[0284] The processor 401 determines the size of each summation term in the at least two summation terms according to a first formula, wherein the first formula is Q≈Q1+Q2.+...+Q n , which may include:

[0285] The size of each summation item in the at least two summation items 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.

[0286] The processor 401 adjusts the size of each of the at least two summation items and obtains a second weight matrix satisfying a preset accuracy by training the compressed machine learning model, which may include:

[0287] The size of each of the at least two summation items 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.

[0288] Wherein, the neural network is a fully connected layer neural network; the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, and the first summation term M1=M 11 *M 12 *......*M 1n1 , the first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K in the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K in the (n1-1) compression parameter K1 1(n1-1) To characterize the M 1n1 The number of input neurons; the second summation term M2 = M 21 *M 22 *......*M 2n2 The second summation item M2 includes (n2-1) compression parameters K2, and the first compression parameter K among the (n2-1) compression parameters is 21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter K among the (n2-1) compression parameters 2(n2-1) To characterize the M 2n2 The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0289] 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; the F1 is the first summation term; the F2 is the second summation term; the first summation term F1=F 11 *F 12 *......*F 1n1 ; The first summation term F1 includes (n1-1) compression parameters R1; The second summation term F2 = F 21 *F 22*......*F 2n2 The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are greater than 0 and less than or equal to min(K x , K y ) is a positive integer.

[0290] 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 summation terms in the jth fully connected layer include the first summation term M j_1 and the second summation term M j_2 , the first summation term M j_1 =M j_11 *M j_12 *......*M j_1n1 , the first summation term M j_1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j_1 The number of output neurons, the (n1-1)th compression parameter S in the (n1-1) compression parameter S1 j_1(n1-1) To characterize the M j_1n1 The number of input neurons; the second summation term M j_2 =M j_21 *M j_22 *......*M j_2n2 , the second summation term M j_2 The compression parameters S2 include (n2-1) compression parameters, wherein the first compression parameter S j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

[0291] 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. Fig.16The specific implementation method of the operation of the electronic device in the embodiment will not be repeated here.

[0292] 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.

[0293] 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.

[0294] The embodiment of the present invention also provides a computer storage medium for storing the above Fig.16 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.

[0295] 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.

[0296] 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.

[0297] 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.

[0298] 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.

[0299] 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.

[0300] 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.

[0301] 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.

[0302] 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 computing device, characterized in that: The computing device is used to perform machine learning calculations, and the computing device includes: a compression unit, an operation unit, and a controller unit; The controller unit is configured 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; The compression unit is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items; The controller unit is further used to obtain second input data and calculation instructions; the second input data includes the second weight matrix and input neuron data; The controller unit is further configured to parse the calculation instruction to obtain a plurality of operation instructions, and send the plurality of operation instructions and the second input data to the operation unit; The operation unit is used to obtain the operation instruction and perform neural network calculation according to the operation instruction and the second input data; the neural network is a convolutional layer neural network; The compression unit includes: a decomposition unit, a solution unit and a training unit; Wherein, the decomposition unit is used to decompose the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two summation items; The solving unit is used to determine the size of each summation term in the at least two summation terms according to the first formula, The training unit is used to adjust the size of each of the at least two summation items, and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model; The computing device is used to perform convolutional neural network calculations; 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 summation term; F2 is the second summation term; The first summation term The first summation term F1 includes (n1-1) compression parameters R1; the second summation term The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are 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 computing device according to claim 1, wherein: The first formula is Q≈Q1+Q2+...+Q n ; wherein, the Q represents a first weight matrix; the Q1 represents a first summation term in the at least two summation terms, Q2 represents the second summation term of the at least two summation terms, The Q n represents the nth summation term in the at least two summation terms, 3. The computing device according to claim 2, characterized in that The solving unit is used to determine the size of each summation term in the at least two summation terms according to a first formula, wherein the first formula is Q≈Q1+Q2.+...+Q n ,include: The solving unit is specifically used to determine the size of each summation item in the at least two summation items 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 computing device according to claim 2, wherein: The training unit is used to adjust the size of each of the at least two summation items and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model, including: The training unit is specifically used to adjust the size of each of the at least two summation items, 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.

5. The computing device according to any one of claims 2 to 4, characterized in that: The computing device is used to perform fully connected layer neural network calculations; the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, the first summation term The first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K1 among the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K1 To characterize the The number of input neurons; the second summation term The second summation term M2 includes (n2-1) compression parameters K2, the first compression parameter K of the (n2-1) compression parameters 21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

6. The computing device according to any one of claims 2 to 4, characterized in that: The computing device is used to perform LSTM layer neural network calculations, the LSTM layer includes N fully connected layers, and 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 summation terms in the jth fully connected layer include the first summation term M j _1 and the second summation term M j _2, the first summation term The first summation term M j _1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j _1, the (n1-1)th compression parameter in the (n1-1)th compression parameter S1 To characterize the The number of input neurons; the second summation term The second summation term M j _2 includes (n2-1) compression parameters S2, the first compression parameter S of the (n2-1) compression parameters j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

7. The computing device according to claim 1, wherein: The computing device further comprises: a storage unit and a direct memory access unit, wherein the storage unit comprises: any combination of a register and a cache; The cache is used to store the first input data and the second input data; The register is used to store the first input data and the scalar data in the second input data; The cache includes a high-speed temporary storage cache; The controller unit includes: an instruction storage unit, an instruction processing unit and a storage queue unit; The instruction storage unit is used to store calculation instructions associated with artificial neural network operations; The instruction processing unit is used to parse the calculation instruction to obtain multiple operation instructions; The storage queue unit is used to store an instruction queue, which includes: a plurality of operation instructions or calculation instructions to be executed in a front-to-back order of the queue; The controller unit includes a main processing circuit, and the main processing circuit includes: a dependency processing unit; The dependency processing unit is used to determine whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction, and if the first operation instruction has an association relationship with the zeroth operation instruction, cache the first operation instruction in the instruction storage unit, and extract the first operation instruction from the instruction storage unit and transmit it to the operation unit after the zeroth operation instruction is executed; The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises: The first storage address interval of the data required in the first operation instruction is extracted based on the first operation instruction, and the zeroth storage address interval of the data required in the zeroth operation instruction is extracted based on 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.

8. A machine learning computing device, characterized in that: The machine learning computing device comprises one or more computing devices according to any one of claims 1 to 7, which are used to obtain input data and control information to be computed from other processing devices, and to perform specified machine learning operations, and transmit the execution results to other processing devices through an I / O interface; When the machine learning computing device includes a plurality of computing devices, the plurality of computing devices are connected and transmit data through a specific structure; Among them, multiple computing devices are interconnected and transmit data through a fast peripheral device interconnection bus PCIE bus to support larger-scale machine learning operations; multiple computing devices share the same control system or have their own control systems; multiple computing devices share memory or have their own memory; the interconnection method of multiple computing devices is any interconnection topology.

9. A combined processing device, characterized in that: The combined processing device includes the machine learning computing device as claimed in claim 8, a universal interconnect interface, a storage device and other processing devices; The machine learning operation device interacts with the other processing devices to jointly complete the computing operations specified by the user; the storage device is respectively connected to the machine learning operation device and the other processing devices, and is used to save the data of the machine learning operation device and the other processing devices.

10. A neural network chip, characterized in that: The machine learning chip includes the machine learning operation device as described in claim 8 or the combined processing device as described in claim 9.

11. An electronic device, characterized in that: The electronic device comprises the chip according to claim 10.

12. A board, characterized in that: The board includes: a storage device, an interface device and a control device and a neural network chip as claimed in claim 10; Wherein, the neural network chip is connected to the storage device, the control device and the interface device respectively; The storage device is used to store data; The interface device is used to realize data transmission between the chip and external equipment; The control device is used to monitor the state of the chip.

13. A computational method for executing a machine learning model, characterized in that: The computing method is applied to a computing device, and the computing device is used to perform machine learning computing; The computing device comprises: a compression unit, a computing unit and a controller unit; the method comprises: The controller unit obtains a compression request for first input data, and instructs the compression unit to compress the first input data according to the compression request; wherein the first input data includes a first weight matrix; The compression unit is used to compress the first weight matrix into a second weight matrix; wherein the second weight matrix includes at least two summation items; The controller unit acquires second input data and a calculation instruction; the second input data includes the second weight matrix and input neuron data; The controller unit parses the calculation instruction to obtain a plurality of operation instructions, and sends the plurality of operation instructions and the second input data to the operation unit; The operation unit obtains the operation instruction, and performs neural network calculation according to the operation instruction and the second input data; the neural network is a convolutional layer neural network; The compression unit includes: a decomposition unit, a solution unit and a training unit; Wherein, the decomposition unit is used to decompose the first weight matrix into a third weight matrix; wherein the third weight matrix includes at least two summation items; The solving unit is used to determine the size of each summation term in the at least two summation terms according to the first formula, The training unit is used to adjust the size of each of the at least two summation items, and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model; The computing device is used to perform convolutional neural network calculations; 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 summation term; F2 is the second summation term; The first summation term The first summation term F1 includes (n1-1) compression parameters R1; the second summation term The second summation term F2 includes (n2-1) compression parameters R2, (K x , K y ) represents the size of the convolution kernel, and R1 and R2 are 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 performs pre-order processing on the second input data and transmits data and operation instructions between the plurality of slave processing circuits; The multiple slave processing circuits 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 performs subsequent processing on the multiple intermediate results to obtain a calculation result of the calculation instruction.

14. The method according to claim 13, characterized in that The solving unit is used to determine the size of each summation term in the at least two summation terms according to a first formula; the first formula is Q≈Q1+Q2+...+Q n ; wherein, the Q represents a first weight matrix; the Q1 represents a first summation term in the at least two summation terms, Q2 represents the second summation term of the at least two summation terms, The Q n represents the nth summation term in the at least two summation terms, 15. The method according to claim 14, characterized in that The solving unit is specifically used to determine the size of each summation item in the at least two summation items 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.

16. The method according to claim 14, characterized in that The training unit is used to adjust the size of each of the at least two summation items and obtain a second weight matrix that meets a preset accuracy by training the compressed machine learning model, including: The training unit is specifically used to adjust the size of each of the at least two summation items, 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.

17. The method according to any one of claims 14 to 16, characterized in that: The computing device is used to perform fully connected layer neural network calculations; the first formula includes: M≈M1+M2; the two summation terms include a first summation term M1 and a second summation term M2, the first summation term The first summation item M1 includes (n1-1) compression parameters K1; the first compression parameter K1 among the (n1-1) compression parameters K1 11 To characterize the M 11 The number of output neurons, the (n1-1)th compression parameter K1 To characterize the The number of input neurons; the second summation term The second summation term M2 includes (n2-1) compression parameters K2, the first compression parameter K of the (n2-1) compression parameters 21 To characterize the M 21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; K1 and K2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

18. The method according to any one of claims 14 to 16, characterized in that: The computing device is used to perform LSTM layer neural network calculations, the LSTM layer includes N fully connected layers, and 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 summation terms in the jth fully connected layer include the first summation term M j _1 and the second summation term M j _2, the first summation term The first summation term M j _1 includes (n1-1) compression parameters S1; the first compression parameter S in the (n1-1) compression parameters S1 j_11 To characterize the M j _1, the (n1-1)th compression parameter in the (n1-1)th compression parameter S1 To characterize the The number of input neurons; the second summation term The second summation term M j _2 includes (n2-1) compression parameters S2, the first compression parameter S of the (n2-1) compression parameters j_21 To characterize the M j_21 The number of output neurons, the (n2-1)th compression parameter of the (n2-1)th compression parameter To characterize the The number of input neurons; S1 and S2 are greater than 0 and less than or equal to min(N in , N out ) is a positive integer.

19. The method according to claim 13, characterized in that The computing device further comprises: a storage unit and a direct memory access unit, wherein the storage unit comprises: any combination of a register and a cache; The cache stores the first input data and the second input data; The register stores the first input data and the scalar in the second input data; the cache comprises a high-speed scratchpad cache; The controller unit includes: an instruction storage unit, an instruction processing unit and a storage queue unit; The instruction storage unit stores calculation instructions associated with artificial neural network operations; The instruction processing unit parses the calculation instruction to obtain a plurality of operation instructions; The storage queue unit stores an instruction queue, the instruction queue comprising: a plurality of operation instructions or calculation instructions to be executed in a front-to-back order of the queue; The controller unit includes a main processing circuit, and the main processing circuit includes: a dependency processing unit; The dependency processing unit determines whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction. If the first operation instruction has an association relationship with the zeroth operation instruction, the first operation instruction is cached in the instruction storage unit, and after the zeroth operation instruction is executed, the first operation instruction is extracted from the instruction storage unit and transmitted to the operation unit; The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises: The first storage address interval of the data required in the first operation instruction is extracted based on the first operation instruction, and the zeroth storage address interval of the data required in the zeroth operation instruction is extracted based on 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.

Citation Information

Patent Citations

  • Artificial neural network compression coding device and artificial neural network compression coding method

    CN106991477A

  • Neural-network computing system and methods

    CN108427990A

  • Model compression and fine-tuning

    US20160217369A1

  • Compression method for deep neural networks with load balance

    US20180046914A1

  • Compression of deep neural networks with proper use of mask

    US20180046915A1

Cited By

  • Systems and methods for activation sparse and kernel sparse general matrix multiplication in neural networks

    US12670370B1