A data processing method, device, equipment and storage medium

Through synchronous sampling of the data to be processed and the convolution kernel, the efficient utilization of the convolution processing array is achieved, the problem of low utilization of the convolution processing array is solved, and the processing efficiency is improved.

CN112927124BActive Publication Date: 2024-10-29CHENGDU SENSETIME TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110352221.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-31
Publication Date
2024-10-29
Estimated Expiration
2041-03-31

AI Technical Summary

Technical Problem

The utilization of convolutional processing arrays is low, resulting in increased energy consumption and reduced efficiency.

Method used

By synchronously sampling the data to be processed and the convolution kernel, the first sampling result and the second sampling result are obtained in one-to-one correspondence, and are input to the processing array to achieve effective utilization of each unit.

Benefits of technology

It improves the utilization rate of the processing array, avoids waste of energy consumption, and improves the processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112927124B_ABST
    Figure CN112927124B_ABST
Patent Text Reader

Abstract

The present invention relates to a data processing method, device, equipment and storage medium. The data processing method comprises: sampling the data to be processed according to the step length of the convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1; sampling the convolution kernel according to the step length of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result and the at least one second sampling result correspond one to one; and inputting the at least one first sampling result and the at least one second sampling result into a processing array correspondingly, so that the processing array outputs the processing result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method, device, equipment and storage medium. Background Art

[0002] With the development of artificial intelligence technology, images can be automatically processed in many aspects, reducing labor costs and improving efficiency and accuracy. For example, processing arrays can be used to perform convolution processing on image data, but the utilization rate of processing arrays is often low during the convolution process, which increases energy consumption and reduces efficiency. Summary of the invention

[0003] The present invention provides a data processing method, device, equipment and storage medium to solve the defects in the related art.

[0004] According to a first aspect of an embodiment of the present invention, a data processing method is provided, the method comprising:

[0005] Sampling the data to be processed according to a step length of the convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1;

[0006] Sampling the convolution kernel according to the step size of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result corresponds to the at least one second sampling result in one-to-one correspondence;

[0007] The at least one first sampling result and the at least one second sampling result are correspondingly input to the processing array, so that the processing array outputs a processing result.

[0008] In combination with any embodiment provided in the present disclosure, sampling the data to be processed according to the step size of the convolution operation to obtain at least one first sampling result includes:

[0009] Performing row sampling on the data to be processed according to the step length to obtain at least one first row sampling result, wherein a union of the at least one first row sampling result is the data to be processed;

[0010] Performing column sampling on the data to be processed according to the step length to obtain at least one first column sampling result, wherein a union of the at least one first column sampling result is the data to be processed;

[0011] The intersection of each of the first row sampling results and each of the first column sampling results is determined as the first sampling result.

[0012] In combination with any implementation manner provided in the present disclosure, sampling the convolution kernel according to the step size of the convolution operation to obtain at least one second sampling result includes:

[0013] Performing row sampling on the convolution kernel according to the step size to obtain at least one second row sampling result, wherein a union of the at least one second row sampling result is the convolution kernel;

[0014] Performing column sampling on the convolution kernel according to the step size to obtain at least one second column sampling result, wherein a union of the at least one second column sampling result is the data to be processed;

[0015] The intersection of each second row sampling result and each second column sampling result is determined as the second sampling result.

[0016] In combination with any embodiment provided in the present disclosure, the step of inputting the at least one first sampling result and the at least one second sampling result into a corresponding processing array so that the processing array outputs a processing result includes:

[0017] For each first sampling result, the first sampling result is input into the processing array, and a second sampling result corresponding to the first sampling result is input into the processing array; and

[0018] Controlling the processing array to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result;

[0019] The processing array is controlled to output a processing result according to the sub-processing result corresponding to each first sampling result.

[0020] In combination with any embodiment provided in the present disclosure, for each first sampling result, inputting the first sampling result into the processing array includes:

[0021] For each first sampling result, multiple values ​​of the first sampling result are input into multiple units of the processing array, so that the relative positions of the multiple values ​​in the multiple units are the same as the relative positions of the multiple values ​​in the first sampling result.

[0022] In combination with any embodiment provided by the present disclosure, the processing array includes an effective array, at least one overflow row and at least one overflow column distributed around the effective array, wherein the effective array includes a plurality of units for storing and processing data, and the overflow row and the overflow column include a plurality of units for storing data;

[0023] The step of inputting the multiple values ​​of the first sampling result into the multiple units of the processing array includes:

[0024] The multiple values ​​of the first sampling result are input into the multiple units of the processing array, so that the values ​​of the first row and first column of the first sampling result are input into the first row and first column of the unit for storing and processing data.

[0025] In combination with any implementation manner provided in the present disclosure, the controlling the processing array to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result includes:

[0026] For each weight value in the corresponding second sampling result, control the processing array to use the value corresponding to the weight value in the first sampling result to determine a partial sum with the weight value;

[0027] Control the processing array to determine a partial result according to the partial sums corresponding to the weight values ​​in the corresponding second sampling result;

[0028] The processing array is controlled to determine a sub-processing result corresponding to the first sampling result according to at least one partial result.

[0029] In combination with any embodiment provided by the present disclosure, for each weight value in the corresponding second sampling result, controlling the processing array to use the numerical value corresponding to the weight value in the first sampling result and the weight value to determine the partial sum, includes:

[0030] For a first weight value in the corresponding second sampling result, the processing array is controlled to determine a partial sum by using a value of the first sampling result in a cell corresponding to an initial position of the processing array and the first weight value.

[0031] In combination with any embodiment provided by the present disclosure, for each weight value in the corresponding second sampling result, controlling the processing array to use the numerical value corresponding to the weight value in the first sampling result and the weight value to determine the partial sum, includes:

[0032] For each non-first weight value in the corresponding second sampling result, according to the first numerical value corresponding to the non-first weight value in the first sampling result and the positional relationship in the first sampling result between the second numerical value corresponding to the previous weight value of the non-first weight value in the first sampling result, determining a moving mode of the first sampling result, and controlling the processing array to move the second numerical value to the corresponding unit using the determined moving mode;

[0033] The processing array is controlled to use the value in the corresponding unit after the shift and the non-first weight value to determine the partial sum.

[0034] In combination with any embodiment provided in the present disclosure, it also includes:

[0035] Determining the number of rows and columns of the data to be processed according to the processing array, the convolution kernel and the step size;

[0036] Determine the number of overlapping rows and overlapping columns according to the convolution kernel and the step size;

[0037] The data of the image to be processed are sampled according to the number of rows and columns of the data to be processed, the number of overlapping rows, and the number of overlapping columns to obtain a plurality of data to be processed.

[0038] In combination with any embodiment provided in the present disclosure, the data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel.

[0039] According to a second aspect of an embodiment of the present invention, there is provided a data processing device, the device comprising:

[0040] A controller, configured to sample the data to be processed according to a step length of a convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1; sample the convolution kernel according to the step length of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result and the at least one second sampling result have a one-to-one correspondence; and input the at least one first sampling result and the at least one second sampling result to a processing array correspondingly;

[0041] The processing array is used to process the at least one first sampling result and the at least one second sampling result, and output the processing results.

[0042] In combination with any embodiment provided by the present disclosure, the controller is used to perform row sampling on the data to be processed according to the step size to obtain at least one first row sampling result, wherein the union of the at least one first row sampling result is the data to be processed; perform column sampling on the data to be processed according to the step size to obtain at least one first column sampling result, wherein the union of the at least one first column sampling result is the data to be processed; and determine the intersection of each first row sampling result and each first column sampling result as the first sampling result.

[0043] In combination with any embodiment provided by the present disclosure, the controller is used to perform row sampling on the convolution kernel according to the step size to obtain at least one second row sampling result, wherein the union of the at least one second row sampling result is the convolution kernel; perform column sampling on the convolution kernel according to the step size to obtain at least one second column sampling result, wherein the union of the at least one second column sampling result is the data to be processed; and respectively determine the intersection of each second row sampling result and each second column sampling result as the second sampling result.

[0044] In combination with any embodiment provided in the present disclosure, the controller is used for inputting each first sampling result into the processing array, and inputting a second sampling result corresponding to the first sampling result into the processing array; and

