A computing device and related products

By using a load balancing unit in the computing device to prune the weight data of the neural network, the problem of load imbalance caused by sparsity is solved and the computing speed of the neural network is improved.

CN111291871BActive Publication Date: 2024-08-23CAMBRICON TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201811507488.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-12-10
Publication Date
2024-08-23
Estimated Expiration
2039-09-03

AI Technical Summary

Technical Problem

Neural network models can easily lead to sparsity problems during the pruning process, resulting in different calculations for each neuron, resulting in load imbalance and reduced computing speed.

Method used

A computing device is designed, including a load balancing unit, a computing unit and a controller unit. By pruning the first weight data and adjusting it to the second weight data, it ensures that the sparsity of each group of weights is the same, thereby solving the problem Load imbalance problem.

Benefits of technology

The first weight data is pruned by the load balancing unit to obtain the second weight data, which solves the load imbalance problem caused by sparsity and improves the computing speed of the neural network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111291871B
    Figure CN111291871B
Patent Text Reader

Abstract

The present application provides a computing device and related products, the computing device includes a load balancing unit, a computing unit and a controller unit; wherein the controller unit is used to obtain a pruning request for first input data, and instruct the load balancing unit to prune the first input data according to the pruning request; wherein the first input data includes first weight data; the load balancing unit is used to adjust the first weight data to second weight data; the controller unit is also used to perform neural network calculations according to the second input data and the calculation instructions. Through the present application, the problem of load imbalance caused by the different amount of calculations of each neuron due to the sparsity problem is solved, and the calculation speed is improved.
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 computation of the neural network. However, in the process of pruning the neural network model, it is easy to cause sparsity problems in the neural network model. The above sparsity problem will introduce irregularity, making the original regular topological structure irregular, resulting in different computational loads for each output neuron, and then causing load imbalance problems. Summary of the invention

[0005] The embodiments of the present application provide a computing device and related products, which solve the problem of load imbalance caused by the different computing amounts of each neuron due to the sparsity problem and improve the computing speed.

