Data processing methods and related products

By selecting the appropriate processing method according to the type of the second network layer, the fully connected layer parameters in the neural network are stored and processed in CSR or CSC format, and processed in blocks when necessary, which solves the problem of slow operation speed of the fully connected layer. , improving the overall computing efficiency of the neural network.

CN112749782BActive Publication Date: 2024-10-29SHANGHAI SENSETIME INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911054334.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-31
Publication Date
2024-10-29
Estimated Expiration
2039-10-31

AI Technical Summary

Technical Problem

In neural networks, the operation speed of network layers with more parameters is slower, especially the fully connected layer. Although the parameters are sparsely processed, the operation of the input data and the sparse parameters is still slow.

Method used

By determining the target processing method from a variety of preset candidate processing methods according to the type of the second network layer, the network parameters and input data of the first network layer are processed, using compressed sparse rows (CSR) or compressed sparse columns ( CSC) format, and process parameters in blocks when necessary to reduce computational complexity.

Benefits of technology

It improves the computing speed of the first network layer, simplifies the computing process of the fully connected layer, and improves the overall computing speed of the neural network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112749782B_ABST
    Figure CN112749782B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a data processing method, including: determining a target processing method from a plurality of preset candidate processing methods based on the layer type of at least one second network layer connected to a first network layer of a neural network, wherein the network parameters of the first network layer are sparse data; using the target processing method, processing the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, wherein the input data of the first network layer is obtained based on the input image of the neural network. The embodiment of the present application is beneficial to the operation speed of the neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and specifically to data processing methods and related products. Background Art

[0002] In a neural network, there are some network layers with many parameters, such as the fully connected layer used to transform the feature map into the sample space. In order to improve the operation speed of these network layers, the parameters of these network layers need to be sparse to obtain a sparse network layer, thereby reducing the model size and improving the operation speed. Then, the input data of the network layer is processed using the sparse parameters in a pre-set manner. However, when the input data is operated with the sparse parameters, the operation process is still slow. Summary of the invention

[0003] The embodiments of the present application provide a data processing method and related products.

[0004] In a first aspect, an embodiment of the present application provides a data processing method, including:

[0005] Determining a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data;

[0006] The target processing method is used to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, wherein the input data of the first network layer is obtained based on the input image of the neural network.

[0007] In some possible implementations, before processing the network parameters of the first network layer and the input data of the first network layer by using the target processing mode, the method further includes:

[0008] The input image is processed through multiple network layers of the neural network to obtain input data of the first network layer.

[0009] In some possible implementations, the first network layer is a fully connected layer.

[0010] In some possible implementations, the at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

[0011] In some possible implementations, the multiple candidate processing methods include: a processing method based on compressed sparse rows (CSR) and a processing method based on compressed sparse columns (CSC).

[0012] In some possible implementations, the layer type of at least one second network layer connected to the first network layer of the neural network, determining the target processing method from a plurality of preset candidate processing methods, includes:

[0013] In response to the at least one second network layer including a linear rectifier ReLu layer, determining a CSC-based processing mode as a target processing mode; and / or

[0014] In response to the at least one second network layer including other activation layers except the ReLu layer, a CSR-based processing mode is determined as a target processing mode.

[0015] In some possible implementations, the method further includes:

[0016] Based on the target processing mode, the network parameters are stored.

[0017] Based on the target processing mode, before processing the network parameters of the first network layer and the input data of the first network layer by using the target processing mode, the method further includes:

[0018] In response to the dimension of the network parameter of the first network layer exceeding the preset dimension, the network parameter is processed in blocks to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within the value range of the short integer data type;

[0019] The plurality of parameter blocks are stored by a short integer data type.

[0020] In a second aspect, an embodiment of the present application provides a data processing device, including:

[0021] a determining unit, configured to determine a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data;

[0022] A processing unit is used to process the network parameters of the first network layer and the input data of the first network layer using the target processing method to obtain a data processing result, wherein the input data of the first network layer is obtained based on an input image of the neural network.

[0023] In some possible implementations, before using the target processing method to process the network parameters of the first network layer and the input data of the first network layer, the processing unit is further used to process the input image through multiple network layers of the neural network to obtain the input data of the first network layer.