[0045] The processing array is used to determine the corresponding sub-processing result according to the first sampling result and the corresponding second sampling result; and output the processing result according to the sub-processing result corresponding to each first sampling result.

[0046] In combination with any embodiment provided in the present disclosure, the controller is used to input multiple numerical values ​​of each first sampling result into multiple units of the processing array, so that the relative positions of the multiple numerical values ​​in the multiple units are the same as the relative positions of the multiple numerical values ​​in the first sampling result.

[0047] In combination with any embodiment provided by the present disclosure, the processing array includes an effective array, at least one overflow row and at least one overflow column distributed around the effective array, wherein the effective array includes a plurality of units for storing and processing data, and the overflow row and the overflow column include a plurality of units for storing data;

[0048] The controller is used to input multiple values ​​of the first sampling result into multiple units of the processing array, so that the values ​​of the first row and first column of the first sampling result are input into the first row and first column of the unit for storing and processing data.

[0049] In combination with any embodiment provided by the present disclosure, the processing array is used to determine a partial sum with a numerical value corresponding to the weight value in the first sampling result and the weight value for each weight value in the corresponding second sampling result;

[0050] Determine a partial result according to the partial sums corresponding to the weight values ​​in the corresponding second sampling result; and

[0051] A sub-processing result corresponding to the first sampling result is determined according to the at least one partial result.

[0052] In combination with any embodiment provided in the present disclosure, the processing array is used to determine a partial sum for a first weight value in a corresponding second sampling result by using a value of the first sampling result in a corresponding unit at an initial position of the processing array and the first weight value.

[0053] In combination with any embodiment provided by the present disclosure, the controller is used to determine, for each non-first weight value in the corresponding second sampling result, a moving mode of the first sampling result according to a first numerical value corresponding to the non-first weight value in the first sampling result and a positional relationship in the first sampling result between a second numerical value corresponding to a previous weight value of the non-first weight value in the first sampling result;

[0054] The processing array is used to move the second value to the corresponding unit in a determined moving manner; and determine the partial sum by using the value in the corresponding unit after the move and the non-first weight value.

[0055] In combination with any embodiment provided by the present disclosure, the controller is further used to determine the number of rows and columns of the data to be processed according to the processing array, the convolution kernel and the step size; determine the number of overlapping rows and the number of overlapping columns according to the convolution kernel and the step size; and sample the data of the image to be processed according to the number of rows and columns of the data to be processed, the number of overlapping rows and the number of overlapping columns to obtain multiple data to be processed.

[0056] In combination with any embodiment provided in the present disclosure, the data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel.

[0057] According to a third aspect of an embodiment of the present invention, an electronic device is provided. The device includes a memory, a processor, and the apparatus according to the second aspect of the embodiment of the present invention.

[0058] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.

[0059] According to the above embodiments, by synchronously sampling the data to be processed and the convolution kernel, at least one first sampling result and at least one second sampling result are obtained, and the first sampling result and the second sampling result correspond one to one, and then the corresponding first sampling result and the second sampling result can be sequentially input into the processing array to obtain the processing result. Since the sampling of the data to be processed and the convolution kernel are both based on the step length of the convolution operation, the corresponding first sampling result and the second sampling result match each other, that is, the step length of the convolution operation of the second sampling result for the first sampling result is 1, and then when input into the processing array, each unit can be utilized, thereby improving the utilization rate of the processing array, avoiding energy waste, and improving processing efficiency.

[0060] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0062] Figure 1 is a flow chart of a data processing method shown in an embodiment of the present invention;

[0063] Figure 2 is a schematic diagram of data to be processed shown in an embodiment of the present invention;

[0064] Figure 3 is a schematic diagram of at least one first sampling result shown in an embodiment of the present invention;

[0065] Figure 4 is a schematic diagram of a convolution kernel shown in an embodiment of the present invention;

[0066] Figure 5 is a schematic diagram of at least one second sampling result shown in an embodiment of the present invention;

[0067] Figure 6 is a flow chart of obtaining a processing result shown in an embodiment of the present invention;

[0068] Figure 7 is a schematic diagram of the structure of a processing array shown in an embodiment of the present invention;

[0069] Figure 8 is a schematic diagram of the structure of a unit in a processing array shown in an embodiment of the present invention;

[0070] Fig. 9 is a flow chart of obtaining sub-processing results shown in an embodiment of the present invention;

[0071] Fig.10 is a schematic diagram showing that a first sampling result is moved to the left on a processing array according to an embodiment of the present invention;

[0072] Fig.11 is a schematic diagram showing a first sampling result moving upward on a processing array according to an embodiment of the present invention;

[0073] Fig.12 is a schematic diagram showing that a first sampling result is moved rightward on a processing array according to an embodiment of the present invention;

[0074] Fig.13 is a schematic diagram of a sampling method of data to be processed according to an embodiment of the present invention;

[0075] Fig.14 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION

[0076] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0077] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0078] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0079] In a first aspect, at least one embodiment of the present invention provides a data processing method. Figure 1 , which shows the process of the method, including steps S101 to S103.

[0080] The method may be executed by an electronic device such as a terminal device or a server, and the terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA) handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The method may be implemented by a processor calling a computer-readable instruction stored in a memory. Alternatively, the method may be executed by a server, and the server may be a local server, a cloud server, etc.

[0081] In step S101, the data to be processed is sampled according to a step size of a convolution operation to obtain at least one first sampling result, wherein the step size is greater than 1.

[0082] The sampling method may be downsampling, that is, selecting part of the data from the data to be processed to form a first sampling result. One downsampling may obtain a first sampling result, and multiple downsampling may obtain multiple first sampling results. There is no data overlap between different first sampling results, and all the first sampling results may form a complete data to be sampled, that is, the data to be processed may be used as a first sampling result, or the data to be processed may be split into multiple first sampling results.

[0083] The step size of the convolution operation refers to the step size of the convolution kernel moving on the data to be processed; in the convolution operation, the convolution kernel performs a calculation every time it moves one step. Similarly, sampling according to the step size refers to selecting from the data to be processed according to the step size, and the result obtained by the selection is the first sampling result; the starting point of the sampling is the data that has not been selected by other sampling processes, and the first sampling results obtained from different positions as the starting point are different and do not overlap. For example, the data to be processed is divided into 17 sub-data. When the step size is 2, firstly, the first sub-data is used as the starting point for sampling with a step size of 2 to obtain the first sampling result consisting of the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, 15th, and 17th sub-data, and then the second sub-data is used as the starting point for sampling with a step size of 2 to obtain the first sampling result consisting of the 2nd, 4th, 6th, 8th, 10th, 12th, 14th, and 16th sub-data. At this point, all the data to be processed have been selected, so the sampling ends and the above two first sampling results are obtained.

[0084] In step S102, the convolution kernel is sampled according to the step size of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result corresponds to the at least one second sampling result.

[0085] The sampling method may be downsampling, that is, selecting some weight values ​​from the convolution kernel to form a second sampling result. One downsampling may obtain a second sampling result, and multiple downsampling may obtain multiple second sampling results. There is no overlap between different second sampling results, and all second sampling results may form a complete convolution kernel, that is, the convolution kernel may be used as a second sampling result, or the convolution kernel may be split into multiple second sampling results.

[0086] Sampling according to the step size means selecting from the convolution kernels according to the step size, and the result obtained by the selection is the second sampling result; the starting point of the sampling is the weight value that has not been selected by other sampling processes, and the second sampling results obtained from different positions as the starting point are different and do not overlap. For example, when the convolution kernel is divided into 9 weight values ​​and the step size is 2, firstly, the first weight value is used as the starting point for sampling with a step size of 2, and the second sampling result consisting of the 1st, 3rd, 5th, 7th, and 9th sub-weight values ​​is obtained, and then the second weight value is used as the starting point for sampling with a step size of 2, and the second sampling result consisting of the 2nd, 4th, 6th, and 8th weight values ​​is obtained. At this point, all the convolution kernels have been selected, so the sampling ends, and the above two second sampling results are obtained.