[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 load balancing unit, a computing unit, and a controller unit;

[0007] The controller unit is configured to obtain a pruning request for first input data, and instruct the load balancing unit to prune the first input data according to the pruning request; wherein the first input data includes first weight data;

[0008] The load balancing unit is used to adjust the first weight data to second weight data;

[0009] The controller unit is further used to obtain second input data and calculation instructions; the second input data includes the second weight data 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 data can be pruned by a load balancing unit to obtain the second weight data, and then the neural network calculation can be performed according to the second weight data and the input neuron data, thereby solving the problem of load imbalance caused by the different calculation amount of each neuron due to the sparsity problem, and improving the calculation speed.

[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 load balancing unit, a computing unit, and a controller unit; the method includes:

[0022] The controller unit obtains first input data and a load balancing instruction; wherein the first input data includes first weight data; the controller unit parses the load balancing instruction to obtain a plurality of operation instructions, and sends the plurality of operation instructions and the first weight data to the load balancing unit;

[0023] The load balancing unit adjusts the first weight data to second weight data according to the multiple operation instructions;

[0024] The controller unit acquires second input data and a calculation instruction; the second input data includes the second weight data and input neuron data;

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

[0026] The operation unit obtains the operation instruction and performs 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 1 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;

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

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

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

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

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

[0036] Figure 5C This is a schematic diagram of an operation of continuously grouping a fully connected layer weight matrix provided in an embodiment of the present application;

[0037] Figure 5D It is a schematic diagram of an operation of cross-grouping a fully connected layer weight matrix provided in an embodiment of the present application;

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

[0039] Fig. 5F It is a schematic diagram of continuously grouping convolution kernels of a convolution layer provided by an embodiment of the present application;

[0040] Figure 5GIt is a schematic diagram of cross-grouping the convolution kernels of a convolution layer provided in an embodiment of the present application;

[0041] Figure 5H is a schematic diagram of a fully connected layer weight matrix provided by another embodiment of the present application;

[0042] Fig.5I is a schematic diagram of an operation of pruning a fully connected layer provided in an embodiment of the present application;

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

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

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

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

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

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

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

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

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

[0052] Fig.15 It is a structural schematic diagram of a board provided in an embodiment of the present application;

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

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

[0055] Fig. 17B is a schematic diagram of the structure of another neural network pruning device provided in an embodiment of the present application;

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

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

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

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

[0060] The present application provides a load balancing unit for pruning first weight data to obtain second weight data, so as to solve the problem of load imbalance caused by different computational loads of each neuron due to sparsity. In practical applications, the load balancing unit can be used in neural network calculations, specifically, in a computing device for performing neural network calculations. Figure 1 The computing device shown is used to describe the present invention.

[0061] See also Figure 1 , Figure 1 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 load balancing unit 13, wherein the controller unit 11 is connected to the computing unit 12 and the load balancing unit 13 respectively;

[0062] The controller unit 11 is used to obtain a pruning request for first input data, and instruct the load balancing unit to prune the first input data according to the pruning request; wherein the first input data includes first weight data; in an optional solution, the pruning 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;

[0063] The load balancing unit 13 is used to adjust the first weight data to second weight data;

[0064] In a specific implementation, the load balancing unit 13 includes a grouping unit 131, a threshold calculation unit 132, and a pruning unit 133. The grouping unit 131 is used to group the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0; the threshold calculation unit 132 is used to determine the threshold of each group of weights in the M groups of weights according to a preset sparsity; the pruning unit 133 is used to prune each group of weights in the M groups of weights according to the determined threshold to obtain second weight data. In one embodiment, P is a real number greater than 0 and less than 1.

[0065] The controller unit 11 is also used to obtain second input data and calculation instructions; the second input data includes second weight data 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.

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

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

[0068] In one implementation, considering that a "load balancing 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 load balancing instruction; wherein, the first input data includes first weight data; in an optional scheme, specifically, the first input data and the load balancing instruction 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.

[0069] The controller unit 11 is further configured to parse the load balancing instruction to obtain a plurality of operation instructions, and send the plurality of operation instructions and the first weight data to the load balancing unit;

[0070] The load balancing unit 13 is used to adjust the first weight data to second weight data according to the multiple operation instructions;

[0071] The controller unit 11 is also used to obtain second input data and calculation instructions; the second input data includes the second weight data 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0089] Table 1

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

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

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

[0093] Table 2

[0094]

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

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

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

[0098] After the controller unit reads the load balancing instruction from the storage unit, it parses the load balancing instruction into an operation instruction and sends the operation instruction to the load balancing unit. Specifically, the instruction fetch module of the instruction processing unit 111 in the controller unit 11 obtains the load balancing instruction from the instruction cache unit 110 and transmits the instruction to the decoding module. The decoding module decodes the load balancing 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 released. If there is no association relationship, the operation instruction is sent to the load balancing unit to perform the corresponding operation.

[0099] S2. The load balancing unit receives the operation instruction sent by the control unit, and performs load balancing processing according to the first weight data read from the storage unit to obtain second weight data.

[0100] Combine the following Figure 4 The flowchart of the balanced pruning method provided by the embodiment of the present invention is shown, which specifically describes how the embodiment of the present invention implements balanced pruning of first weight data to obtain second weight data, and may include but is not limited to the following steps:

[0101] Step S21, grouping the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0.

[0102] In a specific implementation, the first weight data may be any real number.

[0103] In the embodiment of the present invention, grouping the first weight data may include continuously grouping the first weight data, or may include cross-grouping the first weight data.

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

[0105] In practical applications, when the weights of the fully connected layer are divided into M groups, M is greater than 1 and less than N. out A positive integer.

[0106] In one embodiment, when the weight matrix is ​​grouped continuously, the continuous weight matrix The i-th group of weights includes the i-th Row, No. Row, No. Row, ..., Where i is a positive integer greater than 0 and less than M, N out is the number of output neurons.

[0107] In another embodiment, when the weight matrix is ​​cross-grouped, the alternating The i-th group of weights includes the i-th row, i+M-th row, i+M*2-th row, ..., i ... Where i is a positive integer greater than 0 and less than M, N out is the number of output neurons.

[0108] As mentioned above, when the weight matrix can be expressed as Figure 5B , assuming that the above 12 weights are divided into 4 groups, then the number of weights in each group is 3. When the grouping mode is continuous grouping, for the continuous grouping of the above 12 weights, please refer to Figure 5C .like Figure 5C As shown, the first group of weights is the first row of the weight matrix; the second group of weights is the second row of the weight matrix; the third group of weights is the third row of the weight matrix; and the fourth group of weights is the fourth row of the weight matrix.

[0109] Similarly, in actual applications, assume that the above 12 weights are divided into 2 groups. In this case, the number of weights in each group is 6. When the grouping mode is cross grouping, for the cross grouping of the above 12 weights, please refer to Figure 5D ,like Figure 5D As shown, the first set of weights is the 1st row and the 3rd row of the weight matrix; the second set of weights is the 2nd row and the 4th row of the weight matrix.

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

[0111] In practical applications, when the weights of the convolutional layer are divided into M groups, M is greater than 1 and less than N. fout A positive integer.

[0112] In one embodiment, when the weight matrix is ​​grouped continuously, the continuous weight matrix The convolution kernels are in the same group. The i-th group of weights includes the , , , ..., convolution kernels. Where i is a positive integer greater than 0 and less than M.

[0113] In another embodiment, when the weight matrix is ​​cross-grouped, the alternating convolution kernels are in the same group. The i-th group of weights includes the i-th, i+M-th, i+M*2-th, ..., i ... convolution kernels. Where i is a positive integer greater than 0 and less than M.

[0114] As mentioned above, when the convolution kernel in the weight matrix is ​​expressed as shown in 5E, the number of convolution kernels is 4. Assume that the above 4 convolution kernels are divided into 2 groups. In this case, the number of convolution kernels in each group is 2. When the grouping mode is continuous grouping, for the continuous distribution of the above 4 convolution kernels, please refer to Fig. 5F ,like Fig. 5F As shown, the first set of weights is the first convolution kernel and the second convolution kernel in the weight matrix; the second set of weights is the third convolution kernel and the fourth convolution kernel in the weight matrix.

[0115] Similarly, in practical applications, assume that the above 4 convolution kernels are divided into 2 groups. In this case, the number of convolution kernels in each group is 2. When the separation mode is cross grouping, for the cross grouping of the above 4 convolution kernels, please refer to Figure 5G ,like Figure 5G As shown, the first set of weights is the first convolution kernel and the third convolution kernel in the weight matrix; the second set of weights is the second convolution kernel and the fourth convolution kernel in the weight matrix.

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

[0117] In practical applications, each of the t fully connected layers mentioned above is grouped. Taking the jth fully connected layer as an example, the weights of the jth fully connected layer are divided into M groups, then the number of weights in each group of the jth fully connected layer is: Where M is greater than 1 and less than N out_j A positive integer.

[0118] In one embodiment, when the weight matrices in the j-th fully connected layer are grouped continuously, the continuous weight matrices The i-th group of weights includes the i-th Row, No. Row, No. Row, ..., Where i is a positive integer greater than 0 and less than M, N out_j is the number of output neurons in the jth fully connected layer.

[0119] In another embodiment, when the weight matrix in the j-th fully connected layer is continuously grouped, the alternating The i-th group of weights includes the i-th row, i+M-th row, i+M*2-th row, ..., i ... Where i is a positive integer greater than 0 and less than M, N out_jis the number of output neurons in the jth fully connected layer.

[0120] by Figure 5A Take the neural network architecture shown in the figure as an example. The neural network includes an input layer, a hidden layer, and an output layer. The first fully connected layer is between the input layer and the hidden layer, and the second fully connected layer is between the hidden layer and the output layer. For the detailed description of the fully connected layer structure between the input layer and the hidden layer, please refer to the above description. Figure 5A It can be seen that the two-dimensional parameter matrix of the fully connected layer between the hidden layer and the output layer is (4,2). The two-dimensional parameter matrix (4,2) indicates that in the fully connected layer structure between the hidden layer and the output layer, the number of input neurons is 4, the number of output neurons is 2, and the number of weights is 8. In the specific implementation, these 8 weights can be expressed as a 2-row 4-column weight matrix, and the weight matrix can be expressed as follows Figure 5H In addition, the grouping form of the weight matrix (eg, continuous grouping or cross grouping) can refer to the above description, and will not be elaborated here.

[0121] Step S22: Determine the threshold of each group of weights in the M groups of weights according to the preset sparsity P.

[0122] In a specific implementation, the sparsity P refers to the proportion of non-zero elements in the sparse coefficient vector. The sparsity P is a real number greater than 0 and less than 1. For example, the sparsity may be 0.7.

[0123] Taking the fully connected layer of a neural network as an example, the threshold of each weight group in the M weight groups is determined according to the preset sparsity P, including:

[0124] Determine the Qth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0125] In practical applications, it is considered that Q calculated using the above calculation formula for Q may include an integer or a non-integer. In one optional implementation, when Q is a non-integer, a rounding operation may be performed on Q. In a specific implementation, the rounding operation involved here may include an upward rounding operation or a downward rounding operation.

