Compression method and device, electronic equipment and computer readable medium
By grouping the convolution kernels in the deep convolution network, selecting the target sparse template and searching the target convolution kernel group, the deep convolution network is compressed, and the problem of how to compress the deep convolution network without reducing performance is solved, and efficient network compression is achieved.
Patent Information
- Application Number
- CN202311110389.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-02-28
AI Technical Summary
How to effectively compress a deep convolutional network to reduce its structural size while ensuring that the compressed network performance does not decrease.
By grouping the convolution kernels in the deep convolution network, selecting the target sparse template, and searching for the target convolution kernel group according to the preset compression constraints, and using the target sparse template to compress the network.
It realizes the compression processing of the deep convolutional network while maintaining data processing performance, avoids performance degradation caused by compression and improves the compression effect.
Smart Images

Figure CN119538987A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a compression method, device, electronic device, and computer-readable medium. Background Art
[0002] In some application scenarios, in order to avoid defects caused by the large structural size of the neural network, the neural network can be compressed so that the structural size of the compressed neural network is smaller than the structural size of the neural network before compression.
[0003] However, how to achieve compression processing is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The present application provides a compression method, device, electronic device, and computer-readable medium.
[0005] In order to achieve the above objectives, the technical solutions provided by this application are as follows:
[0006] The present application provides a compression method, the method comprising:
[0007] Grouping a number of convolution kernels in a deep convolutional network to obtain at least two convolution kernel groups;
[0008] Selecting a target sparse template corresponding to each convolution kernel group from a plurality of candidate sparse templates;
[0009] According to a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups, searching for a target convolution kernel group from the at least two convolution kernel groups; the preset compression constraint includes a convolution performance constraint;
[0010] The deep convolutional network is compressed using the target sparse template corresponding to the target convolution kernel group to obtain a compressed deep convolutional network; the performance characterization data of the compressed deep convolutional network satisfies the convolution performance constraint; the performance characterization data is determined based on sample data and the compressed deep convolutional network; the sample data includes at least one of image data, text data and voice data.
[0011] In one possible implementation, the deep convolutional network includes a plurality of convolution kernels arranged in sequence; for any of the convolution kernel groups, the convolution kernel group includes 16 convolution kernels that are arranged in adjacent positions in sequence.
[0012] In one possible implementation, the preset compression constraint also includes a sparse processing group number constraint; the number of the target convolution kernel groups satisfies the sparse processing group number constraint.
[0013] In one possible implementation, the convolution kernel includes at least two rows of weight parameters, and each row of weight parameters includes at least two weight parameters; the candidate sparse template is used to remove the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel.
[0014] In a possible implementation manner, the number of the candidate sparse templates is determined according to the number of weight parameter rows of the convolution kernel.
[0015] In a possible implementation, the convolution kernel includes 3 rows of weight parameters, each row of weight parameters includes 3 weight parameters; and the plurality of candidate sparse templates include 8 candidate sparse templates.
[0016] In one possible implementation, the at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; if each convolution kernel in the mth convolution kernel group belongs to a first type of convolution kernel, then the target sparse template corresponding to the mth convolution kernel group is selected from several candidate sparse templates corresponding to the first type of convolution kernel; m is a positive integer, m≤M.
[0017] In a possible implementation manner, the plurality of candidate sparse templates corresponding to the first type of convolution kernels include K candidate sparse templates, where K is a positive integer;
[0018] The process of determining the target sparse template corresponding to the mth convolution kernel group includes: determining the usage impact characterization data corresponding to the kth candidate sparse template based on the mth convolution kernel group and the kth candidate sparse template corresponding to the first type of convolution kernel, where k is a positive integer, k≤K; and searching for a candidate sparse template that meets a preset impact condition from the K candidate sparse templates based on the usage impact characterization data corresponding to the K candidate sparse templates as the target sparse template corresponding to the mth convolution kernel group.
[0019] In one possible implementation, the process of determining the usage impact characterization data corresponding to the kth candidate sparse template includes: determining the parameter impact characterization data corresponding to the kth candidate sparse template based on the weight parameters of each convolution kernel in the mth convolution kernel group and the kth candidate sparse template; determining the performance impact characterization data corresponding to the kth candidate sparse template based on the sample data, the mth convolution kernel group and the kth candidate sparse template; determining the usage impact characterization data corresponding to the kth candidate sparse template based on the parameter impact characterization data corresponding to the kth candidate sparse template and the performance impact characterization data corresponding to the kth candidate sparse template.
[0020] In a possible implementation manner, the mth convolution kernel group includes G convolution kernels, where G is a positive integer;
[0021] The process of determining the target sparse template corresponding to the m-th convolution kernel group includes: determining the target sparse template corresponding to the g-th convolution kernel based on the g-th convolution kernel in the m-th convolution kernel group and several candidate sparse templates corresponding to the first type of convolution kernel, where g is a positive integer, g≤G; performing statistical analysis on the target sparse templates corresponding to the G convolution kernels to obtain statistical analysis results; and determining the target sparse template corresponding to the m-th convolution kernel group based on the statistical analysis results.
[0022] In one possible implementation, the at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; if there are at least two types of convolution kernels in the mth convolution kernel group, the target sparse template corresponding to the mth convolution kernel group includes the target sparse template corresponding to each convolution kernel in the mth convolution kernel group, where m is a positive integer, m≤M.
[0023] In one possible implementation, the m-th convolution kernel group includes G convolution kernels, where G is a positive integer; the g-th convolution kernel in the m-th convolution kernel group belongs to the second type of convolution kernel, and the target sparse template corresponding to the g-th convolution kernel is selected from several candidate sparse templates corresponding to the second type of convolution kernel, g is a positive integer, g≤G.
[0024] In one possible implementation, the search process for the target convolution kernel group includes: constructing a search space based on the deep convolution network and the target sparse templates corresponding to the at least two convolution kernel groups, the search space including at least two candidate compression networks, the candidate compression networks being obtained by compressing the deep convolution network based on the target sparse templates corresponding to one or more convolution kernel groups; searching for a target compression network that satisfies the preset compression constraints from the search space; and determining the target convolution kernel group based on the target compression network.
[0025] In a possible implementation manner, the preset compression constraint further includes a sparse processing group number constraint;
[0026] The constructing of the search space according to the deep convolutional network and the target sparse templates corresponding to the at least two convolutional kernel groups includes: constructing the search space according to the sparse processing group number constraint, the deep convolutional network and the target sparse templates corresponding to the at least two convolutional kernel groups, so that each candidate compression network in the search space satisfies the sparse processing group number constraint;
[0027] The searching for a target compression network satisfying the preset compression constraint from the search space includes: searching for a target compression network satisfying the convolution performance constraint from the search space.
[0028] In a possible implementation manner, before grouping the plurality of convolution kernels in the deep convolutional network, the method further includes:
[0029] Acquire a model to be compressed, wherein the model to be compressed includes the deep convolutional network;
[0030] The method of compressing the deep convolutional network using the target sparse template corresponding to the target convolutional kernel group to obtain a compressed deep convolutional network includes: compressing the deep convolutional network in the model to be compressed using the target sparse template corresponding to the target convolutional kernel group to obtain a compressed model, wherein the compressed model includes the compressed deep convolutional network.
[0031] In a possible implementation, the model to be compressed includes at least one of an image processing module, a text processing module, and a speech processing module.
[0032] The present application provides a compression device, comprising:
[0033] A grouping unit, used for grouping a plurality of convolution kernels in the deep convolution network to obtain at least two convolution kernel groups;
[0034] A selection unit, used for selecting a target sparse template corresponding to each convolution kernel group from a plurality of candidate sparse templates;
[0035] A searching unit, configured to search for a target convolution kernel group from the at least two convolution kernel groups according to a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups; the preset compression constraint includes a convolution performance constraint;
[0036] A compression unit is used to compress the deep convolutional network using the target sparse template corresponding to the target convolution kernel group to obtain a compressed deep convolutional network; the performance characterization data of the compressed deep convolutional network meets the convolution performance constraint; the performance characterization data is determined based on sample data and the compressed deep convolutional network; the sample data includes at least one of image data, text data and voice data.
[0037] The present application provides an electronic device, the device comprising: a processor and a memory;
[0038] The memory is used to store instructions or computer programs;
[0039] The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the compression method provided in the present application.
[0040] The present application provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes the compression method provided by the present application.
[0041] The present application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program codes for executing the compression method provided by the present application.
[0042] Compared with the prior art, this application has at least the following advantages:
[0043] The compression scheme for deep convolutional networks provided in the present application includes: first grouping a number of convolutional kernels in the deep convolutional network to obtain at least two convolutional kernel groups; then selecting a target sparse template corresponding to each convolutional kernel group from a number of candidate sparse templates; then, based on a preset compression constraint and the target sparse template corresponding to the at least two convolutional kernel groups, searching for a target convolutional kernel group from the at least two convolutional kernel groups, so that the compressed deep convolutional network obtained by compressing the deep convolutional network using the target sparse template corresponding to the target convolutional kernel group meets the preset compression constraint, thereby achieving the purpose of compression processing according to compression requirements. Among them, because the preset compression constraint includes a convolution performance constraint, so that the performance characterization data of the compressed deep convolutional network meets the convolution performance constraint, it is possible to achieve network compression processing under the premise of ensuring data processing performance, thereby effectively avoiding the defect of a large decrease in data processing performance caused by related compression schemes, and thus helping to improve the compression effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0045] Figure 1 A flowchart of a compression method provided in an embodiment of the present application;
[0046] Figure 2 A schematic diagram of a grouping method provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of several candidate sparse templates provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of a compression device provided in an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only 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.
[0051] In order to better understand the technical solution provided by the present application, the compression method provided by the present application is described below with reference to some drawings. Figure 1 As shown, the compression method provided in the embodiment of the present application includes the following S1-S4. Figure 1 A flowchart of a compression method provided in an embodiment of the present application.
[0052] S1: Group several convolution kernels in the deep convolutional network to obtain at least two convolution kernel groups.
[0053] Among them, the depthwise convolutional network includes at least two convolutional kernels arranged in sequence, and the depthwise convolutional network is used to implement a certain data processing task (for example, at least one image processing task, at least one speech processing task, at least one text processing task, etc.). It can be seen that in a possible implementation, the depthwise convolutional network may include N convolutional kernels, N is a positive integer, N≥2.
[0054] In addition, the present application is not limited to the above-mentioned deep convolutional network. For example, it can be implemented using any existing or future Depthwise convolution.
[0055] In addition, the present application does not limit the implementation method of the above convolution kernel. For example, in some application scenarios, the convolution kernel may include at least two rows of weight parameters, and each row of weight parameters includes at least two weight parameters. It can be seen that in one possible implementation, the convolution kernel may include R×C weight parameters, R represents the number of rows in the convolution kernel, R is a positive integer, C represents the number of columns in the convolution kernel, C is a positive integer, and the present application does not limit the relative size between R and C. For example, in some application scenarios, R can be equal to C. Based on this, it can be seen that in some application scenarios, the above convolution kernel may include 3×3 weight parameters, 4×4 weight parameters, ... (and so on).
[0056] In addition, the present application does not limit the implementation method of the convolution kernel in the above deep convolutional network. For ease of understanding, some situations are explained below.
[0057] Case 1: In some application scenarios, all convolution kernels in the above deep convolutional network belong to the same type of convolution kernels.
[0058] Based on the above situation 1, it can be known that in a possible implementation, the above deep convolutional network may include N convolution kernels; and each convolution kernel belongs to the same type of convolution kernel (for example, a convolution kernel including 3×3 weight parameters, etc.), so that the size of all convolution kernels in the deep convolutional network is the same. For example, in some application scenarios, the deep convolutional network may include N convolution kernels, and the nth convolution kernel may include 3×3 weight parameters, where n is a positive integer, n≤N.
[0059] Case 2: In some application scenarios, in order to better meet certain data processing requirements, there are multiple types of convolution kernels in the above deep convolutional network.
[0060] Based on the above situation 2, it can be known that in another possible implementation, there are multiple types of convolution kernels in the above deep convolutional network, and for any pair of adjacent convolution kernels in the deep convolutional network, the two convolution kernels can belong to the same type of convolution kernels or to different types of convolution kernels. This application does not make any specific limitations on this.
[0061] After research, it was found that when adjacent convolution kernels belong to the same type of convolution kernels, it is more friendly to the processing performance of some data processors (for example, the number of computational accesses and cache of the processor, etc.). Therefore, the present application also provides a possible implementation of the above-mentioned deep convolution network. Under this implementation, when the above-mentioned deep convolution network may include N convolution kernels, and N=M×G, M is a positive integer, G is a positive integer, and G represents the number of convolution kernels in the convolution kernel group below, the 1st to Gth convolution kernels in the deep convolution network belong to the 1st type of convolution kernel (for example, a convolution kernel including 3×3 weight parameters, etc.), the G+1th to 2Gth convolution kernels belong to the 2nd type of convolution kernel (for example, a convolution kernel including 4×4 weight parameters, etc.), ... (and so on), and the (M-1)×G+1th to M×Gth convolution kernels belong to the Mth type of convolution kernel.
[0062] The above "at least two convolution kernel groups" are obtained by dividing all the convolution kernels in the above deep convolution network so that each convolution kernel group includes at least one convolution kernel. It can be seen that in one possible implementation, the "at least two convolution kernel groups" may include M convolution kernel groups, and the mth convolution kernel group includes at least one convolution kernel, where m is a positive integer and m≤M.
[0063] In fact, in order to better improve the compression efficiency, it is possible to ensure that the number of convolution kernels in each convolution kernel group is the same, so that it can be accelerated later with the help of certain characteristics of the processor (for example, ARM-CPU pipeline characteristics). Based on this, the present application also provides a possible implementation of the above "at least two convolution kernel groups", under which the number of convolution kernels included in each convolution kernel group in the "at least two convolution kernel groups" is the same. For example, when the "at least two convolution kernel groups" include M convolution kernel groups, the mth convolution kernel group includes G convolution kernels, G is a positive integer, G represents the number of convolution kernels included in any convolution kernel group, m is a positive integer, m≤M.
[0064] In addition, the present application does not limit the implementation method of G in the above paragraph. For example, it has been found through research that in some application scenarios, in order to better improve the compression efficiency, G can be 16.
[0065] Based on the above content, it can be known that in a possible implementation mode, when the above deep convolutional network includes a plurality of convolutional kernels arranged in sequence, the above S1 can specifically be: grouping the plurality of convolutional kernels in the deep convolutional network (for example, Figure 2 ), and at least two convolution kernel groups are obtained, so that each convolution kernel group includes 16 convolution kernels arranged in adjacent positions in sequence. It can be seen that in one possible implementation, when the above deep convolution network can include N convolution kernels, and N=M×G, M is a positive integer, and G is a positive integer, the "at least two convolution kernel groups" may include M convolution kernel groups, the first convolution kernel group includes the 1st to the Gth convolution kernels in the deep convolution network, the second convolution kernel group includes the G+1th to the 2Gth convolution kernels in the deep convolution network, ... (and so on), and the Mth convolution kernel group includes the (M-1)×G+1th to the M×Gth convolution kernels in the deep convolution network.
[0066] Based on the relevant content of the deep convolutional network above, it can be known that in one possible implementation, when the deep convolutional network may include N convolution kernels arranged in sequence, these N convolution kernels can be divided and processed to obtain M convolution kernel groups, so that each convolution kernel group includes G convolution kernels that are adjacent to each other in sequence, so that the convolution kernel group can be used as a whole to decide whether to compress it, which is more friendly to the processing performance of the processor (for example, the number of calculation memory accesses of the processor, etc.).
[0067] In addition, the present application does not limit the implementation method of the above-mentioned deep convolutional network. For example, in some application scenarios, the deep convolutional network refers to a network used to implement a certain data processing function (for example, image processing function, speech processing function, text processing function); and the deep convolutional network is a pre-trained network.
[0068] For example, in other application scenarios, the above-mentioned deep convolutional network refers to a network layer existing in a model to be compressed and used to implement deep convolution. Among them, the model to be compressed refers to a data processing model that needs to be compressed, so that the model to be compressed is used to perform some data processing (for example, some image processing, some voice processing or some text processing) on the input data of the model to be compressed. In addition, the present application does not limit the model to be compressed. For example, it may include at least one of an image processing module, a voice processing module and a text processing module, so that the model to be compressed can be used to implement at least one image processing function (for example, face recognition function, target detection function, etc.), at least one voice processing function (for example, voice recognition function, voice translation function, etc.), and at least one text processing function (for example, text translation function, etc.) One or more. In addition, in some application scenarios, the model to be compressed may refer to a pre-trained data processing model.
[0069] Based on the content of the previous paragraph, it can be known that, under a possible implementation mode, the determination process of the above "at least two convolution kernel groups" can be specifically as follows: first obtain the model to be compressed (for example, pre-train a data processing model to obtain the model to be compressed, etc.), the model to be compressed includes a deep convolutional network, and the deep convolutional network includes a number of convolution kernels arranged in sequence; then group the several convolution kernels in the deep convolutional network to obtain at least two convolution kernel groups, so that each convolution kernel group includes at least two convolution kernels (for example, 16 convolution kernels) whose arrangement positions are adjacent to each other in sequence, so that the convolution kernel group can be used as a whole to decide whether to compress it, which is more friendly to the processing performance of the processor (for example, the number of computational accesses and cache of the processor).
[0070] Based on the relevant content of S1 above, it can be known that for a deep convolutional network that needs to be compressed (for example, the deep convolutional network layer existing in the above compressed model, etc.), all convolution kernels in the deep convolutional network can be divided into at least two convolution kernel groups, so that it can be decided from these convolution kernel groups which group of convolution kernels needs to be compressed and which group does not need to be compressed.
[0071] S2: Select the target sparse template corresponding to each convolution kernel group from several candidate sparse templates.
[0072] Among them, several candidate sparse templates are used to remove some weight parameters in the convolution kernel according to certain rules, so that the regular removal of weight parameters can be realized with the help of these candidate sparse templates. This can effectively avoid the defects caused by irregular removal of weight parameters, which is conducive to improving the compression effect.
[0073] It can be seen that, in a possible implementation, the above several candidate sparse templates may include K candidate sparse templates. Among them, the kth candidate sparse template is used to indicate which weight parameters in the convolution kernel are to be removed; and the present application does not limit the kth candidate sparse template, for example, it can be used Figure 3 Any template shown in the figure is used for implementation. k is a positive integer, k≤K, and K is a positive integer.
[0074] Research has found that for any convolution kernel in a deep convolutional network, the value of the weight parameters at the edge position in each row of weight parameters of the convolution kernel is lower than the value of the weight parameters at the non-edge position.
[0075] Based on the findings in the previous paragraph, the present application also provides a possible implementation of the kth candidate sparse template above. In this implementation, when the convolution kernel present in the above deep convolutional network includes at least two rows of weight parameters (for example, R rows of weight parameters), and each row of weight parameters includes at least two weight parameters (for example, C weight parameters), the kth candidate sparse template can be used to remove the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel.
[0076] Based on the above content, in a possible implementation, the above candidate sparse templates (for example, Figure 3 Templates 1 to 8 shown in the figure) are constructed so that each candidate sparse template can be used to remove the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel. In this way, these candidate sparse templates can be used to achieve regular compression processing while ensuring that the performance of the convolution kernel is not reduced as much as possible. This can effectively avoid the defects caused by irregular compression of the weight parameters, thereby helping to improve the compression effect.
[0077] In fact, in order to better improve the compression effect, the above-mentioned candidate sparse templates can refer to all templates that meet the principle of "removing the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel". Based on this, it can be seen that the number of candidate sparse templates in the "several candidate sparse templates" can be determined according to the number of rows of weight parameters of the convolution kernel; and the determination process can be implemented using the following formula (1).
[0078]
[0079] In the formula, Filter number represents the number of candidate sparse templates in the above “several candidate sparse templates”; R represents the number of weight parameter rows of the convolution kernel that can use any template in the “several candidate sparse templates” for sparse processing, and the size of the convolution kernel is the same as the size of any candidate sparse template in the “several candidate sparse templates”; Indicates the number of possible situations when choosing from the beginning or the end of a line.
[0080] Based on the relevant content of the above formula (1), it can be known that when the convolution kernel for sparse processing using a template in the "several candidate sparse templates" includes 3 rows of weight parameters, each row of weight parameters includes 3 weight parameters, that is, when the convolution kernel includes 3×3 weight parameters, the "several candidate sparse templates" can include 2 3 = 8 candidate sparse templates (i.e., Figure 3 Templates 1 to 8 shown in the figure) so that the number of candidate sparse templates in the “several candidate sparse templates” is 8.
[0081] Based on the above “several candidate sparse templates”, it can be known that for a convolution kernel including 3×3 weight parameters, the “several candidate sparse templates” may include Figure 3 The eight templates shown are templates 1 to 8. Among them, since each candidate sparse template in the "several candidate sparse templates" is used to remove the weight parameters at the beginning or end of each row of weight parameters of the convolution kernel, the candidate sparse template is used to delete 3 weight parameters from the 9 weight parameters of the convolution kernel and retain 6 weight parameters, and the deleted 3 weight parameters belong to the beginning or end of each row in the convolution kernel, so that Figure 3 The eight templates shown, template 1 to template 8, implement regular compression processing for a convolution kernel including 3×3 weight parameters, thereby facilitating improved compression effects.
[0082] The target sparse template corresponding to the mth convolution kernel group refers to a candidate sparse template selected for the mth convolution kernel group and suitable for performing sparse processing on the convolution kernels in the mth convolution kernel group. Wherein, m is a positive integer, m≤M.
[0083] In addition, the present application does not limit the process of determining the target sparse template corresponding to the mth convolution kernel group mentioned above. For ease of understanding, some situations are described below.
[0084] Case 1: In some application scenarios, for the mth convolution kernel group above, all the convolution kernels in the mth convolution kernel group may belong to the same type of convolution kernel, so that all the convolution kernels in the mth convolution kernel group have the same size, so that each convolution kernel in the mth convolution kernel group can use the same set of "several candidate sparse templates" for template selection processing.
[0085] Based on the relevant content of the above situation 1, it can be known that in a possible implementation, when each convolution kernel in the mth convolution kernel group above belongs to the first type of convolution kernel (for example, a convolution kernel including 3×3 weight parameters, etc.), the target sparse template corresponding to the mth convolution kernel group can include only one template, so that each convolution kernel in the mth convolution kernel group can be sparsely processed with the help of the same template; and the target sparse template corresponding to the mth convolution kernel group can be selected from several candidate sparse templates corresponding to the first type of convolution kernel. Among them, the first type of convolution kernel is used to represent the type of all convolution kernels in the mth convolution kernel group; and the present application does not limit the first type of convolution kernel.
[0086] The candidate sparse templates corresponding to the first type of convolution kernel in the above text refer to all templates that are pre-set for the first type of convolution kernel and meet the principle of "removing the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel". It can be seen that when the first type of convolution kernel is used to represent a convolution kernel including 3×3 weight parameters, the candidate sparse templates corresponding to the first type of convolution kernel may include Figure 3 Templates 1 to 8 are shown.
[0087] In addition, the present application does not limit the determination process of the "target sparse template corresponding to the mth convolution kernel group" in the above paragraph. For ease of understanding, two possible implementation methods are described below.
[0088] In one possible implementation, when each convolution kernel in the mth convolution kernel group above belongs to the first type of convolution kernel, and the several candidate sparse templates corresponding to the first type of convolution kernel include K candidate sparse templates, the determination process of the above "target sparse template corresponding to the mth convolution kernel group" can specifically include the following steps 11-12.
[0089] Step 11: Based on the mth convolution kernel group and the kth candidate sparse template corresponding to the first type of convolution kernel above, determine the usage impact characterization data corresponding to the kth candidate sparse template, so that the usage impact characterization data is used to characterize the impact of using the kth candidate sparse template to perform sparse processing on the convolution kernels in the mth convolution kernel group, k is a positive integer, k≤K.
[0090] It should be noted that the present application does not limit the implementation method of the above step 11. For example, it may specifically include the following steps 111-112.
[0091] Step 111: Based on the weight parameters of each convolution kernel in the mth convolution kernel group and the kth candidate sparse template, determine the parameter influence characterization data corresponding to the kth candidate sparse template, so that the parameter influence characterization data is used to represent the influence on the weight parameters when the convolution kernels in the mth convolution kernel group are sparsely processed using the kth candidate sparse template.
[0092] It should be noted that the present application does not limit the calculation process of the parameters corresponding to the kth candidate sparse template to affect the characterization data. For example, it can be implemented using the following formula (2).
[0093] In the formula, f k→m Indicates the above “the parameters corresponding to the kth candidate sparse template affect the representation data”; G indicates the number of convolution kernels in the mth convolution kernel group above; g num Cov represents the number of weight parameters included in the gth convolution kernel in the mth convolution kernel group above, g is a positive integer, g≤G, G is a positive integer; g (j) represents the jth weight parameter in the gth convolution kernel; Norm(Cov g (j)) represents the normalized value of the jth weight parameter in the gth convolution kernel (for example, the L1 norm normalized value or the L2 norm normalized value); p(j) represents the jth value in the kth candidate sparse template, so that p(j) is used to indicate whether to remove the jth weight parameter, and the present application does not limit the implementation method of p(j). If p(j) = 1, it means that the jth weight parameter needs to be retained, and if p(j) = 0, it means that the jth weight parameter needs to be removed; j is a positive integer, j≤g num .
[0094] Based on the relevant content of step 111 above, it can be known that in some application scenarios, the parameter influence characterization data corresponding to the kth candidate sparse template can be calculated based on the weight parameters of the kth candidate sparse template and each convolution kernel in the mth convolution kernel group above, so that the parameter influence characterization data can represent the influence on the weight parameters when the kth candidate sparse template is used to perform sparse processing on the convolution kernels in the mth convolution kernel group.
[0095] Step 112: Determine usage impact characterization data corresponding to the kth candidate sparse template according to the parameter impact characterization data corresponding to the kth candidate sparse template.
[0096] It should be noted that the present application does not limit the implementation method of the above step 112. For example, it can specifically be: the parameter impact characterization data corresponding to the above k-th candidate sparse template is determined as the usage impact characterization data corresponding to the k-th candidate sparse template, so that the usage impact characterization data is used to characterize the impact caused when the k-th candidate sparse template is used to perform sparse processing on the convolution kernels in the m-th convolution kernel group.
[0097] Based on the relevant contents of steps 111 to 112 above, it can be known that in some application scenarios, by analyzing the influence of a candidate sparse template on the weight parameters of the convolution kernel in a convolution kernel group, the influence of sparse processing of the convolution kernel group according to the candidate sparse template can be determined, which is conducive to improving analysis efficiency and thus compression efficiency.
[0098] In fact, in order to better improve the compression effect, the impact analysis can be comprehensively performed in multiple aspects. Based on this, the present application also provides another possible implementation of the above step 11, in which the step 11 can specifically include the following steps 113 to 115.
[0099] Step 113: Based on the weight parameters of each convolution kernel in the mth convolution kernel group and the kth candidate sparse template, determine the parameter influence characterization data corresponding to the kth candidate sparse template, so that the parameter influence characterization data is used to represent the influence on the weight parameters when the convolution kernels in the mth convolution kernel group are sparsely processed using the kth candidate sparse template.
[0100] It should be noted that for the relevant content of step 113, please refer to the above step 111.
[0101] Step 114: Determine the performance impact characterization data corresponding to the kth candidate sparse template based on the sample data, the mth convolution kernel group and the kth candidate sparse template.
[0102] Herein, sample data refers to the data required to measure the data processing performance of a network (or model); and this application does not limit the sample data. For example, the sample data may include at least one of image data, text data and voice data.
[0103] It can be seen that in some application scenarios, for objects that need to use sample data to determine data processing performance (for example, the deep convolutional network mentioned above, the model to be compressed mentioned above, the network after sparse processing mentioned below, the deep convolutional network after compression mentioned below, or the model after compression mentioned below, etc.), if the object is used to implement at least one image processing function, then the sample data may include image data; if the object is used to implement at least one voice processing function, then the sample data may include voice data; if the object is used to implement at least one text processing function, then the sample data may include text data.
[0104] The performance impact characterization data corresponding to the kth candidate sparse template represents the impact on data processing performance when the kth candidate sparse template is used to perform sparse processing on the convolution kernels in the mth convolution kernel group.
[0105] In addition, the present application does not limit the implementation method of the above step 114. For example, it can be specifically as follows: first use the above k-th candidate sparse template to perform sparse processing on the m-th convolution kernel group in the above deep convolution network to obtain a sparsely processed network; then, based on the above sample data, perform performance determination processing on the sparsely processed network to obtain performance characterization data of the sparsely processed network; then, based on the performance characterization data, determine the performance impact characterization data corresponding to the k-th candidate sparse template (for example, directly determine the performance characterization data as the performance impact characterization data corresponding to the k-th candidate sparse template), so that the performance impact characterization data corresponding to the k-th candidate sparse template can represent the impact on data processing performance when the k-th candidate sparse template is used to perform sparse processing on the convolution kernels in the m-th convolution kernel group.
[0106] It should be noted that the present application does not limit the implementation method of the determination process of the "performance characterization data of the network after sparse processing" in the previous paragraph. For example, in some application scenarios, it can specifically be: directly using the sparse processed network to process the sample data to obtain the data processing results corresponding to the sample data (for example, predicted image processing results, predicted speech processing results, predicted text processing results, etc.); and then determining the data processing performance of the sparse processed network based on the data processing results.
[0107] For example, in order to better improve the performance determination effect, the present application also provides a possible implementation method of the determination process of the above "performance characterization data of the sparsely processed network", which can be specifically: first use the sample data to train the sparsely processed network; then use the sample data to calculate the data processing performance characterization data (for example, prediction loss, etc.) of the trained sparsely processed network as the performance characterization data of the sparsely processed network.
[0108] Based on the relevant content of step 114 above, it can be known that in some application scenarios, the performance impact characterization data corresponding to the kth candidate sparse template can be determined based on the sample data, the mth convolution kernel group above, and the kth candidate sparse template above, so that the performance impact characterization data corresponding to the kth candidate sparse template can better represent the impact on data processing performance when the kth candidate sparse template is used to perform sparse processing on the convolution kernels in the mth convolution kernel group.
[0109] Step 115: Determine usage impact characterization data corresponding to the kth candidate sparse template according to the parameter impact characterization data corresponding to the kth candidate sparse template and the performance impact characterization data corresponding to the kth candidate sparse template.
[0110] It should be noted that the present application does not limit the implementation method of step 115 above. For example, it can be specifically: weighted summing the parameter impact characterization data corresponding to the kth candidate sparse template above and the performance impact characterization data corresponding to the kth candidate sparse template to obtain the usage impact characterization data corresponding to the kth candidate sparse template.
[0111] Based on the relevant contents of steps 113 to 115 above, it can be known that in some application scenarios, by analyzing the comprehensive effects of a candidate sparse template on the convolution kernels in a convolution kernel group, the influence of sparse processing of the convolution kernel group according to the candidate sparse template can be determined. This is conducive to improving the accuracy of the analysis and thus is conducive to achieving compression processing while ensuring the least possible performance loss.
[0112] Based on the relevant content of step 11 above, it can be known that the kth candidate sparse template corresponding to the first type of convolution kernel above and all the convolution kernels in the mth convolution kernel group above can be used to analyze the usage impact characterization data corresponding to the kth candidate sparse template, so that the usage impact characterization data can characterize the impact of using the kth candidate sparse template to perform sparse processing on the convolution kernels in the mth convolution kernel group, so that it can be decided based on the usage impact characterization data whether to use the kth candidate sparse template to perform sparse processing on the convolution kernels in the mth convolution kernel group, where k is a positive integer, k≤K.
[0113] Step 12: Based on the usage impact characterization data corresponding to the above K candidate sparse templates, search for a candidate sparse template that meets the preset impact condition from the K candidate sparse templates as the target sparse template corresponding to the mth convolution kernel group.
[0114] Among them, the preset influencing condition is used to screen out the most suitable candidate sparse template for a convolution kernel group; and the present application does not limit the preset influencing condition, for example, it can be specifically: the usage impact characterization data corresponding to the target sparse template is used to indicate that the impact generated when the target sparse template is used to perform sparse processing on the convolution kernel in the mth convolution kernel group is minimized.
[0115] In addition, the implementation method of step 12 above in the present application can be implemented, for example, by means of a sorting or size comparison method.
[0116] Based on the relevant content of steps 11 to 12 above, it can be known that in some application scenarios, for the mth convolution kernel group above, we can first analyze the impact of using each candidate sparse template to perform sparse processing on the convolution kernels in the mth convolution kernel group; then select the candidate sparse template with the least impact as the target sparse template corresponding to the mth convolution kernel group, which is conducive to achieving compression processing while ensuring the least performance loss.
[0117] In a possible implementation, when the m-th convolution kernel group above includes G convolution kernels, the determination process of the "target sparse template corresponding to the m-th convolution kernel group" above may specifically include the following steps 13-15.
[0118] Step 13: According to the g-th convolution kernel in the m-th convolution kernel group and several candidate sparse templates corresponding to the first type of convolution kernels mentioned above, determine the target sparse template corresponding to the g-th convolution kernel, where g is a positive integer, g≤G.
[0119] Among them, the target sparse template corresponding to the g-th convolution kernel refers to the candidate sparse template selected for the g-th convolution kernel in the m-th convolution kernel group above and suitable for performing sparse processing on the g-th convolution kernel.
[0120] In addition, the present application does not limit the process of determining the target sparse template corresponding to the g-th convolution kernel above. For example, it may include the following steps 131-132.
[0121] Step 131: According to the g-th convolution kernel and the k-th candidate sparse template corresponding to the first type of convolution kernel, determine the usage impact characterization data corresponding to the k-th candidate sparse template under the g-th convolution kernel, so that the usage impact characterization data is used to characterize the impact of using the k-th candidate sparse template to perform sparse processing on the g-th convolution kernel. Wherein, k is a positive integer, k≤K.
[0122] It should be noted that the process of determining "the usage impact characterization data corresponding to the kth candidate sparse template under the gth convolution kernel" in step 131 is similar to the process of determining the usage impact characterization data shown in step 11 above. For the sake of brevity, it will not be repeated here.
[0123] Step 132: Based on the usage impact characterization data corresponding to the above K candidate sparse templates under the g-th convolution kernel, search for a candidate sparse template that meets the preset impact condition from the K candidate sparse templates as the target sparse template corresponding to the g-th convolution kernel.
[0124] It should be noted that the implementation of step 132 is similar to the implementation of step 12 above, and for the sake of brevity, it will not be repeated here.
[0125] Based on the relevant contents of steps 131 to 132 above, it can be known that for the g-th convolution kernel in the m-th convolution kernel group above, we can first analyze the impact of using each candidate sparse template to perform sparse processing on the g-th convolution kernel; then select the candidate sparse template with the least impact as the target sparse template corresponding to the g-th convolution kernel, which is conducive to achieving compression processing while ensuring the least possible performance loss.
[0126] Based on the relevant content of step 13 above, it can be known that for the mth convolution kernel group above, the target sparse templates corresponding to each convolution kernel in the mth convolution kernel group can be analyzed separately from the several candidate sparse templates corresponding to the first type of convolution kernel above, so that the target sparse template corresponding to the mth convolution kernel group can be determined based on these target sparse templates.
[0127] Step 14: Perform statistical analysis on the target sparse templates corresponding to the G convolution kernels in the m-th convolution kernel group above to obtain the statistical analysis results corresponding to the m-th convolution kernel group.
[0128] Among them, the statistical analysis results corresponding to the m-th convolution kernel group are used to represent the distribution state of the target sparse template corresponding to the G convolution kernels in the m-th convolution kernel group, so that the statistical analysis results can represent the trend of these convolution kernels in template selection.
[0129] In addition, the present application does not limit the implementation method of the statistical analysis results corresponding to the mth convolution kernel group above. For example, it may specifically include the frequency of occurrence of each template in the above several candidate sparse templates (that is, the selection frequency of all convolution kernels in the mth convolution kernel group for each template in the above several candidate sparse templates).
[0130] Step 15: According to the statistical analysis results corresponding to the m-th convolution kernel group above, determine the target sparse template corresponding to the m-th convolution kernel group.
[0131] It should be noted that the present application does not limit the implementation method of step 15. For example, when the statistical analysis results corresponding to the mth convolution kernel group are used to represent the selection frequency of all convolution kernels in the mth convolution kernel group for each of the above-mentioned several candidate sparse templates, the step 15 can specifically be: select the template with the largest frequency from the several candidate sparse templates, and determine it as the target sparse template corresponding to the mth convolution kernel group.
[0132] Based on the relevant content of steps 13 to 15 above, it can be known that in some application scenarios, for the mth convolution kernel group above, the target sparse template corresponding to each convolution kernel in the mth convolution kernel group can be first selected from the several candidate sparse templates corresponding to the first type of convolution kernel above; and then the target sparse template corresponding to the mth convolution kernel group can be determined based on the distribution of the target sparse templates corresponding to all the convolution kernels in the mth convolution kernel group.
[0133] Based on the relevant content of the above situation one, it can be known that in some application scenarios, if all the convolution kernels in the above m-th convolution kernel group belong to the same type of convolution kernel (for example, a convolution kernel including 3×3 weight parameters, etc.), then a template can be selected from the above several candidate sparse templates as the target sparse template corresponding to the m-th convolution kernel group, so that the target sparse template can represent the template that can be used by all convolution kernels in the m-th convolution kernel group, so that all convolution kernels in the m-th convolution kernel group can use the same template for sparse processing, which is more friendly to the processing performance of the processor (for example, the number of computational accesses and cache of the processor, etc.).
[0134] Case 2: In some application scenarios, for the mth convolution kernel group mentioned above, there may be multiple types of convolution kernels in the mth convolution kernel group, so that there are convolution kernels of multiple sizes in the mth convolution kernel group. Therefore, in order to ensure the compression effect, "several candidate sparse templates" of corresponding sizes can be used for template selection processing for different convolution kernels in the mth convolution kernel group.
[0135] Based on the relevant content of the second situation above, it can be known that in a possible implementation mode, when there are at least two types of convolution kernels in the mth convolution kernel group above, the target sparse template corresponding to the mth convolution kernel group may include the target sparse template corresponding to each convolution kernel in the mth convolution kernel group, where m is a positive integer, m≤M, so that when compression processing is subsequently performed on the mth convolution kernel group, each convolution kernel in the mth convolution kernel group can be sparsely processed according to the corresponding target sparse template.
[0136] It can be seen that in a possible implementation, when the mth convolution kernel group above includes G convolution kernels, the target sparse template corresponding to the mth convolution kernel group may include the target sparse template corresponding to the first convolution kernel in the mth convolution kernel group, the target sparse template corresponding to the second convolution kernel, ... (and so on), and the target sparse template corresponding to the Gth convolution kernel. Among them, the target sparse template corresponding to the gth convolution kernel refers to the candidate sparse template selected for the gth convolution and suitable for sparse processing for the gth convolution. Among them, g is a positive integer, g≤G.
[0137] In addition, the present application does not limit the determination process of the target sparse template corresponding to the g-th convolution kernel in the m-th convolution kernel group above. For example, when the g-th convolution kernel belongs to the second type of convolution kernel, the target sparse template corresponding to the g-th convolution kernel can be selected from several candidate sparse templates corresponding to the second type of convolution kernel, where g is a positive integer and g≤G. The second type of convolution kernel is used to indicate the type to which the g-th convolution kernel belongs.
[0138] It should be noted that the implementation method of "the process of determining the target sparse template corresponding to the g-th convolution kernel" in the above paragraph is similar to the implementation method of "the process of determining the target sparse template corresponding to the g-th convolution kernel" above. For the sake of brevity, it will not be repeated here.
[0139] Based on the relevant content of the above situation 2, it can be known that in some application scenarios, if there are multiple types of convolution kernels in the mth convolution kernel group above, in order to better improve the compression effect, a target sparse template corresponding to the size of each convolution kernel in the mth convolution kernel group can be determined respectively, so that when the mth convolution kernel group is subsequently compressed, the sparse processing of the corresponding convolution kernel can be realized according to the target sparse template corresponding to each convolution kernel in the mth convolution kernel group. This can effectively avoid the problems caused by inconsistent sizes, thereby helping to improve the compression effect.
[0140] Based on the relevant content of S2 above, it can be known that after at least two convolution kernel groups are divided from the above deep convolution network, a target sparse template corresponding to each convolution kernel group can be selected from several candidate sparse templates, so that the target sparse template can indicate which weight parameters in the corresponding convolution kernel group need to be removed, so that the compression processing of the deep convolution network can be completed with the help of these target sparse templates.
[0141] S3: Searching for a target convolution kernel group from the at least two convolution kernel groups based on a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups; the preset compression constraint includes a convolution performance constraint.
[0142] Among them, the preset compression constraint refers to the constraint that needs to be met when compressing the above-mentioned deep convolutional network, so that the preset compression constraint can characterize the compression requirements for the deep convolutional network (for example, processing performance requirements, etc.); and the preset compression constraint can be set in advance according to the actual application scenario.
[0143] In addition, for the above preset compression constraint, the preset compression constraint may at least include a convolution performance constraint, wherein the convolution performance constraint refers to a constraint that needs to be satisfied in terms of data processing performance when performing compression processing on the above deep convolutional network.
[0144] In addition, the present application does not limit the implementation method of the above convolution performance constraint. For example, it can be specifically: the performance characterization data of the deep convolutional network after compression is not lower than the preset performance threshold. The performance characterization data is used to characterize the data processing performance of the deep convolutional network after compression; and the performance characterization data can be determined based on the sample data and the deep convolutional network after compression.
[0145] It should be noted that this application does not limit the process of determining the "performance characterization data of the deep convolutional network after compression processing" in the previous paragraph. For example, the implementation method of the process of determining the "performance characterization data of the deep convolutional network after compression processing" is similar to the implementation method of the process of determining the "performance characterization data of the network after sparse processing" mentioned above. For the sake of brevity, it will not be repeated here.
[0146] In fact, in order to better meet the compression requirements, the present application also provides a possible implementation of the above preset compression constraint, under which the preset compression constraint not only includes the above convolution performance constraint, but also includes a sparse processing group number constraint. Among them, the sparse processing group number constraint refers to the constraint that needs to be satisfied in terms of the number of convolution kernel groups that are sparsely processed when the above deep convolution network is compressed; and the present application does not limit the implementation of the sparse processing group number constraint, for example, it can be specifically: the number of convolution kernel groups that need to be sparsely processed when compressing the deep convolution network does not exceed the preset number threshold (for example, 3).
[0147] The target convolution kernel group refers to the convolution kernel group that needs to be sparsely processed when compressing the above deep convolution network. It can be seen that when the above preset compression constraints include convolution performance constraints and sparse processing group number constraints, the number of the target convolution kernel group satisfies the sparse processing group number constraint, and the performance characterization data of the network obtained by compressing the corresponding target convolution kernel group in the deep convolution network according to the target sparse template corresponding to the target convolution kernel group satisfies the convolution performance constraint.
[0148] In addition, the present application does not limit the search process of the above target convolution kernel group. For example, it can be implemented by any existing or future method that can determine the target convolution kernel group from some convolution kernel groups based on the above preset compression constraints.
[0149] In fact, in order to better improve the search effect, the present application also provides a possible implementation method of the search process of the above target convolution kernel group, which may specifically include the following steps 21 to 23.
[0150] Step 21: Based on the above deep convolutional network and the target sparse templates corresponding to the above at least two convolutional kernel groups, a search space is constructed, where the search space includes at least two candidate compression networks, and the candidate compression networks are obtained by compressing the deep convolutional network according to the target sparse templates corresponding to one or more convolutional kernel groups.
[0151] Among them, the search space is used to provide compression results obtained by compressing the deep convolutional network based on different information (for example, target sparse templates corresponding to one or more or less two convolution kernel groups, etc.); and this application does not limit the implementation method of the search space.
[0152] In addition, for the above search space, the search space may include at least two candidate compression networks, and different candidate compression networks are obtained by compression based on different information. It can be seen that for the yth candidate compression network in the search space, the yth candidate compression network is obtained by compressing the deep convolutional network based on the yth information, so that the yth candidate compression network does not contain the weight parameters that need to be removed as described by the yth information; and the yth information includes one or more of the target sparse templates corresponding to the at least two convolution kernel groups above. y is a positive integer, y≤Y, Y is a positive integer, and Y represents the number of networks in the "at least two candidate compression networks".
[0153] In fact, in order to better improve the space construction efficiency while meeting the compression requirements, the present application also provides a possible implementation method of step 21 above. Under this implementation method, when the above preset compression constraint includes at least a sparse processing group number constraint, the step 21 can be specifically as follows: based on the sparse processing group number constraint, the above deep convolutional network and the target sparse templates corresponding to the above at least two convolution kernel groups, a search space is constructed so that each candidate compression network in the search space satisfies the sparse processing group number constraint, thereby eliminating the need to create networks that do not satisfy the sparse processing group number constraint when constructing the search space. This is beneficial to improving the construction efficiency of the search space, thereby improving the compression efficiency.
[0154] It can be seen that in some application scenarios, when the above-mentioned sparse processing group number constraint is used to indicate that the number of convolution kernel groups that need to be sparsely processed when compressing the above-mentioned deep convolution network does not exceed T, for any candidate compression network existing in the search space shown in the upper paragraph, if the candidate compression network is obtained by compressing the deep convolution network according to the target sparse template corresponding to the t convolution kernel groups, then t≤T, thus ensuring that the search space is only used to provide candidate compression networks that meet the sparse processing group number constraint.
[0155] Based on the relevant content of step 21 above, it can be known that for some application scenarios, after obtaining the target sparse templates corresponding to each convolution kernel group in the above deep convolutional network, a search space can be constructed based on these target sparse templates and the deep convolutional network, so that the search space is used to provide at least two candidate compression networks, so that it can be determined based on these candidate compression networks in the future that which information is used to compress the deep convolutional network to obtain a better compression result.
[0156] Step 22: Search the target compression network that satisfies the preset compression constraints from the above search space.
[0157] The target compression network refers to a candidate compression network that exists in the search space above and satisfies the preset compression constraint. It can be seen that when the preset compression constraint includes a convolution performance constraint and a sparse processing group number constraint, the target compression network may refer to a candidate compression network that exists in the search space, whose performance characterization data satisfies the convolution performance constraint, and whose number of sparsely processed convolution kernel groups satisfies the sparse processing group number constraint.
[0158] In addition, the present application does not limit the implementation method of the above step 22. For example, it can be implemented by using any existing or future spatial search method.
[0159] For example, when the above preset compression constraints include convolution performance constraints and sparse processing group number constraints, and the above search space is constructed based on the sparse processing group number constraints, in order to better improve the search efficiency, the above step 22 can be specifically: search for the target compression network that satisfies the convolution performance constraint from the search space, so that in the search process of the target compression network, it is only necessary to determine whether a candidate compression network satisfies the convolution performance constraint. This can effectively reduce the search time, thereby helping to improve the compression efficiency.
[0160] Based on the relevant content of step 22 above, it can be known that after constructing the search space, a target compression network that satisfies the preset compression constraints can be searched from the search space, so that the performance characterization data of the target compression network satisfies the convolution performance constraints existing in the preset compression constraints, and the number of convolution kernel groups that have been sparsely processed in the target compression network satisfies the sparse processing group number constraint existing in the preset compression constraints, so that the convolution kernel group that needs to be sparsely processed in the optimal compression scheme can be determined based on the target compression network in the future.
[0161] Step 23: Determine the target convolution kernel group based on the target compression network above.
[0162] It should be noted that the present application does not limit the implementation method of step 23 above. For example, it can be specifically as follows: after obtaining the above target compression network, the convolution kernel group that has been sparsely processed and exists in the target compression network can be regarded as the target convolution kernel group.
[0163] Based on the relevant content of steps 21 to 23 above, it can be known that for some application scenarios, after obtaining the target sparse templates corresponding to each convolution kernel group in the above deep convolution network, a search space can be constructed based on these target sparse templates and the deep convolution network, so that the search space can provide some compression results obtained by compressing the deep convolution network according to different information; then search for compression results that meet the preset compression constraints from the search space, and regard the compression results that meet the preset compression constraints as the optimal compression scheme; finally, determine the target convolution kernel group based on the optimal compression scheme, so that the target convolution kernel group can represent the convolution kernel group that needs to be sparsely processed in the optimal compression scheme, which is conducive to achieving compression processing while ensuring that performance loss is as little as possible.
[0164] Based on the relevant content of S3 above, it can be known that after obtaining the target sparse templates corresponding to at least two convolution kernel groups in the above deep convolution network, the target convolution kernel group can be searched from the at least two convolution kernel groups based on the above preset compression constraints and the target sparse templates corresponding to the at least two convolution kernel groups, so that the network obtained by compressing the deep convolution network using the target sparse template corresponding to the target convolution kernel group can meet the preset compression constraints, which is conducive to realizing compression processing while ensuring the least possible performance loss.
[0165] S4: Using the target sparse template corresponding to the target convolution kernel group, the deep convolution network is compressed to obtain a compressed deep convolution network; the performance characterization data of the compressed deep convolution network meets the convolution performance constraint; the performance characterization data is determined based on the sample data and the compressed deep convolution network; the sample data includes at least one of image data, text data and voice data.
[0166] Among them, the compressed deep convolutional network refers to the compression result obtained by compressing the above deep convolutional network using the target sparse template corresponding to the above target convolutional kernel group, so that the compressed deep convolutional network includes the sparse result obtained by sparse processing the target convolutional kernel group according to the target sparse template corresponding to the target convolutional kernel group, so that there are no weight parameters described by the target sparse template that need to be removed in the compressed deep convolutional network.
[0167] The above "performance characterization data of the compressed deep convolutional network" is used to characterize the data processing performance of the compressed deep convolutional network; and the determination process of the "performance characterization data of the compressed deep convolutional network" is similar to the implementation method of the determination process of the above "performance characterization data of the network after sparse processing". For the sake of brevity, it will not be repeated here.
[0168] In addition, the present application does not limit the implementation method of S4 above. For example, when the model to be compressed above includes the deep convolutional network above (for example, the deep convolutional network refers to the network layer in the model to be compressed, etc.), the S4 can specifically be: using the target sparse template corresponding to the target convolution kernel group above to compress the deep convolutional network in the model to be compressed to obtain a compressed model, so that the compressed model includes the compressed deep convolutional network above, so that the compressed model does not contain the weight parameters that need to be removed and are described by the target sparse template.
[0169] Based on the relevant contents of S1 to S4 above, it can be known that for the compression method provided in the embodiment of the present application, a number of convolution kernels in the deep convolution network are first grouped to obtain at least two convolution kernel groups; then, a target sparse template corresponding to each convolution kernel group is selected from a number of candidate sparse templates; then, based on the preset compression constraint and the target sparse template corresponding to the at least two convolution kernel groups, the target convolution kernel group is searched from the at least two convolution kernel groups, so that the compressed deep convolution network obtained by compressing the deep convolution network using the target sparse template corresponding to the target convolution kernel group meets the preset compression constraint, so as to achieve the purpose of compression processing according to the compression requirements. Among them, because the preset compression constraint includes a convolution performance constraint, so that the performance characterization data of the compressed deep convolution network meets the convolution performance constraint, so that the network compression processing can be achieved under the premise of ensuring data processing performance, thereby effectively avoiding the defects of a large decrease in data processing performance caused by related compression schemes, and thus helping to improve the compression effect.
[0170] In addition, the present application does not limit the execution subject of the above compression method. For example, any implementation of the compression method provided in the embodiment of the present application can be applied to a device with data processing function such as a terminal device or a server. For example, any implementation of the compression method provided in the embodiment of the present application can also be implemented by means of a data communication process between different devices (for example, a terminal device and a server, two terminal devices, or two servers). Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (PDA) or a tablet computer. The server can be a stand-alone server, a cluster server or a cloud server.
[0171] In addition, in order to better understand the above compression method, an example is provided below for explanation.
[0172] As an example, assume that a data processing model (e.g., a face recognition model, an image style transfer model, a speech recognition model, or a text translation model) includes a deep convolutional network; each convolution kernel in the deep convolutional network is a convolution kernel including 3×3 weight elements. Based on this assumption, it can be known that the compression processing process for the data processing model may include the following steps 31 to 35.
[0173] Step 31: Use sample data to pre-train the above data processing model to obtain a pre-trained data processing model, so that the pre-trained data processing model has better data processing performance.
[0174] Step 32: Divide the deep convolutional network in the pre-trained data processing model in terms of the convolution kernel dimension (for example, Figure 2 The division method shown in the figure) is used to obtain multiple convolution kernel groups, so that each convolution kernel group includes 16 convolution kernels that exist in the deep convolution network and are located adjacent to each other.
[0175] Step 33: From Figure 3 The target sparse template corresponding to each convolution kernel group is determined from the 8 templates shown, so that for any convolution kernel group subsequently, all convolution kernels in the convolution kernel group are sparsely processed using the target sparse template corresponding to the convolution kernel group.
[0176] Step 34: According to the target sparse templates corresponding to all the convolution kernel groups in the above deep convolutional network, a target convolution kernel group is determined from these convolution kernel groups, so that the target convolution kernel group can represent the convolution kernel group that needs to be sparsely processed in the optimal compression scheme.
[0177] Step 35: According to the target sparse template corresponding to the target convolution kernel group above, the deep convolution network in the pre-trained data processing model is compressed to obtain a compression result for the pre-trained data processing model (for example, the compressed model above), so that the compression result does not contain the weight parameters that need to be removed and are described by the target sparse template corresponding to the target convolution kernel group.
[0178] Based on the relevant contents of steps 31 to 35 above, it can be known that in some application scenarios, Figure 3 The 8 templates shown complete the compression processing of the deep convolutional network composed of multiple convolution kernels including 3×3 weight elements; and this compression processing scheme has the advantages shown in ①-⑤ below.
[0179] ① For the compression processing scheme shown in steps 31 to 35 above, this compression scheme will not change the output channels of the model layer, so there is no limitation on the supported model structure.
[0180] ② For the compression processing scheme shown in steps 31 to 35 above, this compression scheme imposes some sparse matrix constraints on the sparse process of the weight parameters (for example, Figure 3 In this way, the sparse matrix has a certain fixed pattern while maintaining a high compression rate. Therefore, conventional convolution optimization methods such as data rearrangement / vectorized calculation can be used to enable this compression scheme to achieve higher implementation efficiency on various computing platforms.
[0181] ③ For the compression processing scheme shown in steps 31 to 35 above, this compression scheme is a technical solution set for sparse processing of Depthwise convolution, so that the compression scheme can not only realize sparse processing for deep convolutional networks, but also improve hardware inference performance while ensuring accuracy, so that the compression scheme can be applied to various neural network compression fields, thereby making the compression scheme have broad application prospects in algorithm deployment and implementation, which is conducive to expanding the application scope of the compression method.
[0182] ④ For the compression processing scheme shown in steps 31 to 35 above, this compression scheme removes 3 weight parameters from the convolution kernel including 3×3 weight parameters, and in order to achieve better acceleration performance in engineering, the compression scheme imposes certain constraints on the 3 weight parameters that need to be removed. The specific constraints are: the 3 weight parameters are distributed in different rows of the convolution kernel, and the 3 weight parameters are the beginning or end of the corresponding rows in the convolution kernel, so that this method is more friendly to the central processing unit (CPU) and the graphics processing unit (GPU) in calculating the number of memory accesses and cache misses.
[0183] ⑤ For the compression processing scheme shown in steps 31 to 35 above, this compression scheme can achieve Mbv2 lossless compression on the CPU, and a single OP has a 25% to 40% performance improvement. In addition, the sparse method described in this compression scheme is applicable to depthwise convolutions of various sizes, so that this compression scheme can be widely used in various types of convolutional neural network compression and engineering deployment.
[0184] ⑥ For the compression processing scheme shown in steps 31 to 35 above, when this compression scheme is implemented on the CPU, the data stream can be arranged in N16HWC16, and in this arrangement, the depthwise convolution is performed in a sliding window manner, and the feature map output of 16 channels is calculated at a time. It can be seen that in this calculation method, it is only necessary to judge the pattern model when calculating every 16 convolution kernel cycles, which is helpful to save time. In addition, when the input feature map is relatively large, this part of the time consumption can be ignored.
[0185] ⑦ For the compression processing scheme shown in steps 31 to 35 above, this compression scheme utilizes the pipeline characteristics of the ARM-CPU to design the sparse processing information of every 16 convolution kernels in the convolution kernel dimension (for example, whether sparse processing is performed, what template is used for sparse processing, etc.) to be consistent, which is conducive to improving the execution efficiency of this compression scheme.
[0186] ⑧For the compression processing scheme shown in steps 31 to 35 above, this compression scheme makes up for the defect that sparse processing cannot be performed Depthwise in the sparse field, and this compression scheme can achieve greater advantages in reducing the precision loss of lightweight network sparseization and improving the performance of the entire network.
[0187] Based on the compression method provided in the embodiment of the present application, the embodiment of the present application also provides a compression device. Figure 4 Explain and illustrate. Figure 4 This is a schematic diagram of the structure of a compression device provided in an embodiment of the present application. It should be noted that for the technical details of the compression device provided in an embodiment of the present application, please refer to the relevant content of the compression method above.
[0188] like Figure 4 As shown, the compression device 400 provided in the embodiment of the present application includes:
[0189] A grouping unit 401 is used to group a plurality of convolution kernels in the deep convolution network to obtain at least two convolution kernel groups;
[0190] A selection unit 402 is used to select a target sparse template corresponding to each convolution kernel group from a plurality of candidate sparse templates;
[0191] A searching unit 403 is configured to search for a target convolution kernel group from the at least two convolution kernel groups according to a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups; the preset compression constraint includes a convolution performance constraint;
[0192] A compression unit 404 is used to compress the deep convolutional network using the target sparse template corresponding to the target convolution kernel group to obtain a compressed deep convolutional network; the performance characterization data of the compressed deep convolutional network meets the convolution performance constraint; the performance characterization data is determined based on sample data and the compressed deep convolutional network; the sample data includes at least one of image data, text data and voice data.
[0193] In one possible implementation, the deep convolutional network includes a plurality of convolution kernels arranged in sequence; for any of the convolution kernel groups, the convolution kernel group includes 16 convolution kernels that are arranged in adjacent positions in sequence.
[0194] In one possible implementation, the preset compression constraint also includes a sparse processing group number constraint; the number of the target convolution kernel groups satisfies the sparse processing group number constraint.
[0195] In one possible implementation, the convolution kernel includes at least two rows of weight parameters, and each row of weight parameters includes at least two weight parameters; the candidate sparse template is used to remove the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel.
[0196] In a possible implementation manner, the number of the candidate sparse templates is determined according to the number of weight parameter rows of the convolution kernel.
[0197] In a possible implementation, the convolution kernel includes 3 rows of weight parameters, each row of weight parameters includes 3 weight parameters; and the plurality of candidate sparse templates include 8 candidate sparse templates.
[0198] In one possible implementation, the at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; if each convolution kernel in the mth convolution kernel group belongs to a first type of convolution kernel, then the target sparse template corresponding to the mth convolution kernel group is selected from several candidate sparse templates corresponding to the first type of convolution kernel; m is a positive integer, m≤M.
[0199] In a possible implementation manner, the plurality of candidate sparse templates corresponding to the first type of convolution kernels include K candidate sparse templates, where K is a positive integer;
[0200] The selection unit 402 includes:
[0201] A first determining subunit is used to determine the usage impact characterization data corresponding to the kth candidate sparse template according to the mth convolution kernel group and the kth candidate sparse template corresponding to the first type of convolution kernel, where k is a positive integer, k≤K;
[0202] The template search subunit is used to search for a candidate sparse template that meets a preset influence condition from the K candidate sparse templates according to the usage influence characterization data corresponding to the K candidate sparse templates, as the target sparse template corresponding to the mth convolution kernel group.
[0203] In one possible implementation, the first determination subunit is specifically used to: determine the parameter impact characterization data corresponding to the kth candidate sparse template based on the weight parameters of each convolution kernel in the mth convolution kernel group and the kth candidate sparse template; determine the performance impact characterization data corresponding to the kth candidate sparse template based on the sample data, the mth convolution kernel group and the kth candidate sparse template; determine the usage impact characterization data corresponding to the kth candidate sparse template based on the parameter impact characterization data corresponding to the kth candidate sparse template and the performance impact characterization data corresponding to the kth candidate sparse template.
[0204] In a possible implementation manner, the mth convolution kernel group includes G convolution kernels, where G is a positive integer;
[0205] The selection unit 402 is specifically used to: determine the target sparse template corresponding to the g-th convolution kernel based on the g-th convolution kernel in the m-th convolution kernel group and several candidate sparse templates corresponding to the first type of convolution kernel, where g is a positive integer, g≤G; perform statistical analysis on the target sparse templates corresponding to the G convolution kernels to obtain statistical analysis results; and determine the target sparse template corresponding to the m-th convolution kernel group based on the statistical analysis results.
[0206] In one possible implementation, the at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; if there are at least two types of convolution kernels in the mth convolution kernel group, the target sparse template corresponding to the mth convolution kernel group includes the target sparse template corresponding to each convolution kernel in the mth convolution kernel group, where m is a positive integer, m≤M.
[0207] In one possible implementation, the m-th convolution kernel group includes G convolution kernels, where G is a positive integer; the g-th convolution kernel in the m-th convolution kernel group belongs to the second type of convolution kernel, and the target sparse template corresponding to the g-th convolution kernel is selected from several candidate sparse templates corresponding to the second type of convolution kernel, g is a positive integer, g≤G.
[0208] In a possible implementation manner, the search unit 403 includes:
[0209] A space construction subunit, configured to construct a search space according to the deep convolutional network and the target sparse templates corresponding to the at least two convolutional kernel groups, wherein the search space includes at least two candidate compression networks, and the candidate compression networks are obtained by compressing the deep convolutional network according to the target sparse templates corresponding to one or more convolutional kernel groups;
[0210] A network search subunit, configured to search the search space for a target compression network that satisfies the preset compression constraint;
[0211] The second determination subunit is used to determine the target convolution kernel group according to the target compression network.
[0212] In a possible implementation manner, the preset compression constraint further includes a sparse processing group number constraint;
[0213] The space construction subunit is specifically used to: construct a search space according to the sparse processing group number constraint, the deep convolutional network and the target sparse templates corresponding to the at least two convolution kernel groups, so that each candidate compression network in the search space satisfies the sparse processing group number constraint;
[0214] The network search subunit is specifically used to search for a target compression network that satisfies the convolution performance constraint from the search space.
[0215] In a possible implementation manner, the compression device 400 further includes:
[0216] A model acquisition unit, used to acquire a model to be compressed, wherein the model to be compressed includes the deep convolutional network;
[0217] The compression unit 404 is specifically used to: use the target sparse template corresponding to the target convolution kernel group to compress the deep convolution network in the model to be compressed to obtain a compressed model, and the compressed model includes the compressed deep convolution network.
[0218] In a possible implementation, the model to be compressed includes at least one of an image processing module, a text processing module, and a speech processing module.
[0219] Based on the relevant contents of the above-mentioned compression device 400, it can be known that for the compression device 400 provided in the embodiment of the present application, a plurality of convolution kernels in the deep convolution network are first grouped to obtain at least two convolution kernel groups; then, a target sparse template corresponding to each convolution kernel group is selected from a plurality of candidate sparse templates; then, based on the preset compression constraint and the target sparse template corresponding to the at least two convolution kernel groups, the target convolution kernel group is searched from the at least two convolution kernel groups, so that the compressed deep convolution network obtained by compressing the deep convolution network using the target sparse template corresponding to the target convolution kernel group meets the preset compression constraint, thereby achieving the purpose of compression processing according to the compression requirements. Among them, because the preset compression constraint includes a convolution performance constraint, so that the performance characterization data of the compressed deep convolution network meets the convolution performance constraint, so that the network compression processing can be achieved under the premise of ensuring the data processing performance, thereby effectively avoiding the defect of a large decrease in data processing performance caused by the relevant compression scheme, and thus helping to improve the compression effect.
[0220] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the compression method provided in the embodiment of the present application.
[0221] See also Figure 5 , which shows a schematic diagram of the structure of an electronic device 500 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0222] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0223] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0224] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0225] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0226] The embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the compression method provided in the embodiment of the present application.
[0227] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0228] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0229] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0230] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.
[0231] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0232] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0233] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.
[0234] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0235] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0236] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0237] It should be understood that in the present application, "at least one (item)" means one or more, "multiple" means two or more, and "several" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0238] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0239] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0240] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A compression method, characterized in that: The method comprises: Grouping a number of convolution kernels in a deep convolutional network to obtain at least two convolution kernel groups; Selecting a target sparse template corresponding to each convolution kernel group from a plurality of candidate sparse templates; According to a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups, searching for a target convolution kernel group from the at least two convolution kernel groups; the preset compression constraint includes a convolution performance constraint; The deep convolutional network is compressed using the target sparse template corresponding to the target convolution kernel group to obtain a compressed deep convolutional network; the performance characterization data of the compressed deep convolutional network satisfies the convolution performance constraint; the performance characterization data is determined based on sample data and the compressed deep convolutional network; the sample data includes at least one of image data, text data and voice data.
2. The method according to claim 1, characterized in that The deep convolutional network includes a plurality of convolution kernels arranged in sequence; For any of the convolution kernel groups, the convolution kernel group includes 16 convolution kernels that are arranged adjacent to each other in sequence.
3. The method according to claim 1, characterized in that The preset compression constraint also includes a sparse processing group number constraint; The number of the target convolution kernel groups satisfies the constraint on the number of sparse processing groups.
4. The method according to claim 1, characterized in that: The convolution kernel includes at least two rows of weight parameters, and each row of weight parameters includes at least two weight parameters; The candidate sparse template is used to remove the weight parameters at the beginning or the end of each row of weight parameters of the convolution kernel.
5. The method according to claim 4, characterized in that The number of the candidate sparse templates is determined according to the number of weight parameter rows of the convolution kernel.
6. The method according to claim 5, characterized in that The convolution kernel includes 3 rows of weight parameters, and each row of weight parameters includes 3 weight parameters; The plurality of candidate sparse templates include 8 candidate sparse templates.
7. The method according to claim 1, characterized in that The at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; If each convolution kernel in the mth convolution kernel group belongs to the first type of convolution kernel, then the target sparse template corresponding to the mth convolution kernel group is selected from several candidate sparse templates corresponding to the first type of convolution kernel; m is a positive integer, m≤M.
8. The method according to claim 7, characterized in that The plurality of candidate sparse templates corresponding to the first type of convolution kernels include K candidate sparse templates, where K is a positive integer; The process of determining the target sparse template corresponding to the mth convolution kernel group includes: Determine, according to the mth convolution kernel group and the kth candidate sparse template corresponding to the first type of convolution kernel, usage impact characterization data corresponding to the kth candidate sparse template, where k is a positive integer, k≤K; According to the usage impact characterization data corresponding to the K candidate sparse templates, a candidate sparse template that meets the preset impact condition is searched from the K candidate sparse templates as the target sparse template corresponding to the mth convolution kernel group.
9. The method according to claim 8, characterized in that The process of determining the usage impact characterization data corresponding to the k-th candidate sparse template includes: Determine, according to the weight parameters of each convolution kernel in the mth convolution kernel group and the kth candidate sparse template, the parameter impact characterization data corresponding to the kth candidate sparse template; Determine, based on the sample data, the mth convolution kernel group and the kth candidate sparse template, performance impact characterization data corresponding to the kth candidate sparse template; Determine usage impact characterization data corresponding to the kth candidate sparse template according to the parameter impact characterization data corresponding to the kth candidate sparse template and the performance impact characterization data corresponding to the kth candidate sparse template.
10. The method according to claim 7, characterized in that The mth convolution kernel group includes G convolution kernels, where G is a positive integer; The process of determining the target sparse template corresponding to the mth convolution kernel group includes: Determine a target sparse template corresponding to the g-th convolution kernel according to the g-th convolution kernel in the m-th convolution kernel group and a plurality of candidate sparse templates corresponding to the first type of convolution kernels, where g is a positive integer and g≤G; Performing statistical analysis on the target sparse templates corresponding to the G convolution kernels to obtain statistical analysis results; According to the statistical analysis result, the target sparse template corresponding to the m-th convolution kernel group is determined.
11. The method according to claim 1, characterized in that: The at least two convolution kernel groups include M convolution kernel groups, where M is a positive integer; If there are at least two types of convolution kernels in the mth convolution kernel group, the target sparse template corresponding to the mth convolution kernel group includes the target sparse template corresponding to each convolution kernel in the mth convolution kernel group, where m is a positive integer, m≤M.
12. The method according to claim 11, characterized in that The mth convolution kernel group includes G convolution kernels, where G is a positive integer; The g-th convolution kernel in the m-th convolution kernel group belongs to the second type of convolution kernel, and the target sparse template corresponding to the g-th convolution kernel is selected from several candidate sparse templates corresponding to the second type of convolution kernel, g is a positive integer, g≤G.
13. The method according to claim 1, characterized in that The search process of the target convolution kernel group includes: According to the deep convolutional network and the target sparse templates corresponding to the at least two convolutional kernel groups, a search space is constructed, wherein the search space includes at least two candidate compression networks, and the candidate compression networks are obtained by compressing the deep convolutional network according to the target sparse templates corresponding to one or more convolutional kernel groups; Searching for a target compression network that satisfies the preset compression constraint from the search space; The target convolution kernel group is determined according to the target compression network.
14. The method according to claim 13, characterized in that The preset compression constraint also includes a sparse processing group number constraint; The step of constructing a search space based on the deep convolutional network and the target sparse template corresponding to the at least two convolutional kernel groups includes: According to the sparse processing group number constraint, the deep convolutional network and the target sparse templates corresponding to the at least two convolution kernel groups, a search space is constructed so that each candidate compression network in the search space satisfies the sparse processing group number constraint; The searching for a target compression network satisfying the preset compression constraint from the search space includes: A target compression network that satisfies the convolution performance constraint is searched from the search space.
15. The method according to any one of claims 1 to 14, characterized in that: Before grouping the plurality of convolution kernels in the deep convolutional network, the method further includes: Acquire a model to be compressed, wherein the model to be compressed includes the deep convolutional network; The method of compressing the deep convolutional network using the target sparse template corresponding to the target convolutional kernel group to obtain a compressed deep convolutional network includes: The deep convolutional network in the model to be compressed is compressed using the target sparse template corresponding to the target convolution kernel group to obtain a compressed model, wherein the compressed model includes the compressed deep convolutional network.
16. The method according to claim 15, characterized in that The model to be compressed includes at least one of an image processing module, a text processing module and a speech processing module.
17. A compression device, characterized in that: include: A grouping unit, used for grouping a plurality of convolution kernels in the deep convolution network to obtain at least two convolution kernel groups; A selection unit, used for selecting a target sparse template corresponding to each convolution kernel group from a plurality of candidate sparse templates; A searching unit, configured to search for a target convolution kernel group from the at least two convolution kernel groups according to a preset compression constraint and a target sparse template corresponding to the at least two convolution kernel groups; The preset compression constraints include convolution performance constraints; A compression unit is used to compress the deep convolutional network using the target sparse template corresponding to the target convolution kernel group to obtain a compressed deep convolutional network; the performance characterization data of the compressed deep convolutional network meets the convolution performance constraint; the performance characterization data is determined based on sample data and the compressed deep convolutional network; the sample data includes at least one of image data, text data and voice data.
18. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 16.
19. A computer readable medium, characterized in that The computer-readable medium stores instructions or computer programs, and when the instructions or computer programs are executed on a device, the device executes the method according to any one of claims 1 to 16.