[0087] Since the sampling of the data to be processed and the sampling of the convolution kernel are both performed according to the step size, the number of the first sampling results and the number of the second sampling results are the same. Since the convolution kernel performs a calculation every time it moves one step in the convolution operation, there is a corresponding relationship between the sub-data of the data to be processed and the weight value of the convolution kernel during the entire convolution operation process, and thus the first sampling result and the second sampling result also have a corresponding relationship, that is, at least one first sampling result and at least one second sampling result are one-to-one corresponding. The corresponding first sampling results and second sampling results refer to the sub-data in the data to be processed and the weight value calculated with it during the convolution process. When matching specifically, the starting point position of the sampling can be used for matching, that is, the relative position of the starting point of the first sampling result in the data to be processed is the same as the relative position of the starting point of the second sampling result in the convolution kernel, then it is confirmed that the above-mentioned first sampling result corresponds to the second sampling result. For example, in the above-mentioned examples of the data to be processed and the convolution kernel, the first sampling result whose starting point is the first sub-data corresponds to the second sampling result whose starting point is the first weight value, that is, the first sampling result composed of the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, 15th, and 17th sub-data corresponds to the second sampling result composed of the 1st, 3rd, 5th, 7th, and 9th weight values; the first sampling result whose starting point is the 2nd sub-data corresponds to the second sampling result whose starting point is the second weight value, that is, the first sampling result composed of the 2nd, 4th, 6th, 8th, 10th, 12th, 14th, 16th, and 18th sub-data corresponds to the second sampling result composed of the 2nd, 4th, 6th, and 8th weight values.

[0088] In step S103, the at least one first sampling result and the at least one second sampling result are input to the processing array accordingly, so that the processing array outputs the processing result.

[0089] Among them, the first pair of mutually corresponding first sampling results and second sampling results are input into the processing array, and then the second pair of mutually corresponding first sampling results and second sampling results are input into the processing array, until the last pair of mutually corresponding first sampling results and second sampling results are input into the processing array, so that the processing array can be controlled to output the processing result, wherein the processing result refers to the result after the data to be processed is convolved by the convolution kernel.

[0090] It should be noted that the data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel. In other words, when the convolution kernel and / or the data to be processed is multi-channel, each channel is convolved accordingly. This method is aimed at the process of convolving a single data to be processed by a single convolution kernel channel, and the method is used separately in each channel and each process is combined to obtain the result of multi-channel convolution.

[0091] According to the above embodiments, by synchronously sampling the data to be processed and the convolution kernel, at least one first sampling result and at least one second sampling result are obtained, and the first sampling result and the second sampling result correspond one to one, and then the corresponding first sampling result and the second sampling result can be sequentially input into the processing array to obtain the processing result. Since the sampling of the data to be processed and the convolution kernel are both based on the step length of the convolution operation, the corresponding first sampling result and the second sampling result match each other, that is, the step length of the convolution operation of the second sampling result for the first sampling result is 1, and then when input into the processing array, each unit can be utilized, thereby improving the utilization rate of the processing array, avoiding energy waste, and improving processing efficiency.

[0092] Specifically, the processing array of the commonly used convolutional neural network accelerator is generally a two-dimensional connection architecture. In the single instruction multiple data (SIMD) operation mode, a single instruction controls all units to perform the same operation (such as shifting, memory access, MAC, etc.). When the step size of the convolution operation is greater than 1, the results calculated by some units of the processing array are unnecessary, which will greatly reduce the utilization of the processing array. For example, when the step size stride=2, the utilization rate of the processing array in SIMD mode is only 1 / 4, and when the step size stride=3, the utilization rate of the processing array in SIMD mode is only 1 / 9. Through the processing method provided in this embodiment, each operation of the processing array is converted into a convolution operation with a step size of 1 for the second sampling result on the first sampling result, thereby making the utilization rate of the processing array reach 100%.

[0093] In some embodiments of the present disclosure, the data to be processed can be sampled according to the step size of the convolution operation in the following manner to obtain at least one first sampling result: first, the data to be processed is row sampled according to the step size to obtain at least one first row sampling result, wherein the union of the at least one first row sampling result is the data to be processed; next, the data to be processed is column sampled according to the step size to obtain at least one first column sampling result, wherein the union of the at least one first column sampling result is the data to be processed; finally, the intersection of each first row sampling result and each first column sampling result is respectively determined as the first sampling result.

[0094] During the convolution operation, the movement of the convolution kernel on the data to be processed is divided into two directions, namely the row direction and the column direction. Therefore, the correspondence between the weight value in the convolution kernel and the sub-data in the data to be processed is divided into two dimensions, row and column. After sampling according to rows and columns respectively, the sampling results are combined in pairs (that is, each first row sampling result is combined with each first column sampling result) to obtain multiple first sampling results, so that the first sampling result and the second sampling result can correspond to each other in both row and column dimensions.

[0095] In addition, both row sampling and column sampling are performed using the sampling method introduced in step S101. Since sampling is performed from two dimensions, if the step length is S, the number of the first sampling results is S. 2 .

[0096] In one example, the data to be processed is as follows Figure 2 The 17*17 data block shown in the figure, and the step size of the convolution operation is 2, so according to the above row sampling, column sampling, and finally taking the intersection method, we can get the following Figure 3 The four first sampling results 301, 302, 303 and 304 are shown, where the first sampling result 301 is the intersection of the 1st, 3, 5, 7, 9, 11, 13, 15 and 17th rows and the 1st, 3, 5, 7, 9, 11, 13, 15 and 17th columns (9*9), and the first sampling result 302 is the intersection of the 1st, 3, 5, 7, 9, 11, 13, 15 and 17th rows and the 2nd, 4th, 6th, 8th, 10th, 11th The first sampling result 303 is the intersection of the 2nd, 4th, 6th, 8th, 10th, 12th, 14th and 16th rows and the 1st, 3rd, 5th, 7th, 9th, 11th, 13th, 15th and 17th columns (8*9), and the first sampling result 304 is the intersection of the 2nd, 4th, 6th, 8th, 10th, 12th, 14th and 16th rows and the 2nd, 4th, 6th, 8th, 10th, 12th, 14th and 16th columns (8*8).

[0097] In some embodiments of the present disclosure, the convolution kernel can be sampled according to the step size of the convolution operation in the following manner to obtain at least one second sampling result: first, the convolution kernel is row-sampled according to the step size to obtain at least one second row sampling result, wherein the union of the at least one second row sampling result is the convolution kernel; next, the convolution kernel is column-sampled according to the step size to obtain at least one second column sampling result, wherein the union of the at least one second column sampling result is the data to be processed; finally, the intersection of each second row sampling result and each second column sampling result is respectively determined as the second sampling result.

[0098] During the convolution operation, the movement of the convolution kernel on the data to be processed is divided into two directions, namely the row direction and the column direction. Therefore, the correspondence between the weight value in the convolution kernel and the sub-data in the data to be processed is divided into two dimensions, row and column. After sampling according to rows and columns respectively, the sampling results are combined in pairs (that is, each second row sampling result is combined with each second column sampling result respectively) to obtain multiple second sampling results, so that the first sampling result and the second sampling result can correspond to each other in both row and column dimensions.

[0099] In addition, both row sampling and column sampling are performed using the sampling method introduced in step S102. Since sampling is performed from two dimensions, if the step length is S, the number of the first sampling results is S 2 .

[0100] In one example, the convolution kernel is Figure 4 The 3*3 convolution kernel is shown in the figure, and the step size of the convolution operation is 2. Therefore, according to the above row sampling, column sampling, and finally taking the intersection method, we can get the following Figure 5 The four second sampling results 501, 502, 503 and 504 are shown, among which the second sampling result 501 is the intersection of the 1st and 3rd rows and the 1st and 3rd columns (i.e., the four weight values ​​of A, C, G, and I in the figure), the second sampling result 502 is the intersection of the 1st and 3rd rows and the 2nd column (i.e., the two weight values ​​of B and H in the figure), the second sampling result 503 is the intersection of the 2nd row and the 1st and 3rd columns (i.e., the two weight values ​​of D and F in the figure), and the second sampling result 504 is the intersection of the 2nd row and the 2nd column (i.e., the weight value E in the figure).

[0101] Figure 3 The four first sampling results and Figure 5The four second sampling results shown are all obtained by sampling according to a step size of 2, and therefore can correspond one to one. Specifically, the first sampling result 301 corresponds to the second sampling result 501, the first sampling result 302 corresponds to the second sampling result 502, the first sampling result 303 corresponds to the second sampling result 503, and the first sampling result 304 corresponds to the second sampling result 504.