[0126] For example, Figure 5ATaking the fully connected layer from the input layer to the hidden layer in the neural network architecture shown as an example, the number of input neurons is 3, the number of output neurons is 4, and the number of weights is 12. The weight matrix is ​​divided into 4 groups by continuous grouping. The second weight in the first group of weights is determined as the threshold of each group of weights according to the preset sparsity P. Among them, the second weight in the first group of weights is 0.5, that is, the threshold of the first group of weights is 0.5; the second weight in the second group of weights is 0.4, that is, the threshold of the second group of weights is 0.4; the second weight in the third group of weights is 0.65, that is, the threshold of the third group of weights is 0.65; the second weight in the fourth group of weights is 0.45, that is, the threshold of the fourth group of weights is 0.45.

[0127] Taking the convolution layer of a neural network as an example, the threshold of each weight group in M ​​weight groups is determined according to the preset sparsity P, including:

[0128] Determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N fin is the number of input feature images, N fout is the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0129] As an optional implementation, R is obtained by a rounding operation. Similarly, the rounding operation may include an upward rounding operation or a downward rounding operation.

[0130] For example, Figure 5G The convolution layer shown in the figure uses a cross-grouping method to divide the weight matrix into two groups. The first group of weights is the first and third convolution kernels in the weight matrix; the second group of weights is the second and fourth convolution kernels in the weight matrix. The sixth weight in the first group of weights is determined as the threshold of each group of weights according to the preset sparsity. Among them, the sixth weight in the first group of weights is 0.7, that is, the threshold of the first group of weights is 0.7; the sixth weight in the second group of weights is 0.45, that is, the threshold of the second group of weights is 0.45.

[0131] Taking the LSTM layer of the neural network as an example, the threshold of each weight group in the M weight groups is determined according to the preset sparsity P, including:

[0132] Determine the Sth weight in the i-th group of weights of the j-th fully connected layer as the threshold for each group of weights, where N in_j is the number of input neurons in the jth fully connected layer, N out_jis the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to the absolute value, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N. As an optional implementation, S is obtained by rounding operation. Similarly, the rounding operation may include rounding up operation or rounding down operation.