[0024] In some possible implementations, the first network layer is a fully connected layer.

[0025] In some possible implementations, the at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

[0026] In some possible implementations, the multiple candidate processing methods include: a processing method based on compressed sparse rows (CSR) and a processing method based on compressed sparse columns (CSC).

[0027] In some possible implementations, in determining the target processing method from a plurality of preset candidate processing methods based on the layer type of at least one second network layer connected to the first network layer of the neural network, the determining unit is specifically used to:

[0028] In response to the at least one second network layer including a linear rectifier ReLu layer, determining a CSC-based processing mode as a target processing mode; and / or

[0029] In response to the at least one second network layer including other activation layers except the ReLu layer, a CSR-based processing mode is determined as a target processing mode.

[0030] In some possible implementations, the processing unit is further configured to store the network parameters based on the target processing mode.

[0031] In some possible implementations, the data processing device further includes a block division unit, which, before processing the network parameters of the first network layer and the input data of the first network layer using the target processing mode,

[0032] The blocking unit is configured to, in response to a dimension of the network parameter of the first network layer exceeding a preset dimension, block the network parameter to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within a value range of a short integer data type;

[0033] The plurality of parameter blocks are stored by a short integer data type.

[0034] In some possible implementations, in terms of using the target processing mode to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, the processing unit is specifically used to:

[0035] Determining whether a current element in the input data is zero;

[0036] In response to the current element being 0, a portion of the data processing result corresponding to the current element is determined to be zero.

[0037] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the method described in the first aspect.

[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method described in the first aspect.

[0039] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer is operable to cause the computer to execute the method described in the first aspect.

[0040] Implementing the embodiments of the present application has the following beneficial effects:

[0041] It can be seen that in the embodiment of the present application, the target processing method of the first network layer is determined according to the layer type of the first one or more second network layers, and the input data of the first network layer is processed using the target processing method. This can achieve targeted processing based on the input data, which is beneficial to improving the computing speed of the first network layer. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0045] Figure 3 A block diagram of the functional units of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

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

[0048] Reference to "embodiments" herein means that a particular feature, result, 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.

[0049] Figure 1 A flow chart of a data processing method provided in an embodiment of the present application, which can be applied to the processing of a sparse network layer of a neural network. For ease of understanding, the following description is given using a fully connected layer as an example, but the embodiments of the present disclosure are not limited thereto.

[0050] 101: Determine a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network.

[0051] The network parameters of the first network layer are sparse data.

[0052] It can be understood that when the first network layer is a fully connected layer, the network parameters can also be called the weight matrix of the fully connected layer, and the weight matrix is ​​a sparse weight matrix.

[0053] In addition, the at least one second network layer is the N network layers before the fully connected layer in the neural network, and N is a value greater than or equal to 1. When N=1, the at least one second network layer is the previous network layer connected to the fully connected layer in the neural network, and the second network layer can be one of other network layers such as a nonlinear activation layer, a pooling layer, and a convolutional layer.

[0054] Based on the mapping relationship between the layer type and the target processing mode, a target processing mode corresponding to the layer type of the at least one second network layer is selected from a plurality of preset candidate processing modes.

[0055] 102: Using the target processing method, process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result.

[0056] Before processing the network parameters of the first network layer using the target processing method, the input image is first processed through multiple network layers of the neural network to obtain input data of the first network layer.

[0057] Because the layer types of the first N network layers connected to the fully connected layers of different depths are different. For example, the previous network layer connected to the first fully connected layer is a pooling layer, the previous network layer connected to the second fully connected layer is a nonlinear activation layer, and so on. Therefore, the number of non-zero values ​​contained in the input data of fully connected layers of different depths is different. For example, the input data of the fully connected layer connected to the nonlinear activation layer contains a large amount of zero-value data. Therefore, the target processing method corresponding to the layer type of at least one second network layer connected to the first network layer (fully connected layer) can be adopted, and the network parameters (weight matrix) of the first network layer can be stored in a storage format corresponding to the target processing method, and the network parameters stored in the storage format are processed with the input data to obtain the data processing results.