[0102] In some embodiments of the present disclosure, the following Figure 6 The method shown inputs the at least one first sampling result and the at least one second sampling result to the corresponding processing array so that the processing array outputs the processing result, including steps S601 to S603.

[0103] In step S601, for each first sampling result, the first sampling result is input into the processing array, and a second sampling result corresponding to the first sampling result is input into the processing array.

[0104] In step S602, the processing array is controlled to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result.

[0105] In step S603, the processing array is controlled to output a processing result according to the sub-processing result corresponding to each first sampling result.

[0106] Among them, step S601 and step S602 are both repeated steps (i.e., repeated N times, where N is the number of first sampling results), that is, step S601 and step S602 are executed for each first sampling result and its corresponding second sampling result. Specifically, the first first sampling result is first input into the processing array, and then the first second sampling result is input into the processing array, and the processing array is controlled to obtain the first sub-processing result according to the above input; then the second first sampling result is input into the processing array, and then the second second sampling result is input into the processing array, and the processing array is controlled to obtain the second sub-processing result according to the above input; until the last sub-processing result (i.e., the Nth sub-processing result) is obtained. For example, for Figure 3 The four first sampling results and Figure 5When the four second sampling results shown in the figure execute step S601 and step S602, the first sampling result 301 can be first input into the processing array, and then the second sampling result 501 can be input into the processing array, so as to control the processing array to obtain the first sub-processing result according to the first sampling result 301 and the second sampling result 501; then the first sampling result 302 can be input into the processing array, and then the second sampling result 502 can be input into the processing array, so as to control the processing array to obtain the second sub-processing result according to the first sampling result 302 and the second sampling result 502; then the first sampling result 303 can be input into the processing array, and then the second sampling result 503 can be input into the processing array, so as to control the processing array to obtain the third sub-processing result according to the first sampling result 303 and the second sampling result 503; finally, the first sampling result 304 can be input into the processing array, and then the second sampling result 504 can be input into the processing array, so as to control the processing array to obtain the fourth sub-processing result according to the first sampling result 304 and the second sampling result 504.

[0107] Wherein, step S601 can be performed in the following manner: for each first sampling result, multiple values ​​of the first sampling result are input into multiple cells of the processing array, so that the relative positions of the multiple values ​​in the multiple cells are the same as the relative positions of the multiple values ​​in the first sampling result. The first sampling result includes multiple rows and columns of values, and the processing array includes multiple rows and columns of cells, each of which is used to store a value. The arrangement of the values ​​in the first sampling result is exactly the same as the arrangement of the values ​​in the processing array. Figuratively speaking, the processing array is a layer of multiple rows and columns of cells, and the first sampling result is a layer of multiple rows and columns of values, and the multiple rows and columns of cells are parallel to and correspond to the multiple rows and columns of values. When the first sampling result is input, the multiple rows and columns of values ​​are mapped as a whole to the multiple rows and columns of cells.