[0133] by Figure 5A Taking the neural network architecture shown as an example, the neural network architecture includes two fully connected layers, namely the network structure between the input layer and the hidden layer and the network structure between the hidden layer and the output layer. As mentioned above, in the first fully connected layer, when the grouping mode is continuous grouping, the weight matrix of the first fully connected layer is divided into two groups, and the threshold of the first group of weights is determined to be 0.5, and the threshold of the second group of weights is determined to be 0.4. In the second fully connected layer, when the grouping mode is continuous grouping, the weight matrix of the second fully connected layer is divided into two groups, wherein the first group of weights includes the first row of the weight matrix, and the second group of weights includes the second row of the weight matrix, the threshold of the first group of weights is determined to be 0.65, and the threshold of the second group of weights is determined to be 0.5.

[0134] Step S23: Prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data.

[0135] In layman's terms, pruning each of the M groups of weights means removing some unnecessary weights.

[0136] In a specific implementation, each group of weights in the M groups of weights is pruned according to a determined threshold value to obtain second weight data, including:

[0137] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

[0138] As mentioned earlier, taking the fully connected layer of a neural network as an example, Figure 5C As shown, when the grouping mode is continuous grouping, the 12 weights are divided into 4 groups, where the first group of weights is the first row of the weight matrix; the second group of weights is the second row of the weight matrix; the third group of weights is the third row of the weight matrix; and the fourth group of weights is the fourth row of the weight matrix. According to the preset sparsity P, the threshold in the first group of weights is determined to be 0.5, the threshold in the second group of weights is 0.4, the threshold in the third group of weights is 0.65, and the threshold in the fourth group of weights is 0.45. Then, each group of weights is pruned according to the above-determined thresholds. Specifically, in the first group of weights, weights less than 0.5 are removed. In the second group of weights, weights less than 0.4 are removed. In the third group of weights, weights less than 0.65 are removed. In the fourth group of weights, weights less than 0.45 are removed. Specifically, for Figure 5C The schematic diagram after pruning the four groups of weights shown in FIG. 5I is as shown in FIG. Fig.5I As shown in Figure 1, after pruning, the sparsity of these four groups of weights can be ensured to be the same.

[0139] In one embodiment, when M=N out , that is, when the number of groups is equal to the number of output neurons, it can ensure that the amount of calculation for each neuron is the same, thus solving the problem of load imbalance.

[0140] As mentioned earlier, taking the convolutional layer of a neural network as an example, Figure 5G For the convolution layer shown, when the grouping mode is cross grouping, the weight matrix is ​​divided into two groups, where the first group of weights is the first and third convolution kernels in the weight matrix; the second group of weights is the second and fourth convolution kernels in the weight matrix. The threshold in the first group of weights determined according to the preset sparsity P is 0.7, and the threshold in the second group of weights is 0.45. Then, each group of weights is pruned according to the above-determined thresholds. Specifically, in the first group of weights, weights less than 0.7 are removed. In the second group of weights, weights less than 0.45 are removed. After pruning, it can be ensured that the sparsity of the two groups of weights is the same.

[0141] Taking the LSTM layer of the neural network as an example, each group of weights in the M groups of weights is pruned according to a determined threshold value to obtain the second weight data. The specific implementation of this solution can refer to the aforementioned text description of pruning the fully connected layer, which will not be elaborated here.

[0142] Through the embodiment of the present invention, after obtaining the load balancing instruction, the controller unit parses it to obtain multiple operation instructions, and then sends the multiple operation instructions and the first weight data to the load balancing unit. The load balancing unit then groups the first weight data, calculates the threshold in each group of weights, and performs pruning and other operations according to the threshold. The first weight data can be adjusted to obtain the second weight data, which can ensure that the sparsity of each group of weights is the same, solves the problem of load imbalance caused by the different amount of calculation of each neuron caused by the sparsity problem, and improves the calculation speed.

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

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

[0145] 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 the load balancing instruction mentioned above, and no further details will be given here.

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

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

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

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

[0150] 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 the second weight data and the input neuron data.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0169] The following is an explanation of the neural network operation instructions. Figure 1 The specific calculation method of the computing 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.

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

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

[0172] Optionally, the tree module may be an n-ary tree structure, for example, Fig. 9 The binary tree structure shown in FIG. 1 may also be a ternary tree structure, and n may 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 may also be 2. The slave processing circuit may be connected to nodes of other layers except the penultimate layer node, for example, it may be connected to nodes of Fig. 9 The nodes of the penultimate layer are shown.

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

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

[0175] 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,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0208] In the embodiment of the present invention, it is considered that the pruning method for the neural network can be applied to the computing device mentioned above, and can also be applied to other scenarios, for example, to reduce the accuracy loss of the neural network. Fig.16The flowchart of the neural network pruning method provided by the embodiment of the present invention is shown, which specifically illustrates how the present invention implements balanced pruning of first weight data to obtain second weight data, and may include but is not limited to the following steps:

[0209] Step S100: Obtain first input data; wherein the first input data includes first weight data.

[0210] In a specific implementation, the first weight data may 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.

[0211] Step S102: Adjust the first weight data to second weight data.

[0212] In one implementation manner, adjusting the first weight data to second weight data includes:

[0213] Grouping the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0214] Determining a threshold of at least one set of weights in the M sets of weights according to a preset sparsity P;