[0058] Among them, the fully connected layer is any one of the multiple fully connected layers of the neural network, and the processing method of the network parameters of other fully connected layers is consistent with that of the fully connected layer, which will not be described again.

[0059] It can be seen that in the embodiment of the present application, a target processing method is selected according to the layer types of the first N network layers, and the target processing method is used to process the input data and weight matrix of the fully connected layer. Considering the layer types of other network layers connected to the fully connected layer, targeted processing based on input data can be achieved, thereby simplifying the operation process of the fully connected layer and improving the operation speed of the entire neural network.

[0060] In some possible implementations, the multiple candidate processing methods include a processing method based on a compressed sparse row (Compressed Sparse Row, CSR) and a processing method based on a compressed sparse column (Compressed Sparse Column, CSR).

[0061] The following describes in detail the storage methods of the weight matrix in the two processing methods.

[0062] ①Store the weight matrix using CSC processing method.

[0063] The sparse matrix M (i.e., the weight matrix m*n of the fully connected layer) is stored as three 1-dimensional vectors (A, IA, JA). Among them, vector A is used to store the values ​​of non-zero elements in the sparse matrix M. The non-zero elements in the sparse matrix M are arranged in sequence in a column traversal manner from left to right and from top to bottom to obtain vector A. The dimension of vector A is represented by A, that is, the number of non-zero elements in the sparse matrix M; the dimension of vector JA is n+1, JA[0]=0, and JA[i]=JA[i-1]+(the number of non-zero elements in the i-1th column of M). Since programming starts from the 0th column, the i-1th column here is actually the i-th column of the sparse matrix M; the dimension of vector IA is represented by MMZ, and the row index of each non-zero value in the sparse matrix M is stored in vector IA.

[0064] Furthermore, after the weight matrix of the fully connected layer is stored in the CSC storage format, assuming that the input data of the fully connected layer is X and the output vector is Y, the operation of the fully connected layer satisfies the following cycle, namely:

[0065] for(i=0;i <n;i++)

[0066] {for(j=JA[i]; j <JA[i+1];j++)

[0067] Y[IA[j]]+=A[j]*X[i]}

[0068] ②Store the weight matrix using CSR processing method.

[0069] Similarly, the sparse matrix M is stored as three one-dimensional vectors (A, IA, JA). Vector A is used to store the values ​​of non-zero elements in the sparse matrix M. The non-zero elements in the sparse matrix M are arranged in sequence in a row traversal manner from left to right and from top to bottom to obtain vector A. The dimension of vector A is represented by A, that is, the number of non-zero elements in the sparse matrix M; the dimension of vector JA is m+1, JA[0]=0, and JA[i]=JA[i-1]+(the number of non-zero elements in the i-1th row in M); the dimension of vector IA is represented by MMZ, which stores the column index of each non-zero value in the sparse matrix M.

[0070] Furthermore, after the weight matrix of the fully connected layer is stored in the CSR storage format, assuming that the input data of the fully connected layer is X and the output vector is Y, the operation of the fully connected layer satisfies the following cycle, namely:

[0071] for(i=0;i <m;i++)

[0072] for(j=IA[i];j <IA[i+1];j++)

[0073] Y[i]+=A[j]*X[JA[j]]

[0074] It can be seen that after the weight matrix is ​​stored in the CSC storage format, if the i-th element X[i] in the input data X is equal to zero, then the column operation between X[i] and the weight matrix, that is, the process in which j starts from JA[i] and takes values ​​to JA[i+1] in sequence, does not need to participate in the operation, and the output result of the column operation is directly zero.

[0075] Since, after the data passes through the linear rectification Relu activation layer, multiple zero values ​​will be obtained. Therefore, when the input data X of the fully connected layer is processed by the Relu activation layer, the input data X corresponding to the fully connected layer will contain multiple zero values, and the weight matrix of the fully connected layer is stored in the CSC storage format, so that when the weight matrix of the fully connected layer is operated with the input data X, there are multiple column operations that do not need to participate in the operation, and the column operation result is directly obtained as zero, thereby improving the operation speed of the fully connected layer; when the input data X of the fully connected layer is not processed by the Relu activation layer, there are no large number of zero values ​​in the input data X, therefore, a general storage method can be used, that is, the CSR storage format can be used to store the weight matrix of the fully connected layer, of course, the CSC storage format can also be used to store the weight matrix of the fully connected layer, and other storage formats can also be used to store the weight matrix of the fully connected layer, and this application does not limit this.