[0108] Please refer to the attached Figure 7 The processing array may include an effective array, at least one overflow row and at least one overflow column distributed around the effective array, wherein the effective array includes a plurality of units for storing and processing data (i.e. Figure 7 The overflow row and the overflow column include a plurality of units PE for storing data (i.e. Figure 7 The number of rows of the unit for storing and processing data is greater than the number of rows of the first sampling result, equal to the number of rows of the first sampling result, or 1 less than the number of rows of the first sampling result, and the number of columns of the unit for storing and processing data is greater than the number of columns of the first sampling result, equal to the number of columns of the first sampling result, or 1 less than the number of columns of the first sampling result. The above relationship is determined when the data to be processed is obtained (which will be described in detail below) and when the first sampling result is obtained (which has been described in detail above). For example, Figure 3 The four first sample results are shown as input Figure 7 In the processing array shown (comprising 10*10 units, the central 8*8 units being units for storing and processing data, and around the central 8*8 units, there are two rows of units for storing data above and below, and two columns of units for storing data on the left and right), the number of rows and columns of the four first sampling results are both 8 or 9, and therefore the above relationship is satisfied.

[0109] Among them, the units used to store and process data and the connection relationship between adjacent units are as follows: Figure 8 As shown in the figure, it can be seen that the unit for storing and processing data has an internal register R0, an operation unit ALU and a related data loading and storage circuit module M, and each unit for storing and processing data is connected to a shift register stack and a static random access memory (SRAM), and the shift register stack has multiple shift registers such as R1, R2, R3, and R4. The unit for storing data has the same structure as the unit for storing and processing data, but does not have an operation unit ALU. Adjacent units are connected through a shift register stack. In the processing array, each unit is connected to its adjacent units in all directions (i.e., up, down, left, and right).

[0110] Based on the structure of the above-mentioned processing array, when the first sampling result is input, multiple values ​​of the first sampling result can be input into multiple units of the processing array, so that the value of the first row and first column of the first sampling result is input into the first row and first column of the unit for storing and processing data, that is, the first value is input into the first unit for storing and processing data. Since the storage and movement of the first sampling result in the processing array are performed uniformly as a whole (that is, the single instruction multiple data (SIMD) operation mode), after the first value is located, the positioning of the entire first sampling result and the processing array is realized. The number of rows of the first sampling result can be less than or equal to the number of rows of the units used to store and process data, or be 1 greater than the number of rows of the units used to store and process data, so at most one row of values ​​is stored in the units used to store data, and in this case, the extra row of values ​​does not need to be convolved with the second sampling result, thereby ensuring the convolution operation between the first sampling result and the second sampling result, and avoiding energy waste and reduced efficiency; similarly, the number of columns of the first sampling result can be less than or equal to the number of columns of the units used to store and process data, or be 1 greater than the number of columns of the units used to store and process data, so at most one column of values ​​is stored in the units used to store data, and in this case, the extra column of values ​​does not need to be convolved with the second sampling result, thereby ensuring the convolution operation between the first sampling result and the second sampling result, and avoiding energy waste and reduced efficiency.

[0111] Among them, step S602 can be performed as follows: Fig. 9 The method shown in the figure includes steps S901 to S903.

[0112] In step S901, for each weight value in the corresponding second sampling result, the processing array is controlled to use a numerical value corresponding to the weight value in the first sampling result to determine a partial sum with the weight value.

[0113] In step S902, the processing array is controlled to determine a partial result according to the partial sums corresponding to the weights in the corresponding second sampling result.

[0114] In step S903, the processing array is controlled to determine a sub-processing result corresponding to the first sampling result according to at least one partial result.

[0115] Among them, step S901 is a repetitive step (i.e., repeated M times, where M is the number of weight values ​​in the corresponding second sampling result), that is, step S901 is executed for each weight value of the second sampling result, so that the partial sum corresponding to each weight value (i.e., the 1st to Mth partial sums) can be obtained in sequence. When determining the partial sum, the first weight value can be multiplied by the corresponding numerical value to obtain it.

[0116] Wherein, step S901 can be performed as follows: for the first weight value in the corresponding second sampling result, control the processing array to determine the partial sum by using the value of the first sampling result in the corresponding unit of the initial position of the processing array and the first weight value; for each non-first weight value in the corresponding second sampling result, determine the moving mode of the first sampling result according to the first value corresponding to the non-first weight value in the first sampling result and the positional relationship of the second value corresponding to the previous weight value of the non-first weight value in the first sampling result, and control the processing array to move the second value to the corresponding unit by using the determined moving mode, and control the processing array to determine the partial sum by using the value in the corresponding unit after the movement and the non-first weight value. For example, if the jth non-first weight value is to the right of the j-1th non-first weight value, the first sampling result is moved one unit to the left relative to the processing array. Since the movement of the first sampling result is performed uniformly as a whole unit (i.e., the operation mode of Single Instruction Multiple Data (SIMD)), each unit sends its stored value to the adjacent unit according to the movement direction during the movement. For example, when the first sampling result is moved one unit to the left relative to the processing array, each unit sends the stored value to the adjacent unit on its left.

[0117] In step S902, when a partial result is obtained according to each partial sum, each partial sum may be summed to obtain the partial result. During execution, the unit stores the partial sum after obtaining it for the first time, and sums it with the stored partial sum each time the unit obtains the partial sum thereafter, and stores the summed result as a new partial sum.

[0118] In step S904, the partial results obtained by the units for storing and processing data may be arranged accordingly according to the positional relationship of each unit to obtain sub-processing results in multiple rows and columns.

[0119] Below Figure 3 The four first sampling results and Figure 5 Taking the four second sampling results shown in the figure as an example, the process of solving the sub-processing results is further described in detail.

[0120] The first sampling result 301 and the second sampling result 501: First, determine A as the first weight value, and keep the initial position when the first sampling result is input into the processing matrix, that is, (1, 1) is stored in the first row and first column of the cells for storing and processing data, (1, 3) is stored in the first row and second column of the cells for storing and processing data, (3, 1) is stored in the second row and first column of the cells for storing and processing data, (3, 3) is stored in the second row and second column of the cells for storing and processing data, the 9th row value (i.e. the last row value) is stored in the first row of the cells for storing data on the lower side of the 8*8 array composed of cells for storing and processing data, and the 9th column value (i.e. the last column value) is stored in the first column on the right side of the 8*8 array composed of cells for storing and processing data. The data is stored in the unit; then each unit for storing and processing data multiplies the stored data with A to obtain a partial sum. Taking the unit for storing and processing data in the first row and first column as an example, the partial sum A*(1, 1) is obtained and stored. Taking the unit for storing and processing data in the first row and second column as an example, the partial sum A*(1, 3) is obtained and stored. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum A*(3, 1) is obtained and stored. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum A*(3, 3) is obtained and stored. The process of obtaining partial sums for other units for storing and processing data will not be repeated one by one, but it should be noted that the units for storing data do not perform calculations, so no partial sums are obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of the convolution operation on the data shown in FIG. 3 with a step size of 2 is an 8*8 data array, that is, during the convolution process, the last row of the first sampling result 301 is only multiplied by the weight values ​​G and I of the second sampling result 501, without multiplying by A and C. During the convolution process, the last column of the first sampling result 301 is only multiplied by the weight values ​​C and I of the second sampling result 501, without multiplying by A and G. Then, for the non-first weight value C, since C is on the right side of A, please refer to the attached Fig.10, the first sampling result is shifted one unit to the left relative to the entire processing array, that is, R1 in the shift register stack of each unit sends its stored data to R1 in the shift register stack of the unit on its left, that is, (1,3) is stored in the first row and first column of the unit for storing and processing data, (1,5) is stored in the first row and second column of the unit for storing and processing data, (3,3) is stored in the second row and first column of the unit for storing and processing data, (3,5) is stored in the second row and second column of the unit for storing and processing data, and the first column value is stored in the first column of the unit for storing data on the left side of the 8*8 array composed of the units for storing and processing data; then each unit for storing and processing data multiplies the stored data with C to obtain a partial sum. Taking the unit for storing and processing data in the first row and first column as an example, the partial sum C*(1,3) is obtained, and after adding it to the original stored partial sum A*(1,1), the latest partial sum A*(1,1)+ C*(1,3) is stored, and taking the unit for storing and processing data in the first row and second column as an example, the partial sum C*(1,5) is obtained, and after adding it to the originally stored partial sum A*(1,3), the latest partial sum A*(1,3)+C*(1,5) is obtained for storage. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum C*(3,3) is obtained, and after adding it to the originally stored partial sum A*(3,1), the latest partial sum A*(3,1)+C*(3,3) is obtained for storage. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum C*(3,5) is obtained, and after adding it to the originally stored partial sum A*(3,3), the latest partial sum A*(3,3)+C*(3,5) is obtained for storage. The process of obtaining partial sums for other units for storing and processing data will not be repeated one by one, but it should be noted that the units used to store data do not perform calculations, so no partial sums are obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of the convolution operation on the data shown in the figure with a step size of 2 is an 8*8 data array, that is, during the convolution process, the first column of the first sampling result 301 is only multiplied by the weight values ​​A and G of the second sampling result 501, without being multiplied by C and I; then for the non-first weight value I, since I is below C, please refer to the attached Fig.11, the first sampling result is moved upward by one unit relative to the processing array as a whole, that is, R1 in the shift register stack of each unit sends its stored data to R1 in the shift register stack of the unit above it, that is, (3, 3) is stored in the first row and first column of the unit for storing and processing data, (3, 5) is stored in the first row and second column of the unit for storing and processing data, (5, 3) is stored in the second row and first column of the unit for storing and processing data, and (5, 5) is stored in the second row and second column of the unit for storing and processing data In the example, the first row of values ​​is stored in the first row of cells for storing data on the upper side of the 8*8 array composed of cells for storing and processing data; then each cell for storing and processing data multiplies the stored data by I to obtain a partial sum. Taking the cell for storing and processing data in the first row and first column as an example, the partial sum I*(3,3) is obtained, and after adding it to the originally stored partial sum A*(1,1)+C*(1,3), the latest partial sum A*(1,1)+C*(1,3)+I*(3,3) is obtained for storage, and the first row and the first column are used as the cells for storing and processing data. Taking the unit for storing and processing data in the second column as an example, the partial sum I*(3, 5) is obtained, and after adding it to the originally stored partial sum A*(1, 3)+C*(1, 5), the latest partial sum A*(1, 3)+C*(1, 5)+I*(3, 5) is obtained for storage. Taking the unit for storing and processing data in the first column of the second row as an example, the partial sum I*(5, 3) is obtained, and after adding it to the originally stored partial sum A*(3, 1)+C*(3, 3), the latest partial sum A*(3, 1)+C*(3, 3)+I*(5,3) for storage. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum I*(5,5) is obtained and added to the originally stored partial sum A*(3,3)+C*(3,5) to obtain the latest partial sum A*(3,3)+C*(3,5)+I*(5,5) for storage. The process of obtaining the partial sums of other units for storing and processing data will not be described in detail. However, it should be noted that the unit for storing data does not perform calculations, so the partial sums are not obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of the convolution operation on the data shown in FIG. 3 with a step size of 2 is an 8*8 data array, that is, during the convolution process, the first row of the first sampling result 301 is only multiplied by the weight values ​​A and C of the second sampling result 501, and does not need to be multiplied by G and I; finally, for the non-first weight value G, since G is on the left side of I, please refer to the attached Fig.12, the first sampling result is shifted one unit to the right relative to the entire processing array, that is, R1 in the shift register stack of each unit sends its stored data to R1 in the shift register stack of the unit to its right, that is, (3, 1) is stored in the first row and first column of the unit for storing and processing data, (3, 3) is stored in the first row and second column of the unit for storing and processing data, (5, 1) is stored in the second row and first column of the unit for storing and processing data, (5, 3) is stored in the second row and second column of the unit for storing and processing data, and the last column value is stored in the unit for storing and processing data. The first row on the upper side of the 8*8 array composed of elements is used to store data; then each unit for storing and processing data multiplies the stored data with G to obtain a partial sum. Taking the unit for storing and processing data in the first row and first column as an example, the partial sum G*(3,1) is obtained, and after adding it to the originally stored partial sum A*(1,1)+C*(1,3)+I*(3,3), the partial result A*(1,1)+C*(1,3)+I*(3,3)+G*(3,1) of the unit for storing and processing data in the first row and first column is obtained for storage. Taking the unit for processing data as an example, the partial sum G*(3,3) is obtained, and after adding it to the originally stored partial sum A*(1,3)+C*(1,5)+I*(3,5), the latest partial sum A*(1,3)+C*(1,5)+I*(3,5)+G*(3,3) is stored. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum G*(5,1) is obtained, and after adding it to the originally stored partial sum A*(3,1)+C*(3,3)+I*(5,3), the latest partial sum A*(3,1)+C*(3,3)+I *(5,3)+G*(5,1) is used for storage. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum I*(5,3) is obtained, and after adding it to the originally stored partial sum A*(3,3)+C*(3,5)+I*(5,5), the latest partial sum A*(3,3)+C*(3,5)+I*(5,5)+I*(5,3) is obtained for storage. The process of obtaining the partial sum of other units for storing and processing data will not be repeated one by one. However, it should be noted that the unit for storing data does not perform calculations, so no partial sum is obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of performing convolution operation on the data shown with a step size of 2 is an 8*8 data array. Finally, the partial results of all units used to store and process data are arranged as needed to obtain the sub-processing result corresponding to the first sampling result 301.

[0121] The first sampling result 302 and the second sampling result 502: First, determine B as the first weight value, and keep the initial position when the first sampling result is input into the processing matrix, that is, (1, 2) is stored in the first row and first column of the cells for storing and processing data, (1, 4) is stored in the first row and second column of the cells for storing and processing data, (3, 2) is stored in the second row and first column of the cells for storing and processing data, (3, 4) is stored in the second row and second column of the cells for storing and processing data, and the 9th row value (i.e. the last row value) is stored in the first row of the cells for storing data on the lower side of the 8*8 array composed of the cells for storing and processing data; then each cell for storing and processing data stores the stored The data is multiplied by B to obtain a partial sum. Taking the unit for storing and processing data in the first row and first column as an example, the partial sum B*(1, 2) is obtained and stored. Taking the unit for storing and processing data in the first row and second column as an example, the partial sum B*(1, 4) is obtained and stored. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum B*(3, 2) is obtained and stored. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum B*(3, 4) is obtained and stored. The process of obtaining the partial sum of other units for storing and processing data will not be repeated one by one, but it should be noted that the units for storing data are not operated, so no partial sum is obtained. This is because Figure 4 The convolution kernel shown in Figure 2The result of the convolution operation on the data shown in the figure with a step size of 2 is an 8*8 data array, that is, during the convolution process, the last row of the first sampling result 302 is only multiplied by the weight value H of the second sampling result 502, and does not need to be multiplied by B; then for H, which is not the first weight value, since H is on the lower side of B, the first sampling result is moved one unit upward relative to the processing array as a whole, that is, the R1 unit in each shift register stack sends its stored data to the R1 in the shift register stack of the unit on its upper side, that is, (3, 2) is stored in the first row and first column for storing and processing data. The first row of values ​​is stored in the first row of the 8*8 array of cells for storing and processing data. Then, each cell for storing and processing data multiplies the stored data with H to obtain a partial sum. Taking the first row and first column of cells for storing and processing data as an example, the partial sum H is obtained. *(3,2), and after adding it to the originally stored partial sum B*(1,2), the partial result B*(1,2)+H*(3,2) of the first row and first column unit for storing and processing data is obtained for storage. Taking the first row and second column unit for storing and processing data as an example, the partial sum H*(3,4) is obtained, and after adding it to the originally stored partial sum B*(1,4), the latest partial sum B*(1,4)+H*(3,4) is obtained for storage. Taking the second row and first column unit for storing and processing data as an example, the partial sum H*(5,2) is obtained, and added to the originally stored partial sum B*(1,4)+H*(3,4). After adding the stored partial sums B*(3,2), the latest partial sum B*(3,2)+H*(5,2) is obtained for storage. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum H*(5,4) is obtained, and after adding it to the originally stored partial sum B*(3,4), the latest partial sum B*(3,4)+H*(5,4) is obtained for storage. The process of obtaining partial sums in other units for storing and processing data will not be repeated one by one, but it should be noted that the unit for storing data does not perform calculations, so no partial sums are obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of the convolution operation with a step size of 2 on the data shown is an 8*8 data array, that is, during the convolution process, the first row of the first sampling result 302 is only multiplied by the weight value B of the second sampling result 502, and does not need to be multiplied by H; finally, the partial results of all the units used to store and process data are arranged as needed to obtain the sub-processing results corresponding to the first sampling result 302.

[0122] The first sampling result 303 and the second sampling result 503: First, determine D as the first weight value, and keep the initial position when the first sampling result is input into the processing matrix, that is, (2, 1) is stored in the first row and first column of the cells for storing and processing data, (2, 3) is stored in the first row and second column of the cells for storing and processing data, (4, 1) is stored in the second row and first column of the cells for storing and processing data, (4, 3) is stored in the second row and second column of the cells for storing and processing data, and the 9th column value (i.e. the last column value) is stored in the first column of the cells for storing data on the right side of the 8*8 array composed of the cells for storing and processing data; then each cell for storing and processing data stores the stored The data is multiplied by D to obtain a partial sum. Taking the unit for storing and processing data in the first row and first column as an example, the partial sum D*(2, 1) is obtained and stored. Taking the unit for storing and processing data in the first row and second column as an example, the partial sum D*(2, 3) is obtained and stored. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum D*(4, 1) is obtained and stored. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum D*(4, 3) is obtained and stored. The process of obtaining the partial sum of other units for storing and processing data will not be repeated one by one, but it should be noted that the units for storing data are not operated, so no partial sum is obtained. This is because Figure 4 The convolution kernel shown in Figure 2The result of the convolution operation on the data shown in the figure with a step size of 2 is an 8*8 data array, that is, during the convolution process, the last column of the first sampling result 303 is only multiplied by the weight value F of the second sampling result 503, and does not need to be multiplied by D; then for F, which is not the first weight value, since F is on the right side of D, the first sampling result is shifted one unit to the left relative to the entire processing array, that is, R1 in the shift register stack of each unit sends its stored data to R1 in the shift register stack of the unit on its left, that is, (2, 3) is stored in the first row and first column for storing and In the data processing unit, (2, 5) is stored in the first row and second column of the data storage and processing unit, (4, 3) is stored in the second row and first column of the data storage and processing unit, (4, 5) is stored in the second row and second column of the data storage and processing unit, and the first column value is stored in the first column of the data storage unit on the left side of the 8*8 array composed of the data storage and processing units; then each unit multiplies the stored data with F to obtain a partial sum. Taking the first row and first column of the data storage and processing unit as an example, the partial sum F*(2, 3 ), and after adding it to the originally stored partial sum D*(2,1), the partial result D*(2,1)+F*(2,3) of the first row and first column of the unit for storing and processing data is obtained for storage. Taking the first row and second column of the unit for storing and processing data as an example, the partial sum F*(2,5) is obtained, and after adding it to the originally stored partial sum D*(2,3), the latest partial sum D*(2,3)+F*(2,5) is obtained for storage. Taking the second row and first column of the unit for storing and processing data as an example, the partial sum F*(4,3) is obtained, and added to the originally stored After adding the partial sum D*(4,1), the latest partial sum D*(4,1)+F*(4,3) is obtained for storage. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum F*(4,5) is obtained, and after adding it to the originally stored partial sum D*(4,3), the latest partial sum D*(4,3)+F*(4,5) is obtained for storage. The process of obtaining the partial sum of other units for storing and processing data will not be repeated one by one, but it should be noted that the unit for storing data does not perform calculations, so no partial sum is obtained. This is because Figure 4 The convolution kernel shown in Figure 2 The result of the convolution operation with a step size of 2 on the data shown is an 8*8 data array, that is, during the convolution process, the first column of the first sampling result 303 is only multiplied by the weight value D of the second sampling result 503, and does not need to be multiplied by F; finally, the partial results of all the units used to store and process data are arranged as needed to obtain the sub-processing results corresponding to the first sampling result 303.

[0123] The first sampling result 304 and the second sampling result 504: First, determine E as the first weight value, and keep the initial position of the first sampling result when it is input into the processing matrix, that is, (2, 2) is stored in the first row and first column of cells for storing and processing data, (2, 4) is stored in the first row and second column of cells for storing and processing data, (4, 1) is stored in the second row and first column of cells for storing and processing data, and (4, 4) is stored in the second row and second column of cells for storing and processing data; then each cell multiplies the stored data with E to obtain a partial sum. Taking the first row and first column of cells for storing and processing data as an example, the first row and first column of cells for storing and processing data are obtained. The partial result E*(2, 2) of the unit for storing and processing data is stored. Taking the unit for storing and processing data in the first row and second column as an example, the partial sum E*(2, 4) is obtained and stored. Taking the unit for storing and processing data in the second row and first column as an example, the partial sum E*(4, 2) is obtained and stored. Taking the unit for storing and processing data in the second row and second column as an example, the partial sum E*(4, 4) is obtained and stored. The process of obtaining the partial sum of other units for storing and processing data will not be repeated one by one. Finally, the partial results of all units for storing and processing data are arranged as needed to obtain the sub-processing result corresponding to the first sampling result 304.

[0124] Among them, step S603 can be performed in the following manner: multiple sub-processing results are summed to obtain the processing result. Since the sub-processing results are partial results of multiple rows and columns, and the number of rows and columns of each sub-processing result is equal (this is because the number of rows and columns of the units used to store and process data is equal), the partial results of the corresponding positions are added, and the sum obtained at each position is used as the processing result, that is, the sum of the partial sums obtained by the units used to store and process data is summed to obtain the value of the unit, and the value of each unit constitutes the processing result. For example, the above Figure 3 and Figure 5In the example, the cells in the first row and first column used to store and process data obtain a total of four partial sums. These four partial sums are added together to obtain the value of the corresponding position of the cell in the processing result, that is, A*(1,1)+C*(1,3)+I*(3,3)+G*(3,1)+B*(1,2)+H*(3,2)+D*(2,1)+F*(2,3)+E*(2,2), and the cells in the first row and second column used to store and process data obtain a total of four partial sums. These four partial sums are added together to obtain the value of the corresponding position of the cell in the processing result, that is, A*(1,3)+C*(1,5)+I*(3,5)+G*(3,3)+B*(1,4)+H*(3,4)+D*(2,3)+F*(2,5)+E*(2,4 ); the second row, first column, units used to store and process data obtain a total of four partial sums. These four partial sums are added together to obtain the value of the corresponding position of the unit in the processing result, namely A*(3,1)+C*(3,3)+I*(5,3)+G*(5,1)+B*(3,2)+H*(5,2)+D*(4,1)+F*(4,3)+E*(4,2); the second row, second column, units used to store and process data obtain a total of four partial sums. These four partial sums are added together to obtain the value of the corresponding position of the unit in the processing result, namely A*(3,3)+C*(3,5)+I*(5,5)+I*(5,3)+B*(3,4)+H*(5,4)+D*(4,3)+F*(4,5)+E*(4,4).

[0125] In some embodiments of the present disclosure, the data to be processed is obtained based on the data of the image. In order to make the first sampling result after sampling of the data to be processed match the processing array, the data to be processed can be obtained in the following manner: first, the number of rows and columns of the data to be processed is determined according to the processing array, the convolution kernel and the step size; next, the number of overlapping rows and the number of overlapping columns are determined according to the convolution kernel and the step size; finally, according to the number of rows and columns of the data to be processed, the number of overlapping rows and the number of overlapping columns, the data of the image to be processed is sampled to obtain multiple data to be processed.

[0126] The number of overlapping rows and the number of overlapping columns may also be equal, and the number of overlapping rows and the number of overlapping columns P may be determined in the following manner:

[0127] P=KS, where K is the number of rows of the convolution kernel (the number of rows and the number of columns are equal), and S is the step size of the convolution operation. In addition, K is greater than or equal to S.

[0128] The number of rows and columns of the data to be processed may be equal, and the number of rows and columns L of the data to be processed may be determined in the following manner:

[0129] L=S*a+P, where S is the step size of the convolution operation, and a is the number of rows of units used to store and process data (the number of rows and the number of columns are equal).

[0130] like Fig.13 As shown, when sampling the data of the image to be processed, a sampling frame of L*L is placed at the upper left corner of the data of the image to be processed, the data in the sampling frame is taken as the first data to be processed, and then the sampling frame is moved to the right by LP, the data in the sampling frame is taken as the second data to be processed, and then the sampling frame is moved to the right by LP and sampled again until the sampling frame cannot be moved to the right by LP, and then the sampling frame is moved downward by LP from the position of the upper left corner for sampling, and then the first row sampling process is repeated. After the second row sampling is completed, LP is continued to be moved downward until LP cannot be moved downward any further, and after each movement, the new row is sampled in accordance with the first row.

[0131] According to a second aspect of an embodiment of the present invention, there is provided a data processing device, the device comprising:

[0132] A controller, configured to sample the data to be processed according to a step length of a convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1; sample the convolution kernel according to the step length of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result and the at least one second sampling result have a one-to-one correspondence; and input the at least one first sampling result and the at least one second sampling result to a processing array correspondingly;

[0133] The processing array is used to process the at least one first sampling result and the at least one second sampling result, and output the processing results.

[0134] In some embodiments of the present disclosure, the controller is used to perform row sampling on the data to be processed according to the step size to obtain at least one first row sampling result, wherein the union of the at least one first row sampling result is the data to be processed; perform column sampling on the data to be processed according to the step size to obtain at least one first column sampling result, wherein the union of the at least one first column sampling result is the data to be processed; and respectively determine the intersection of each first row sampling result and each first column sampling result as the first sampling result.

[0135] In some embodiments of the present disclosure, the controller is used to perform row sampling on the convolution kernel according to the step size to obtain at least one second row sampling result, wherein the union of the at least one second row sampling result is the convolution kernel; perform column sampling on the convolution kernel according to the step size to obtain at least one second column sampling result, wherein the union of the at least one second column sampling result is the data to be processed; and respectively determine the intersection of each second row sampling result and each second column sampling result as the second sampling result.

[0136] In some embodiments of the present disclosure, the controller is used to input each first sampling result into the processing array, and input a second sampling result corresponding to the first sampling result into the processing array; and

[0137] The processing array is used to determine the corresponding sub-processing result according to the first sampling result and the corresponding second sampling result; and output the processing result according to the sub-processing result corresponding to each first sampling result.

[0138] In some embodiments of the present disclosure, the controller is used to input multiple numerical values ​​of each first sampling result into multiple units of the processing array, so that the relative positions of the multiple numerical values ​​in the multiple units are the same as the relative positions of the multiple numerical values ​​in the first sampling result.

[0139] In some embodiments of the present disclosure, the processing array includes an effective array, at least one overflow row and at least one overflow column distributed around the effective array, wherein the effective array includes a plurality of units for storing and processing data, and the overflow row and the overflow column include a plurality of units for storing data;

[0140] The controller is used to input multiple values ​​of the first sampling result into multiple units of the processing array, so that the values ​​of the first row and first column of the first sampling result are input into the first row and first column of the unit for storing and processing data.

[0141] In some embodiments of the present disclosure, the processing array is used to determine a partial sum with a numerical value corresponding to the weight value in the first sampling result and the weight value for each weight value in the corresponding second sampling result;

[0142] Determine a partial result according to the partial sums corresponding to the weight values ​​in the corresponding second sampling result; and

[0143] A sub-processing result corresponding to the first sampling result is determined according to the at least one partial result.

[0144] In some embodiments of the present disclosure, the processing array is used to determine a partial sum for a first weight value in a corresponding second sampling result by using a value of the first sampling result in a cell corresponding to an initial position of the processing array and the first weight value.

[0145] In some embodiments of the present disclosure, the controller is used to determine, for each non-first weight value in the corresponding second sampling result, a moving mode of the first sampling result according to a first numerical value corresponding to the non-first weight value in the first sampling result and a positional relationship in the first sampling result between a second numerical value corresponding to a previous weight value of the non-first weight value in the first sampling result;

[0146] The processing array is used to move the second value to the corresponding unit in a determined moving manner; and determine the partial sum by using the value in the corresponding unit after the move and the non-first weight value.

[0147] In some embodiments of the present disclosure, the controller is further used to determine the number of rows and columns of the data to be processed according to the processing array, the convolution kernel and the step size; determine the number of overlapping rows and columns according to the convolution kernel and the step size; and sample the data of the image to be processed according to the number of rows and columns of the data to be processed, the number of overlapping rows and the number of overlapping columns to obtain multiple data to be processed.

[0148] In some embodiments of the present disclosure, the data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel.

[0149] Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the first aspect related to the method, and will not be elaborated here.

[0150] The data processing device provided in the embodiments of the present disclosure may include a chip, an AI chip, etc.

[0151] In a third aspect, at least one embodiment of the present invention provides an electronic device, please refer to the attached Fig.14 , which shows the structure of the device, the device includes a memory, a processor, and a data processing device provided in an embodiment of the present application. The memory is used to store computer instructions that can be executed on the processor, and the processor is used to process data based on the method described in the first aspect when executing the computer instructions.

[0152] In a fourth aspect, at least one embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in the first aspect.

[0153] In the present invention, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance. The term "plurality" refers to two or more than two, unless otherwise clearly defined.

[0154] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the disclosure disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0155] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A data processing method, characterized in that: The method comprises: Sampling the data to be processed according to a step length of the convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1; Sampling the convolution kernel according to the step size of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result corresponds to the at least one second sampling result in one-to-one correspondence; Input the at least one first sampling result and the at least one second sampling result to the processing array accordingly, so that the processing array outputs the processing result; The step of inputting the at least one first sampling result and the at least one second sampling result into a corresponding processing array so that the processing array outputs a processing result comprises: For each first sampling result, the first sampling result is input into the processing array, and a second sampling result corresponding to the first sampling result is input into the processing array; and Controlling the processing array to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result; Controlling the processing array to output a processing result according to the sub-processing results respectively corresponding to each first sampling result; For each first sampling result, inputting the first sampling result into the processing array comprises: For each first sampling result, input multiple values ​​of the first sampling result into multiple units of the processing array so that relative positions of the multiple values ​​in the multiple units are the same as relative positions of the multiple values ​​in the first sampling result; The processing array includes an active array, at least one overflow row and at least one overflow column distributed around the active array, wherein the active array includes a plurality of cells for storing and processing data, and the overflow row and the overflow column include a plurality of cells for storing data; The step of inputting the multiple values ​​of the first sampling result into the multiple units of the processing array includes: The multiple values ​​of the first sampling result are input into the multiple units of the processing array, so that the values ​​of the first row and first column of the first sampling result are input into the first row and first column of the unit for storing and processing data.

2. The data processing method according to claim 1, characterized in that: The step of sampling the data to be processed according to the step size of the convolution operation to obtain at least one first sampling result includes: Performing row sampling on the data to be processed according to the step length to obtain at least one first row sampling result, wherein a union of the at least one first row sampling result is the data to be processed; Performing column sampling on the data to be processed according to the step length to obtain at least one first column sampling result, wherein a union of the at least one first column sampling result is the data to be processed; The intersection of each of the first row sampling results and each of the first column sampling results is determined as the first sampling result.

3. The data processing method according to claim 1, characterized in that: The step of sampling the convolution kernel according to the step size of the convolution operation to obtain at least one second sampling result includes: Performing row sampling on the convolution kernel according to the step size to obtain at least one second row sampling result, wherein a union of the at least one second row sampling result is the convolution kernel; Performing column sampling on the convolution kernel according to the step size to obtain at least one second column sampling result, wherein a union of the at least one second column sampling result is the data to be processed; The intersection of each second row sampling result and each second column sampling result is determined as the second sampling result.

4. The data processing method according to claim 1, characterized in that: The controlling the processing array to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result includes: For each weight value in the corresponding second sampling result, control the processing array to use the value corresponding to the weight value in the first sampling result to determine a partial sum with the weight value; Control the processing array to determine a partial result according to the partial sums corresponding to the weight values ​​in the corresponding second sampling result; The processing array is controlled to determine a sub-processing result corresponding to the first sampling result according to at least one partial result.

5. The data processing method according to claim 4, characterized in that: The step of controlling the processing array to use a numerical value corresponding to the weight value in the first sampling result and determining a partial sum with the weight value for each weight value in the corresponding second sampling result includes: For a first weight value in the corresponding second sampling result, the processing array is controlled to determine a partial sum by using a value of the first sampling result in a cell corresponding to an initial position of the processing array and the first weight value.

6. The data processing method according to claim 4 or 5, characterized in that: The step of controlling the processing array to use a numerical value corresponding to the weight value in the first sampling result and determining a partial sum with the weight value for each weight value in the corresponding second sampling result includes: For each non-first weight value in the corresponding second sampling result, according to the first numerical value corresponding to the non-first weight value in the first sampling result and the positional relationship in the first sampling result between the second numerical value corresponding to the previous weight value of the non-first weight value in the first sampling result, determining a moving mode of the first sampling result, and controlling the processing array to move the second numerical value to the corresponding unit using the determined moving mode; The processing array is controlled to use the value in the corresponding unit after the shift and the non-first weight value to determine the partial sum.

7. The data processing method according to claim 1, characterized in that: Also includes: Determining the number of rows and columns of the data to be processed according to the processing array, the convolution kernel and the step size; Determine the number of overlapping rows and overlapping columns according to the convolution kernel and the step size; The data of the image to be processed are sampled according to the number of rows and columns of the data to be processed, the number of overlapping rows, and the number of overlapping columns to obtain a plurality of data to be processed.

8. The data processing method according to claim 1, characterized in that: The data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel.

9. A data processing device, characterized in that: The device comprises: A controller, configured to sample the data to be processed according to a step length of a convolution operation to obtain at least one first sampling result, wherein the step length is greater than 1; sample the convolution kernel according to the step length of the convolution operation to obtain at least one second sampling result, wherein the at least one first sampling result and the at least one second sampling result have a one-to-one correspondence; and input the at least one first sampling result and the at least one second sampling result to a processing array correspondingly; The processing array is used to process the at least one first sampling result and the at least one second sampling result, and output the processing result; The controller is used for inputting each first sampling result into the processing array, and inputting a second sampling result corresponding to the first sampling result into the processing array; and The processing array is used to determine a corresponding sub-processing result according to the first sampling result and the corresponding second sampling result; and output a processing result according to the sub-processing result corresponding to each first sampling result; The controller is used for inputting, for each first sampling result, a plurality of values ​​of the first sampling result into a plurality of units of the processing array, so that relative positions of the plurality of values ​​in the plurality of units are the same as relative positions of the plurality of values ​​in the first sampling result; The processing array includes an active array, at least one overflow row and at least one overflow column distributed around the active array, wherein the active array includes a plurality of cells for storing and processing data, and the overflow row and the overflow column include a plurality of cells for storing data; The controller is used to input multiple values ​​of the first sampling result into multiple units of the processing array, so that the values ​​of the first row and first column of the first sampling result are input into the first row and first column of the unit for storing and processing data.

10. The data processing device according to claim 9, characterized in that: The controller is used to perform row sampling on the data to be processed according to the step size to obtain at least one first row sampling result, wherein the union of the at least one first row sampling result is the data to be processed; perform column sampling on the data to be processed according to the step size to obtain at least one first column sampling result, wherein the union of the at least one first column sampling result is the data to be processed; and determine the intersection of each first row sampling result and each first column sampling result as the first sampling result.

11. The data processing device according to claim 9, characterized in that: The controller is used to perform row sampling on the convolution kernel according to the step size to obtain at least one second row sampling result, wherein the union of the at least one second row sampling result is the convolution kernel; perform column sampling on the convolution kernel according to the step size to obtain at least one second column sampling result, wherein the union of the at least one second column sampling result is the data to be processed; and respectively determine the intersection of each second row sampling result and each second column sampling result as the second sampling result.

12. The data processing device according to claim 9, characterized in that: The processing array is used to determine a partial sum with a numerical value corresponding to the weight value in the first sampling result and the weight value for each weight value in the corresponding second sampling result; Determine a partial result according to the partial sums corresponding to the weight values ​​in the corresponding second sampling result; as well as A sub-processing result corresponding to the first sampling result is determined according to the at least one partial result.

13. The data processing device according to claim 12, characterized in that: The processing array is used to determine a partial sum for a first weight value in a corresponding second sampling result by using a value of the first sampling result in a cell corresponding to an initial position of the processing array and the first weight value.

14. The data processing device according to claim 12 or 13, characterized in that: The controller is used to determine, for each non-first weight value in the corresponding second sampling result, a moving mode of the first sampling result according to a first numerical value corresponding to the non-first weight value in the first sampling result and a positional relationship in the first sampling result between a second numerical value corresponding to a previous weight value of the non-first weight value in the first sampling result; The processing array is used to move the second value to a corresponding unit using a determined moving method; The partial sum is determined by using the numerical value in the corresponding unit after the move and the non-first weight value.

15. The data processing device according to claim 9, characterized in that: The controller is further used to determine the number of rows and columns of the data to be processed according to the processing array, the convolution kernel and the step size; and determine the number of overlapping rows and overlapping columns according to the convolution kernel and the step size; The data of the image to be processed are sampled according to the number of rows and columns of the data to be processed, the number of overlapping rows, and the number of overlapping columns to obtain a plurality of data to be processed.

16. The data processing device according to claim 9, characterized in that: The data to be processed is single-channel data or one channel in multi-channel data, and the convolution kernel is a single-channel convolution kernel or one channel in a multi-channel convolution kernel.

17. An electronic device, characterized in that: The device comprises a memory, a processor, and the apparatus according to any one of claims 9 to 16.

18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Winograd convolution splitting method for convolutional neural network accelerator

    CN110533164A