[0215] At least one group of weights in the M groups of weights is pruned according to the determined threshold value to obtain second weight data.

[0216] In another embodiment, adjusting the first weight data to second weight data includes:

[0217] Grouping the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0218] Determine a threshold value of each group of weights in the M groups of weights according to a preset sparsity P;

[0219] Each group of weights in the M groups of weights is pruned according to the determined threshold value to obtain second weight data.

[0220] In the embodiment of the present invention, grouping the first weight data may include continuously grouping the first weight data, or may include cross-grouping the first weight data.

[0221] In a specific implementation, in the process of adjusting the first weight data to the second weight data, when applied to different neural networks (for example, a fully connected layer neural network, a convolutional layer neural network, and an LSTM layer neural network), the grouping operation on the first weight data, determining the threshold in each group of weights, and performing pruning operations according to the threshold will be different, which will be specifically described below:

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

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

[0224] In practical applications, when the weights of the fully connected layer are divided into M groups, M is greater than 1 and less than N. out A positive integer.

[0225] In one embodiment, when the weight matrix is ​​grouped continuously, the continuous weight matrix The i-th group of weights includes the i-th Row, No. Row, No. Row, ..., Where i is a positive integer greater than 0 and less than M, N out is the number of output neurons.

[0226] In another embodiment, when the weight matrix is ​​cross-grouped, the alternating The i-th group of weights includes the i-th row, i+M-th row, i+M*2-th row, ..., i ... Where i is a positive integer greater than 0 and less than M, N out is the number of output neurons.

[0227] As mentioned above, when the weight matrix can be expressed as Figure 5B , assuming that the above 12 weights are divided into 4 groups, then the number of weights in each group is 3. When the grouping mode is continuous grouping, for the continuous grouping of the above 12 weights, please refer to Figure 5C .like Figure 5C As shown, the first group of weights is the first row of the weight matrix; the second group of weights is the second row of the weight matrix; the third group of weights is the third row of the weight matrix; and the fourth group of weights is the fourth row of the weight matrix.

[0228] Similarly, in actual applications, assume that the above 12 weights are divided into 2 groups. In this case, the number of weights in each group is 6. When the grouping mode is cross grouping, for the cross grouping of the above 12 weights, please refer to Figure 5D ,like Figure 5D As shown, the first set of weights is the 1st row and the 3rd row of the weight matrix; the second set of weights is the 2nd row and the 4th row of the weight matrix.

[0229] After the first weight data is grouped, a threshold value of each weight group in the M weight groups is determined according to a preset sparsity P, including:

[0230] Determine the Qth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0231] In practical applications, it is considered that Q calculated using the above calculation formula for Q may include an integer or a non-integer. In one optional implementation, when Q is a non-integer, a rounding operation may be performed on Q. In a specific implementation, the rounding operation involved here may include an upward rounding operation or a downward rounding operation.

[0232] For example, Figure 5A Taking the fully connected layer from the input layer to the hidden layer in the neural network architecture shown as an example, the number of input neurons is 3, the number of output neurons is 4, and the number of weights is 12. The weight matrix is ​​divided into 4 groups by continuous grouping. The second weight in the first group of weights is determined as the threshold of each group of weights according to the preset sparsity P. Among them, the second weight in the first group of weights is 0.5, that is, the threshold of the first group of weights is 0.5; the second weight in the second group of weights is 0.4, that is, the threshold of the second group of weights is 0.4; the second weight in the third group of weights is 0.65, that is, the threshold of the third group of weights is 0.65; the second weight in the fourth group of weights is 0.45, that is, the threshold of the fourth group of weights is 0.45.

[0233] After determining the threshold of each group of weights according to the preset sparsity P, each group of weights is pruned according to the determined threshold. In layman's terms, pruning each group of weights in the M groups of weights means removing some unnecessary weights to reduce the scale of the parameters of the neural network.

[0234] In a specific implementation, each group of weights in the M groups of weights is pruned according to a determined threshold value to obtain second weight data, including:

[0235] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

[0236] As mentioned earlier, taking the fully connected layer of a neural network as an example, Figure 5C As shown, when the grouping mode is continuous grouping, the 12 weights are divided into 4 groups, where the first group of weights is the first row of the weight matrix; the second group of weights is the second row of the weight matrix; the third group of weights is the third row of the weight matrix; and the fourth group of weights is the fourth row of the weight matrix. According to the preset sparsity P, the threshold in the first group of weights is determined to be 0.5, the threshold in the second group of weights is 0.4, the threshold in the third group of weights is 0.65, and the threshold in the fourth group of weights is 0.45. Then, each group of weights is pruned according to the above-determined thresholds. Specifically, in the first group of weights, weights less than 0.5 are removed. In the second group of weights, weights less than 0.4 are removed. In the third group of weights, weights less than 0.65 are removed. In the fourth group of weights, weights less than 0.45 are removed. Specifically, for Figure 5C The schematic diagram after pruning the four groups of weights shown in FIG. 5I is as shown in FIG. Fig.5I As shown in Figure 1, after pruning, the sparsity of these four groups of weights can be ensured to be the same.

[0237] In one embodiment, when M=N out , that is, when the number of groups is equal to the number of output neurons, it can ensure that the amount of calculation for each neuron is the same, thus solving the problem of load imbalance.