[0076] Therefore, in combination with the characteristics of the input data X, in response to the at least one second network layer including a ReLu layer, the CSC-based processing method is determined as the target processing method, and the CSC processing method is used to store the weight matrix to simplify the subsequent weight matrix and input data operations and improve the operation speed. That is, when the input data X and the weight matrix are processed to obtain the data processing result, it is determined whether the current element in the input data X is 0. In response to the current element being 0, the column operation result corresponding to the current element in the data processing result is directly determined to be 0 without participating in the operation, thereby improving the operation speed; in response to the at least one second network layer including other activation layers except the ReLu activation layer, that is, the at least one second network layer does not include the ReLu activation layer, the CSR-based processing method is determined as the target processing method, and the CSR processing method is used to store the weight matrix.

[0077] It should be noted that when there are more than one second network layer (the first N network layers) connected to the fully connected layer, the first N network layers will have more complex layer types. Even if the first N network layers include a ReLu activation layer, due to the participation of other complex network layers, there will not be many zeros in the input data of the fully connected layer. At this time, it is not suitable to use the CSC storage format for sparseness. For example, if the first N network layers include a ReLu activation layer, a convolution layer, and a pooling layer, if the input image is first passed through the ReLu activation layer, and then through the convolution layer and the pooling layer to obtain the input data of the fully connected layer, due to the processing of the convolution layer, there will not be a large number of zero values ​​in the input data of the fully connected layer. Therefore, in practical applications, the layer type of the previous network layer or the previous few network layers of the fully connected layer is generally obtained, and the target processing method is determined from a variety of candidate processing methods through the layer type of the previous network layer or the previous few network layers.

[0078] In some possible implementations, when the dimension of the weight matrix of the fully connected layer exceeds the preset dimension, when the weight matrix of the fully connected layer is stored in the CSR processing mode or the CSC processing mode, the dimensions of the three one-dimensional vectors obtained are relatively high. When performing the operation of the fully connected layer, when accessing the elements in each one-dimensional vector, the access span is relatively large, which is prone to cache miss problems.

[0079] For example, when the CSR processing method is used for storage, when the dimension of the weight matrix of the fully connected layer is large, when executing the operation of the fully connected layer, it is necessary to access from JA[1] to JA[n]. Since n is relatively large, the access span is relatively large, so it is easy to lose the cache when obtaining the elements in the vector JA for operation.

[0080] Therefore, when the dimension of the network parameters of the fully connected layer exceeds the preset dimension, the network parameters are first divided into blocks to obtain multiple network parameter blocks. Then, each network parameter block is processed according to the selected target processing method. The processing process is consistent with the above and will not be described again.

[0081] The dimensions of each sub-matrix may be the same or different, and this application does not impose any limitation on this.

[0082] In addition, when dividing into blocks, the dimension of the control network parameter block is within the value range of the short integer data type, that is, the row size and column size of each network parameter block are both less than or equal to 65535. Since the number of rows and columns are both less than 65535, the elements in the above-mentioned vector JA and vector IA are all less than 65535, and the unsigned short data type can be used to encode the elements in the vector JA and vector IA; in addition, when the number of rows and columns is less than or equal to 32768, the short integer short data type can also be used to encode the elements in the vector JA and vector IA; thereby replacing the existing encoding method of using the unsigned int data type when the dimension of the network parameter is large. Since the unsigned int data type requires 4 bytes for encoding, and the unsigned short data type or the short data type uses 2 bytes for encoding, the size of the model is reduced and the cache bandwidth and reading speed are improved.

[0083] Figure 2 A structural diagram of a data processing device provided in an embodiment of the present application. The data processing device 200 includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are different from the one or more application programs, and the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the following steps:

[0084] Determining a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data;

[0085] The target processing method is used to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, wherein the input data of the first network layer is obtained based on the input image of the neural network.

[0086] In some possible implementations, before processing the network parameters of the first network layer and the input data of the first network layer by using the target processing mode, the program is further used to execute instructions of the following steps:

[0087] The input image is processed through multiple network layers of the neural network to obtain input data of the first network layer.

[0088] In some possible implementations, the first network layer is a fully connected layer.

[0089] In some possible implementations, the at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

[0090] In some possible implementations, the multiple candidate processing modes include: a processing mode based on row compression CSR and a processing mode based on column compression CSC.

[0091] In some possible implementations, in terms of determining a target processing method from a plurality of preset candidate processing methods based on the layer type of at least one second network layer connected to the first network layer of the neural network, the above program is specifically used to execute instructions of the following steps:

[0092] In response to the at least one second network layer including a ReLu layer, determining a CSC-based processing mode as a target processing mode; and / or

[0093] In response to the at least one second network layer including other activation layers except the ReLu layer, a CSR-based processing mode is determined as a target processing mode.

[0094] In some possible implementations, the above program is also used to execute instructions for the following steps:

[0095] Based on the target processing mode, the network parameters are stored.

[0096] In some possible implementations, before processing the network parameters of the first network layer and the input data of the first network layer using the target processing method, the program is further used to execute instructions of the following steps:

[0097] In response to the dimension of the network parameter of the first network layer exceeding the preset dimension, the network parameter is processed in blocks to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within the value range of the short integer data type;

[0098] The plurality of parameter blocks are stored by a short integer data type.

[0099] In some possible implementations, in terms of processing the network parameters of the first network layer and the input data of the first network layer using the target processing mode to obtain a data processing result, the above program is specifically used to execute instructions of the following steps:

[0100] Determining whether a current element in the input data is zero;

[0101] In response to the current element being 0, a portion of the data processing result corresponding to the current element is determined to be zero.

[0102] Figure 3A possible functional unit composition block diagram of a data processing device provided in an embodiment of the present application. The data processing device 300 includes: a determination unit 310, a processing unit 320, wherein:

[0103] A determination unit 310 is configured to determine a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data;

[0104] The processing unit 320 is used to process the network parameters of the first network layer and the input data of the first network layer using the target processing method to obtain a data processing result, wherein the input data of the first network layer is obtained based on the input image of the neural network.

[0105] In some possible implementations, before using the target processing method to process the network parameters of the first network layer and the input data of the first network layer, the processing unit 320 is further used to process the input image through multiple network layers of the neural network to obtain the input data of the first network layer.

[0106] In some possible implementations, the first network layer is a fully connected layer.

[0107] In some possible implementations, the at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

[0108] In some possible implementations, the multiple candidate processing methods include: a CSR-based processing method and a CSC-based processing method.

[0109] In some possible implementations, in terms of determining a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, the determination unit 310 is specifically configured to:

[0110] In response to the at least one second network layer including a ReLu layer, determining a CSC-based processing mode as a target processing mode; and / or

[0111] In response to the at least one second network layer including other activation layers except the ReLu layer, a CSR-based processing mode is determined as a target processing mode.

[0112] In some possible implementations, the processing unit 320 is further configured to store the network parameters based on the target processing mode.

[0113] In some possible implementations, the data processing device 300 further includes a block splitting unit 330, which, before processing the network parameters of the first network layer and the input data of the first network layer using the target processing method,

[0114] A block division unit 330 is configured to, in response to the dimension of the network parameter of the first network layer exceeding a preset dimension, perform block processing on the network parameter to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within a value range of a short integer data type;

[0115] The plurality of parameter blocks are stored by a short integer data type.

[0116] In some possible implementations, in terms of using the target processing mode to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, the processing unit 320 is specifically configured to:

[0117] Determining whether a current element in the input data is zero;

[0118] In response to the current element being 0, a portion of the data processing result corresponding to the current element is determined to be zero.

[0119] An embodiment of the present application also provides a computer storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement part or all of the steps of any one of the methods described in the above method embodiments.