[0238] (2) Convolutional neural network:

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

[0240] In practical applications, when the weights of the convolutional layer are divided into M groups, M is greater than 1 and less than N. fout A positive integer.

[0241] In one embodiment, when the weight matrix is ​​grouped continuously, the continuous weight matrix The convolution kernels are in the same group. The i-th group of weights includes the , , , ..., convolution kernels. Where i is a positive integer greater than 0 and less than M.

[0242] In another embodiment, when the weight matrix is ​​cross-grouped, the alternating convolution kernels are in the same group. The i-th group of weights includes the i-th, i+M-th, i+M*2-th, ..., i ... convolution kernels. Where i is a positive integer greater than 0 and less than M.

[0243] As mentioned above, when the convolution kernel in the weight matrix is ​​expressed as shown in 5E, the number of convolution kernels is 4. Assume that the above 4 convolution kernels are divided into 2 groups. In this case, the number of convolution kernels in each group is 2. When the grouping mode is continuous grouping, for the continuous distribution of the above 4 convolution kernels, please refer to Fig. 5F ,like Fig. 5F As shown, the first set of weights is the first convolution kernel and the second convolution kernel in the weight matrix; the second set of weights is the third convolution kernel and the fourth convolution kernel in the weight matrix.

[0244] Similarly, in practical applications, assume that the above 4 convolution kernels are divided into 2 groups. In this case, the number of convolution kernels in each group is 2. When the separation mode is cross grouping, for the cross grouping of the above 4 convolution kernels, please refer to Figure 5G ,like Figure 5G As shown, the first set of weights is the first convolution kernel and the third convolution kernel in the weight matrix; the second set of weights is the second convolution kernel and the fourth convolution kernel in the weight matrix.

[0245] After the first weight data is grouped, a threshold value of each weight group in the M weight groups is determined according to a preset sparsity P, including:

[0246] Determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N fin is the number of input feature images, N fout is the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0247] As an optional implementation, R is obtained by a rounding operation. Similarly, the rounding operation may include an upward rounding operation or a downward rounding operation.

[0248] For example, Figure 5G The convolution layer shown in the figure uses a cross-grouping method to divide the weight matrix into two groups. The first group of weights is the first and third convolution kernels in the weight matrix; the second group of weights is the second and fourth convolution kernels in the weight matrix. The sixth weight in the first group of weights is determined as the threshold of each group of weights according to the preset sparsity. Among them, the sixth weight in the first group of weights is 0.7, that is, the threshold of the first group of weights is 0.7; the sixth weight in the second group of weights is 0.45, that is, the threshold of the second group of weights is 0.45.

[0249] After determining the threshold of each group of weights according to the preset sparsity P, pruning each group of weights according to the determined threshold. In a specific implementation, pruning each group of weights in the M groups of weights according to the determined threshold to obtain second weight data includes:

[0250] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

[0251] by Figure 5G The convolution layer shown in FIG. 1 is used as an example to illustrate that when the grouping mode is cross grouping, the weight matrix is ​​divided into two groups, wherein the first group of weights is the first convolution kernel and the third convolution kernel in the weight matrix; the second group of weights is the second convolution kernel and the fourth convolution kernel in the weight matrix. The threshold in the first group of weights determined according to the preset sparsity P is 0.7, and the threshold in the second group of weights is 0.45. Then, each group of weights is pruned according to the above-determined thresholds. Specifically, in the first group of weights, weights less than 0.7 are removed. In the second group of weights, weights less than 0.45 are removed. After pruning, it can be ensured that the sparsity of the two groups of weights is the same.

[0252] (3) LSTM layer neural network:

[0253] In the specific implementation, 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 .

[0254] In practical applications, each of the t fully connected layers mentioned above is grouped. Taking the jth fully connected layer as an example, the weights of the jth fully connected layer are divided into M groups, then the number of weights in each group of the jth fully connected layer is: Where M is greater than 1 and less than N out_j A positive integer.

[0255] In one embodiment, when the weight matrices in the j-th fully connected layer are grouped continuously, the continuous weight matrices The i-th group of weights includes the i-th Row, No. Row, No. Row, ..., Where i is a positive integer greater than 0 and less than M, N out_j is the number of output neurons in the jth fully connected layer.

[0256] In another embodiment, when the weight matrix in the j-th fully connected layer is continuously grouped, the alternating The i-th group of weights includes the i-th row, i+M-th row, i+M*2-th row, ..., i ... Where i is a positive integer greater than 0 and less than M, N out_j is the number of output neurons in the jth fully connected layer.

[0257] After the first weight data is grouped, a threshold in each group of weights is determined according to a preset sparsity P, including:

[0258] Determine the Sth weight in the i-th group of weights of the j-th fully connected layer as the threshold for each group of weights, where is the number of input neurons in the jth fully connected layer, N out_j is the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to the absolute value, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N. As an optional implementation, S is obtained by rounding operation. Similarly, the rounding operation may include rounding up operation or rounding down operation.

[0259] After determining the threshold of each group of weights according to the preset sparsity P, pruning each group of weights according to the determined threshold. In a specific implementation, pruning each group of weights in the M groups of weights according to the determined threshold to obtain second weight data includes:

[0260] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

[0261] In practical applications, when the balanced pruning method described in this application is applied to the LSTM layer neural network, each group of weights in the M groups of weights is pruned according to a determined threshold value to obtain the second weight data. The specific implementation of this solution can refer to the aforementioned text description of pruning the fully connected layer, and no further details will be given here.

[0262] The embodiment of the present invention groups the first weight data, calculates the threshold in each group of weights, and prunes each group of weights according to the determined threshold, thereby ensuring that the sparsity of each group of weights is the same, solving the problem of load imbalance caused by the different amount of calculation of each neuron due to the sparsity problem, and improving the calculation speed.

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

[0264] like Fig.17A The structure diagram of the neural network pruning device provided by the embodiment of the present invention shown in the figure, the neural network pruning device includes: an acquisition unit 300, a load balancing unit 13 and a calculation unit 304;

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

[0266] The load balancing unit 13 is used to adjust the first weight data to second weight data;

[0267] 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 data and input neuron data.

[0268] In one embodiment, if Fig. 17B As shown, the load balancing unit 13 includes a grouping unit 130, a threshold calculation unit 131 and a pruning unit 132;

[0269] The grouping unit 130 is used to group the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0270] The threshold value calculating unit 131 is used to determine a threshold value of at least one group of weights in the M groups of weights according to a preset sparsity P;

[0271] The pruning unit 132 is used to prune at least one group of weights in the M groups of weights according to the determined threshold value to obtain second weight data.

[0272] In another embodiment, the load balancing unit 13 includes a grouping unit 130, a threshold calculation unit 131, and a pruning unit 132;

[0273] The grouping unit 130 is used to group the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0274] The threshold value calculating unit 131 is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P;

[0275] The pruning unit 132 is used to prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data.

[0276] Optionally, the neural network is a fully connected layer neural network; the threshold calculation unit 131 is specifically used for:

[0277] Determine the Qth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0278] Optionally, the Q is obtained by rounding off.

[0279] Optionally, the neural network is a convolutional layer neural network; the threshold calculation unit 131 is further specifically used for:

[0280] Determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N fin is the number of input feature images, N fout is the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0281] Optionally, the neural network is an LSTM layer neural network; the LSTM layer neural network includes N fully connected layers, where N is a positive integer greater than 0; the threshold calculation unit 131 is further specifically used for:

[0282] Determine the Sth weight in the i-th group of weights of the j-th fully connected layer as the threshold for each group of weights, where N in_j is the number of input neurons in the jth fully connected layer, N out_j is the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to their absolute values, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N.

[0283] Optionally, the pruning unit 132 is specifically configured to:

[0284] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

[0285] The embodiment of the present invention groups the first weight data, calculates the threshold in each group of weights, and prunes each group of weights according to the determined threshold, thereby ensuring that the sparsity of each group of weights is the same, solving the problem of load imbalance caused by the different amount of calculation of each neuron due to the sparsity problem, and improving the calculation speed.

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

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

[0288] Acquire first input data; wherein the first input data includes first weight data;

[0289] adjusting the first weight data to second weight data;

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

[0291] The processor 401 adjusting the first weight data to the second weight data may include:

[0292] Grouping the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0293] Determining a threshold of at least one set of weights in the M sets of weights according to a preset sparsity P;

[0294] At least one group of weights in the M groups of weights is pruned according to the determined threshold value to obtain second weight data.

[0295] The processor 401 adjusting the first weight data to the second weight data may include:

[0296] Grouping the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0;

[0297] Determine a threshold value of each group of weights in the M groups of weights according to a preset sparsity P;

[0298] Each group of weights in the M groups of weights is pruned according to the determined threshold value to obtain second weight data.

[0299] Wherein, the neural network is a fully connected layer neural network;

[0300] The processor 401 determines the threshold of each group of weights in the M groups of weights according to the preset sparsity P, which may include:

[0301] Determine the Qth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0302] Wherein, the neural network is a convolutional layer neural network;

[0303] The processor 401 determines the threshold of each group of weights in the M groups of weights according to the preset sparsity P, which may include:

[0304] Determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value for each group of weights, wherein, N fin is the number of input feature images, N foutis the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

[0305] Wherein, the neural network is an LSTM layer neural network; the LSTM layer neural network includes N fully connected layers, and N is a positive integer greater than 0;

[0306] The processor 401 determines the threshold of each group of weights in the M groups of weights according to the preset sparsity P, which may include:

[0307] Determine the Sth weight in the i-th group of weights of the j-th fully connected layer as the threshold for each group of weights, where N in_j is the number of input neurons in the jth fully connected layer, N out_j is the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to their absolute values, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N.

[0308] The processor 401 prunes each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data, including:

[0309] The weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold are pruned to obtain the second weight data.

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

[0311] 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 pruning method for the neural network can be integrated into the NPU. In one embodiment, the processor 401 can control the NPU to execute the pruning method for the first weight data.

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

[0313] 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, balanced pruning of the first weight data can be achieved, thereby solving the problem of load imbalance caused by different computational loads of each neuron due to sparsity problems.

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

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

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

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

[0318] 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-mentioned integrated unit may be implemented in the form of hardware or in the form of a software program module.

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

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