[0120] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any one of the methods recorded in the above method embodiments.

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

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

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

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

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

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

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

[0128] 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 data processing method, characterized in that: include: Determining a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data; The multiple candidate processing methods include: a processing method based on compressed sparse rows (CSR) and a processing method based on compressed sparse columns (CSC); the first network layer is a fully connected layer; The layer type of at least one second network layer connected to the first network layer of the neural network, determining the target processing method from a plurality of preset candidate processing methods, includes: In response to the at least one second network layer including a linear rectifier (ReLu) layer, determining a CSC-based processing mode as a target processing mode; In response to the at least one second network layer including other activation layers except the ReLu layer, determining the CSR-based processing mode as the target processing mode; The target processing method is used to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, wherein the input data of the first network layer is obtained based on the input image of the neural network.

2. The method according to claim 1, characterized in that: Before processing the network parameters of the first network layer and the input data of the first network layer by using the target processing mode, the method further includes: The input image is processed through multiple network layers of the neural network to obtain input data of the first network layer.

3. The method according to claim 1 or 2, characterized in that: The at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

4. The method according to claim 1 or 2, characterized in that: The method further comprises: Based on the target processing mode, the network parameters are stored.

5. The method according to claim 1 or 2, characterized in that: Before processing the network parameters of the first network layer and the input data of the first network layer by using the target processing mode, the method further includes: In response to the dimension of the network parameter of the first network layer exceeding the preset dimension, the network parameter is processed in blocks to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within the value range of the short integer data type; The plurality of parameter blocks are stored by a short integer data type.

6. The method according to claim 1 or 2, characterized in that: The using the target processing mode to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result includes: Determining whether a current element in the input data is zero; In response to the current element being 0, a portion of the data processing result corresponding to the current element is determined to be zero.

7. A data processing device, characterized in that: include: a determining unit, configured to determine a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, wherein a network parameter of the first network layer is sparse data; The multiple candidate processing methods include: a processing method based on compressed sparse rows (CSR) and a processing method based on compressed sparse columns (CSC); the first network layer is a fully connected layer; In terms of determining a target processing method from a plurality of preset candidate processing methods based on a layer type of at least one second network layer connected to a first network layer of a neural network, the determining unit is specifically configured to: In response to the at least one second network layer including a linear rectifier (ReLu) layer, determining a CSC-based processing mode as a target processing mode; In response to the at least one second network layer including other activation layers except the ReLu layer, determining the CSR-based processing mode as the target processing mode; A processing unit is used to process the network parameters of the first network layer and the input data of the first network layer using the target processing method to obtain a data processing result, wherein the input data of the first network layer is obtained based on an input image of the neural network.

8. The device according to claim 7, characterized in that Before using the target processing method to process the network parameters of the first network layer and the input data of the first network layer, the processing unit is also used to process the input image through multiple network layers of the neural network to obtain the input data of the first network layer.

9. The device according to claim 7 or 8, characterized in that The at least one second network layer is the first N network layers of the first network layer, where N is less than a first value.

10. The device according to claim 7 or 8, characterized in that The processing unit is further configured to store the network parameters based on the target processing mode.

11. The device according to claim 7 or 8, characterized in that The data processing device further includes a block division unit, which, before processing the network parameters of the first network layer and the input data of the first network layer using the target processing mode, The blocking unit is configured to, in response to a dimension of the network parameter of the first network layer exceeding a preset dimension, block the network parameter to obtain a plurality of parameter blocks, wherein the dimension of each parameter block is within a value range of a short integer data type; The plurality of parameter blocks are stored by a short integer data type.

12. The device according to claim 7 or 8, characterized in that In terms of using the target processing mode to process the network parameters of the first network layer and the input data of the first network layer to obtain a data processing result, the processing unit is specifically used to: Determining whether a current element in the input data is zero; In response to the current element being 0, a portion of the data processing result corresponding to the current element is determined to be zero.

13. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in any one of the methods of claims 1-6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Neural network operation device and method

    CN109902815A

  • High-parallelism-degree computing platform and system and computing implementation method

    CN110321997A