[0321] 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 load balancing unit, a computing unit, and a controller unit; The controller unit is configured to obtain a pruning request for first input data, and instruct the load balancing unit to prune the first input data according to the pruning request; wherein the first input data includes first weight data; The load balancing unit is used to adjust the first weight data to second weight data; The controller unit is further used to obtain second input data and calculation instructions; the second input data includes the second weight data 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 computing unit is used to obtain the computing instruction and perform neural network calculation according to the computing instruction and the second input data; The load balancing unit includes: a grouping unit, a threshold calculation unit and a pruning unit; The grouping unit is used to group the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0; The threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P; The pruning unit is used to prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data; The computing device is used to perform convolutional neural network calculations; the threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is specifically used to determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value of each group of weights, wherein, N fin is the number of input feature images, N fout is the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order of absolute value, and i is a positive integer less than or equal to M; 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.

2. The computing device according to claim 1, wherein: The computing device is used to perform fully connected layer neural network calculations; the threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is specifically used to determine the Qth weight in the i-th group of weights in the M groups of weights as the threshold value of each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

3. The computing device according to claim 2, characterized in that The Q is obtained by rounding.

4. The computing device according to claim 1, wherein: 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; The threshold value calculating unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is specifically used to determine the Sth weight value in the i-th group of weights of the j-th fully connected layer as the threshold value of each group of weights, wherein, N in_j is the number of input neurons in the jth fully connected layer, N out_j is the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to their absolute values, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N.

5. The computing device according to claim 1, wherein: The pruning unit is used to prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data, including: The pruning unit is specifically used to prune the weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold value to obtain the second weight data.

6. 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 scratch pad cache.

7. The computing device according to claim 1, wherein: 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 the order of the queue.

8. The computing device according to claim 1, wherein: 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 an 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.

9. 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 8, 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 to 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.

10. A combined processing device, characterized in that: The combined processing device includes the machine learning computing device as claimed in claim 9, a universal interconnection interface and other processing devices; The machine learning computing device interacts with the other processing devices to jointly complete the computing operations specified by the user.

11. The combined processing device according to claim 10, characterized in that: It also includes: a storage device, which is connected to the machine learning operation device and the other processing device respectively, and is used to store data of the machine learning operation device and the other processing device.

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

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

14. 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 13; 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.

15. 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 load balancing unit, a computing unit and a controller unit; the method comprises: The controller unit obtains a pruning request for first input data, and instructs the load balancing unit to prune the first input data according to the pruning request; wherein the first input data includes first weight data; The load balancing unit adjusts the first weight data to second weight data; The controller unit acquires second input data and a calculation instruction; the second input data includes the second weight data 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 computing unit obtains the computing instruction, and performs neural network calculation according to the computing instruction and the second input data; The load balancing unit includes: a grouping unit, a threshold calculation unit and a pruning unit; The grouping unit is used to group the first weight data to obtain M groups of weights; wherein M is a positive integer greater than 0; The threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P; The pruning unit is used to prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data; The computing device is used to perform convolutional neural network calculations; the threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is specifically used to determine the Rth weight in the i-th group of weights in the M groups of weights as the threshold value of each group of weights, wherein, N fin is the number of input feature images, N fout is the number of output feature images, K x and K y is the size of the convolution kernel in the convolutional layer neural network, the weights in the i-th group are arranged in ascending order of absolute value, and i is a positive integer less than or equal to M; 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.

16. The method according to claim 15, characterized in that The computing device is used to perform fully connected layer neural network calculations; the threshold value calculation unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is used to determine the Q-th weight in the i-th group of weights in the M groups of weights as the threshold value of each group of weights, wherein, N in is the number of input neurons, N out is the number of output neurons, the weights in the i-th group are arranged in ascending order according to their absolute values, and i is a positive integer less than or equal to M.

17. The method according to claim 16, characterized in that The Q is obtained by rounding.

18. The method according to claim 15, 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; The threshold value calculating unit is used to determine the threshold value of each group of weights in the M groups of weights according to a preset sparsity P, including: The threshold value calculation unit is used to determine the Sth weight value in the i-th group of weights of the j-th fully connected layer as the threshold value of each group of weights, wherein, N in_j is the number of input neurons in the jth fully connected layer, N out_j is the number of output neurons of the jth fully connected layer, the weights in the i-th group are arranged in ascending order according to their absolute values, i is a positive integer less than or equal to M, and j is a positive integer less than or equal to N.

19. The method according to claim 15, characterized in that The pruning unit is used to prune each group of weights in the M groups of weights according to the determined threshold value to obtain second weight data, including: The pruning unit is used to prune the weights in the i-th group (i=0, 1, ..., M) of weights that are smaller than the determined threshold value to obtain the second weight data.

20. The method according to claim 15, 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; and the cache includes a high-speed scratch pad cache.

21. The method according to claim 15, characterized in that 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, which includes: a plurality of operation instructions or calculation instructions to be executed in a front-to-back order of the queue.

22. The method according to claim 19, characterized in that 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, and if the first operation instruction has an association relationship with the zeroth operation instruction, caches the first operation instruction in an instruction storage unit, and extracts the first operation instruction from the instruction storage unit and transmits 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.