Data processing method and device, processor, electronic device and storage medium
By loading the output gradient tensor from the memory to the processor cache component during the back propagation process of the neural network, and using the data block to calculate the input gradient matrix, the problem of low computational efficiency of channel-by-channel convolution back propagation is solved and the calculation efficiency is improved. performance.
Patent Information
- Application Number
- CN202410947731.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-16
AI Technical Summary
In the back propagation process of neural networks, the calculation efficiency of back propagation of channel-by-channel convolution is low, especially when the size of the input gradient tensor is large, the limitation of shared memory makes it impossible to load it as a whole, resulting in low memory access efficiency. , performance drops significantly.
By loading the output gradient tensor from the memory to the cache component of the processor, the backpropagation calculation of the channel-by-channel convolution is performed in units of data blocks, and some elements in the output gradient matrix are used to calculate the corresponding elements in the input gradient matrix to reduce loading duplication. For data points, a cache component is introduced to cache input gradient tensors, and a hierarchical storage structure is used to speed up data loading.
It improves data loading and calculation efficiency, reduces the calculation amount of coordinate points, avoids loading a large amount of duplicate data, improves performance and efficiency, and achieves more efficient batch data processing.
Smart Images

Figure CN118503600B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a data processing method, a data processing method apparatus, a processor, an electronic device, and a non-transitory computer-readable storage medium. Background Art
[0002] The forward operator and the reverse operator of the DepthWise Separable Convolution are two key processes involved in neural network training.
[0003] During the forward propagation of the neural network, the forward operator (Forward Pass / Propagation) performs the following operations: split the standard convolution into two steps: channel-wise convolution (DepthWise Convolution) and pointwise convolution (PointwiseConvolution) for convolution operations. During the back propagation of the neural network, the backward operator (BackwardPass / Propagation) is used to calculate the gradient and update the weights. Backward propagation includes the following steps: calculate the gradient of the loss function with respect to the output feature map (i.e., the error signal); use this gradient and the weights of pointwise convolution and channel-wise convolution to calculate the gradient of the loss function with respect to the weights and biases through the chain rule; update the weights and biases to minimize the loss function. During the back propagation process, the backward operator is responsible for calculating the gradients and propagating them back to the network for weight updates.
[0004] Compared with standard convolution, depthwise separable convolution can greatly reduce the number of parameters and computation, and is more computationally efficient. Summary of the invention
[0005] At least one embodiment of the present disclosure provides a data processing method for loading an output gradient tensor from a memory into a cache unit of a processor to perform back propagation calculation of channel-by-channel convolution to obtain an input gradient tensor, wherein the output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers, and the elements in the output gradient matrix are array-divided into a plurality of data blocks of a size of w×h, w and h are positive integers greater than 1. The back propagation calculation of the channel-by-channel convolution includes determining an input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and a corresponding convolution kernel, wherein the size of the convolution kernel is 3×3, the step size of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H. The data processing method includes: for each output gradient matrix, in response to calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, loading all elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache unit in units of data blocks, wherein n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h; using the elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix, calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix.
[0006] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, loading the elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of data blocks, including: in response to n=0, loading the elements from the 1st row to the 2×hth row in the output gradient matrix to the cache component in units of data blocks; in response to n being greater than or equal to 2×h, loading the elements from the n / 2+h+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of data blocks, and retaining the elements from the n / 2+1th row to the n / 2+hth row in the output gradient matrix that have been loaded into the cache component.
[0007] For example, in the data processing method provided by at least one embodiment of the present disclosure, the elements from the n+1th row to the n+2×hth row in the input gradient matrix obtained by the back propagation calculation of the channel-by-channel convolution are divided into multiple data blocks of size w×h, and the data processing method further includes: storing the elements from the n+1th row to the n+2×hth row in the input gradient matrix in the memory in units of data blocks.
[0008] For example, in the data processing method provided by at least one embodiment of the present disclosure, W is less than or equal to Wm, Wm is determined according to h, the storage capacity of the cache component, and the data type of the elements in the output gradient tensor, and Wm is a positive number.
[0009] For example, in the data processing method provided in at least one embodiment of the present disclosure, Wm is calculated according to the following formula:
[0010] Wm=Size / (e×2×h×D)
[0011] Among them, Size represents the capacity of the cache component, e represents the number of execution units sharing the cache component in the same computing unit, and D represents the size of the element data type in the output gradient tensor.
[0012] For example, in the data processing method provided by at least one embodiment of the present disclosure, the elements cached in the cache component are loaded into the register for calculation when performing gradient calculation on the cached elements.
[0013] For example, in the data processing method provided by at least one embodiment of the present disclosure, the cache component includes a shared memory.
[0014] For example, in the data processing method provided by at least one embodiment of the present disclosure, the data blocks loaded into the cache component are all loaded into the same storage area of fixed capacity in the cache component.
[0015] At least one embodiment of the present disclosure provides a processor, comprising an instruction parsing unit, an execution unit, a cache component and a memory, wherein the instruction parsing unit is used to receive and parse data processing instructions, wherein the data processing instructions are used to load an output gradient tensor from the memory to the cache component of the processor to perform a back propagation calculation of a channel-by-channel convolution to obtain an input gradient tensor, and the execution unit executes the data processing method according to any embodiment of the present disclosure after the instruction parsing unit parses the data processing instructions.
[0016] At least one embodiment of the present disclosure provides a data processing device, which is used to load an output gradient tensor from a memory into a cache unit of a processor to perform back propagation calculation of channel-by-channel convolution to obtain an input gradient tensor, wherein the output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers, and the elements in the output gradient matrix are array-divided into a plurality of data blocks of a size of w×h, w and h are positive integers greater than 1. The back propagation calculation of the channel-by-channel convolution includes determining an input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and a corresponding convolution kernel, wherein the size of the convolution kernel is 3×3, the step size of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H. The data processing device includes: a loading module configured to, for each output gradient matrix, in response to calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, load all elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache unit in units of data blocks, wherein n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h; and a calculation module configured to calculate the elements from the n+1th row to the n+2×hth row in the input gradient matrix using the elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix.
[0017] At least one embodiment of the present disclosure provides an electronic device, comprising: a memory, which non-transitorily stores computer-executable instructions; and a processor, which is configured to execute the computer-executable instructions, wherein the computer-executable instructions, when executed by the processor, implement the data processing method according to any embodiment of the present disclosure.
[0018] At least one embodiment of the present disclosure provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the data processing method according to any embodiment of the present disclosure is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below. Obviously, the drawings in the following description only relate to some embodiments of the present disclosure, but are not intended to limit the present disclosure.
[0020] Figure 1 A schematic diagram of a channel-by-channel convolution;
[0021] Figure 2 A schematic structural diagram of a general-purpose graphics processing unit (GPGPU);
[0022] Figure 3A schematic flow chart of a data processing method provided for at least one embodiment of the present disclosure;
[0023] Figure 4 A schematic diagram showing the relationship between the input gradient matrix and the output gradient matrix;
[0024] Figure 5 A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure;
[0025] Figure 6 A schematic structural diagram of a processor provided for at least one embodiment of the present disclosure;
[0026] Figure 7 A schematic block diagram of an electronic device provided in accordance with an embodiment of the present disclosure;
[0027] Figure 8 A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0029] Unless otherwise defined, the technical terms or scientific terms used in the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly. In order to keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits the detailed description of some known functions and known components.
[0030] Channel-by-channel convolution is a two-dimensional convolution in which the convolution kernel is applied to the input feature map of each channel separately without changing the number of channels.
[0031] Figure 1 is a schematic diagram of channel-by-channel convolution, such as Figure 1 As shown, assuming that the input gradient tensor includes input feature maps of 3 channels, each channel has a corresponding convolution kernel, the number of convolution kernels is the same as the number of channels of the input gradient tensor and is 3, and each input feature map is convolved with the corresponding convolution kernel in a two-dimensional plane, as shown in Figure 1 As shown in the figure, a 3-channel output feature map is generated through channel-by-channel convolution.
[0032] During the back propagation process of channel-by-channel convolution, we first need to calculate the error terms corresponding to each element on each output feature map. These error terms are the partial derivatives of the loss function with respect to each element of the output feature map. Then, we perform back propagation calculations for channel-by-channel convolution, including using the chain rule to calculate the gradient of the loss function with respect to the convolution kernel parameters. Finally, based on the calculated gradient, we use optimization algorithms such as gradient descent to update the weight parameters of the convolution kernel to minimize the loss function.
[0033] The forward propagation operator of the channel-by-channel convolution is usually responsible for performing convolution operations on the input feature map. The back propagation operator of the channel-by-channel convolution is usually responsible for calculating the input gradient according to the output gradient and propagating the input gradient back to the network for weight update.
[0034] Figure 2 A schematic structural diagram of a general-purpose graphics processing unit (GPGPU).
[0035] like Figure 2 As shown, the general-purpose graphics processor is actually an array of programmable multiprocessors. For example, the programmable multiprocessor can be a streaming processor cluster (SPC), for example, including Figure 1 The stream processor clusters 1, ..., and stream processor cluster M are shown, where M is a positive integer greater than 1. In a general-purpose graphics processor, one stream processor cluster processes one computing task, or multiple stream processor clusters process one computing task. Multiple stream processor clusters share data through a global cache or a global memory.
[0036] like Figure 2 As shown, taking stream processor cluster 1 as an example, one stream processor cluster includes multiple computing units, such as Figure 2In the figure, there are computing units 1, 2, ..., N, where N is a positive integer. Each computing unit (CU) is used to perform arithmetic and logical operations, such as accumulation, reduction, conventional addition, subtraction, multiplication, and division. A computing unit includes multiple cores (also called computing cores or computing cores), each of which includes an arithmetic logic unit (ALU), a floating-point computing unit, etc. The computing core is used to perform specific computing tasks. In addition, the computing unit also includes registers (e.g. Figure 2 The register file in the computing unit and the shared memory are used to hierarchically store source data and destination data related to computing tasks. The shared memory in a computing unit is used to share data between the cores of the computing unit.
[0037] In parallel computing, computing tasks are generally performed by multiple threads. These threads are divided into multiple thread blocks before being executed in a general-purpose graphics processor (or parallel computing processor), and then distributed through the thread block distribution module ( Figure 2 The CPU (not shown) distributes multiple thread blocks to each computing unit. All threads in a thread block must be assigned to the same computing unit for execution. At the same time, the thread block is split into minimum execution thread bundles (or simply thread bundles, warps), each of which contains a fixed number of threads (or less than this fixed number), for example, 32 threads. Multiple thread blocks can be executed in the same computing unit or in different computing units.
[0038] In each compute unit, the warp scheduling / dispatching module ( Figure 2 The thread warps are scheduled and allocated (not shown) so that multiple computing cores of the computing unit can run the thread warps. Depending on the number of computing cores in the computing unit, multiple thread warps in a thread block can be executed simultaneously or in time-sharing. Multiple threads in each thread warp will execute the same instruction. The memory execution instruction will be emitted to the shared memory in the computing unit or further emitted to the intermediate level cache or global cache or global memory for read and write operations, etc.
[0039] When using a general-purpose graphics processor to perform back propagation calculations for channel-by-channel convolution, a common implementation method is to load the required output gradient tensor (activation) into shared memory or registers, load the weight parameters of the convolution layer into registers, and then manually perform multiplication to perform single-channel back propagation calculations, thereby implementing the reverse operator.
[0040] Processor (e.g. Figure 2In the process of convolution calculation using the general-purpose graphics processor shown in the figure, it is more efficient to use data blocks as units for data storage, loading and calculation. For example, the two-dimensional input feature map of each channel in the input gradient tensor can be divided into data blocks of the same size for loading, calculation and storage, so that batch data processing instructions can be used for loading, storage and calculation. In terms of memory usage, the better the continuity of the memory address accessed by the program, the higher the program access efficiency, and the storage addresses of each element in the same data block are continuous, so it is more efficient to use batch data processing instructions for data loading and data storage. For example, batch data loading instructions (LDM, Load Much) can be used for data loading, which is more efficient than using data loading methods for single elements (pixels) (such as conventional Load instructions).
[0041] However, the size of shared memory is limited. When the size of the input gradient tensor is large, it cannot be loaded into the shared memory as a whole. Batch data processing instructions can only load or store data blocks of fixed size. At this time, data loading can no longer be performed in data blocks. This is because for the edge elements of a data block, the elements of other adjacent data blocks are required for back propagation calculations, which results in data loading only for single elements. The efficiency of conventional Load instructions is not high, and a large number of repeated elements need to be loaded when calculating edge elements, resulting in low memory access efficiency and a significant decrease in overall performance.
[0042] At least one embodiment of the present disclosure provides a data processing method, a processor, an electronic device, and a non-transitory computer-readable storage medium. The data processing method is used to load an output gradient tensor from a memory to a cache unit of a processor to perform a back propagation calculation of a channel-by-channel convolution to obtain an input gradient tensor, wherein the output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers, and the elements in the output gradient matrix are arrayed into a plurality of data blocks of a size of w×h, w and h are positive integers greater than 1, and the back propagation calculation of the channel-by-channel convolution includes determining an input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and a corresponding convolution kernel, wherein the size of the convolution kernel is 3×3, the step size of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H, and the data processing method includes: for each output gradient matrix, in response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, all elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix are loaded to the cache unit in units of data blocks, wherein n is an integer greater than or equal to 0 and less than H, and n is 2×h An integer multiple of ; using the elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix, calculate the elements from the n+1th row to the n+2×hth row in the input gradient matrix.
[0043] In at least one embodiment, the data processing method can load 2×h consecutive rows of elements in the output gradient matrix to the cache component at one time in units of data blocks, and use the elements of the 2×h rows to calculate the elements of the corresponding 2×h rows in the input gradient matrix, thereby fully squeezing the shared memory resources. As a result, more efficient batch data processing instructions can be used, and there is no need to load data in units of single elements, thereby reducing the amount of calculation of coordinate points; data is highly reused to avoid loading a large number of repeated data points; a cache component is introduced to cache the loaded input gradient tensor, and a hierarchical storage structure is used to speed up the data loading process.
[0044] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings, but the present disclosure is not limited to these specific embodiments.
[0045] Figure 3 A schematic flowchart of a data processing method provided for at least one embodiment of the present disclosure.
[0046] The data processing method is used to load the output gradient tensor from the memory to the cache component of the processor to perform the back propagation calculation of the channel-by-channel convolution to obtain the input gradient tensor. The cache component is used to cache the output gradient tensor and send the output gradient tensor to the corresponding register when the computing core performs the back propagation calculation on the output gradient tensor. For example, the cache component can be the aforementioned Figure 2 Shared memory in .
[0047] The output gradient tensor includes at least one output gradient matrix, and the size of each output gradient matrix is W×H, where W and H are positive integers. The output gradient tensor can be a 3-dimensional tensor, such as [C, H, W], and the output gradient tensor includes, for example, output gradient matrices of C channels; the output gradient tensor can also be a 4-dimensional tensor, such as [N, C, W, H], where N represents a batch, and the output gradient tensor includes, for example, N batches, and each batch includes output gradient matrices of C channels. The present disclosure does not impose specific limitations on this.
[0048] The elements in the output gradient matrix are arrayed into multiple data blocks of size w×h, where w and h are positive integers greater than 1. For example, the elements in a data block have consecutive storage addresses in the memory and can be loaded into the memory at one time using a batch data load instruction. For example, when the input matrix is stored in the memory, it can be divided into multiple data blocks of the same size and stored in the data memory in units of data blocks. For example, elements belonging to the same data block are stored consecutively in the memory, and elements belonging to the same data block correspond to the same storage address in the memory. For example, in one example, the size of the data block can be 4×8, including 4 rows and 8 columns of elements in the input matrix.
[0049] The back propagation calculation of the channel-by-channel convolution includes determining the input gradient matrix corresponding to the output gradient matrix based on each output gradient matrix and the corresponding convolution kernel. For example, the size of the convolution kernel is 3×3, the stride of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H.
[0050] like Figure 3 As shown, the data processing method provided by at least one embodiment of the present disclosure includes steps S10-S20.
[0051] In step S10, for each output gradient matrix, in response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, all elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix are loaded into the cache component in units of data blocks.
[0052] Here, n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h.
[0053] For example, n=i×2×h, i is 0, 1, 2, etc.
[0054] In step S20, the elements from the n / 2+1th row to the n / 2+2×hth row in the loaded output gradient matrix are used to calculate the elements from the n+1th row to the n+2×hth row in the input gradient matrix.
[0055] In at least one embodiment of the present disclosure, when performing gradient calculation, if it is necessary to calculate the elements of the n+1th row to the n+2×hth row in the input gradient matrix, it is only necessary to load all elements in the data blocks corresponding to two rows (elements of the n / 2+1th row to the n / 2+2×hth row) in the output gradient matrix, and use all elements in the data blocks corresponding to two rows (elements of the n / 2+1th row to the n / 2+2×hth row) in the output gradient matrix to perform gradient calculation of the elements of the n+1th row to the n+2×hth row in the input gradient matrix, without loading the data blocks of the upper and lower adjacent rows of the two data blocks.
[0056] Usually, in order to use batch data processing instructions, data blocks are usually used for loading and storage. Therefore, when performing back propagation calculations, in theory, the gradient calculation of the elements at the edge of each data block needs to use the elements in the adjacent data blocks. However, in the present invention, there is no need to load the data blocks of the upper and lower adjacent rows of these two rows of data blocks, thereby greatly reducing the overhead caused by data loading.
[0057] Figure 4 Figure 1 shows the relationship between the input gradient matrix and the output gradient matrix. The left side represents the input gradient matrix or input feature map, and the right side represents the output gradient matrix or output feature map. Figure 4 The input feature map in is applied with a convolution kernel of size 3×3 and a step length of 2 to obtain the output feature map. Figure 4 After back-propagation calculation of the output gradient matrix in , the input gradient matrix is obtained.
[0058] Figure 4 Each minimum granularity rectangle in represents an element. Figure 4 The left input gradient matrix or input feature map in FIG. 1 shows two data blocks, each of which is marked by a thick frame and each of which includes 4 rows and 8 columns of elements.
[0059] like Figure 4 As shown in the figure, during the forward propagation process, the convolution calculation of the 3×3 convolution kernel is performed with the black rectangular box in the input feature map as the center, and the output feature map on the right is obtained, which has 4×4 elements with stripes marked by the black thick line box.
[0060] In the reverse calculation process, the calculation Figure 4 The value of each element in the two data blocks in the input gradient matrix needs to depend on the striped elements in the output gradient matrix on the right.
[0061] After analysis, it can be seen that for the black rectangular box in the input gradient matrix (hereinafter referred to as type A element), for example Figure 4Taking element a0 in as an example, during back propagation calculation, element a0 in the input gradient matrix only depends on the corresponding element a0' in the output gradient matrix. Therefore, the calculation of class A elements in the entire data block depends on the elements in the corresponding data block in the output gradient matrix.
[0062] For the elements adjacent to the orthogonal directions (upper, lower, left, and right) of the A-type elements in the input gradient matrix (hereinafter referred to as B-type elements), for example, Figure 4 During the back propagation calculation, the element b in the input gradient matrix depends on the elements a0' and a1' in the output gradient matrix. Therefore, the calculation of the B-type elements in the entire data block depends on the elements in the corresponding data block in the output gradient matrix.
[0063] For the diagonal elements (upper left, lower left, upper right, lower right) of the A-type elements in the input gradient matrix (hereinafter referred to as C-type elements), for example Figure 4 During the back propagation calculation, the element c in the input gradient matrix depends on the corresponding elements a0', a1', a2' and a3' in the output gradient matrix. The elements a2' and a3' belong to the next adjacent row of data blocks. Therefore, the calculation of the C-type elements in the entire data block depends on the elements in the two adjacent rows of data blocks in the output gradient matrix.
[0064] Therefore, in at least one embodiment of the present disclosure, it is only necessary to load all elements in two rows of data blocks (elements from the n+1th row to the n+2×hth row) in the output gradient matrix to calculate all elements in the corresponding two rows of data blocks in the input gradient matrix, without having to load data blocks of upper and lower adjacent rows of the two rows of data blocks in the output gradient matrix, thereby reducing the reading of a large amount of duplicate data from the memory.
[0065] For example, step S10 may include: in response to n=0, loading the elements of the 1st row to the 2×hth row in the output gradient matrix to the cache component in units of data blocks; in response to n being greater than or equal to 2×h, loading the elements of the n / 2+h+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of data blocks, and retaining the elements of the n / 2+1th row to the n / 2+hth row in the output gradient matrix that have been loaded into the cache component.
[0066] For example, first, the elements from row 1 to row 2×h in the input gradient matrix are calculated, and the elements from row 1 to row 2×h in the output gradient matrix are loaded into the cache component in units of data blocks. For example, all elements from row 1 to row 2×h in the output gradient matrix (W elements in each row) are loaded into the cache component in units of data blocks to calculate the elements from row 1 to row 2×h in the input gradient matrix using these elements.
[0067] Afterwards, the elements from the 2×h +1th row to the 4×hth row in the input gradient matrix are calculated. To calculate the elements from the 2×h +1th row to the 4×hth row in the input gradient matrix, the elements from the h+1th row to the 3×hth row in the output gradient matrix are needed. The elements from the h+1th row to the 2×hth row in the output gradient matrix have been loaded into the cache component. Therefore, the elements from the h+1th row to the 2×hth row in the output gradient matrix in the cache component are retained, and the elements from the 2×h +1th row to the 3×hth row in the output gradient matrix are loaded in units of data blocks.
[0068] The subsequent process is similar and will not be described here.
[0069] In the above embodiment, two rows of data blocks (continuous 2×h rows of elements in the output gradient matrix) are loaded into the cache component each time to calculate all elements in the corresponding two rows of data blocks in the input gradient matrix, and in the next round of calculation, a row of data blocks loaded in the output gradient matrix in the previous round of calculation is reused, and only a row of data blocks that have not been loaded in the output gradient matrix is loaded, so that the shared memory resources are fully squeezed, more efficient data loading instructions are used, and a large amount of repeated data is read from the memory is reduced.
[0070] For example, the elements from the n+1th row to the n+2×hth row in the input gradient matrix obtained by back propagation calculation of channel-by-channel convolution are divided into multiple data blocks of size w×h. The data processing method provided by at least one embodiment of the present disclosure also includes: storing the elements from the n+1th row to the n+2×hth row in the input gradient matrix to the memory in units of data blocks.
[0071] To improve storage efficiency, each time the 2×h row elements in the input gradient matrix are calculated, they are stored in the memory in units of data blocks. For example, more efficient batch data storage instructions can be used to store data, which greatly improves performance and efficiency.
[0072] Therefore, both the input parameters (two rows of data blocks of the output gradient matrix) and the output parameters (one row of data blocks of the input gradient matrix) can be stored and loaded through batch data processing instructions, greatly improving performance and efficiency.
[0073] In the data processing method provided by at least one embodiment of the present disclosure, when the capacity of the cache component is limited, the size W of the output gradient matrix needs to be limited.
[0074] For example, W is less than or equal to Wm, and Wm is determined according to h, the storage capacity of the cache component, and the data type of the elements in the output gradient tensor.
[0075] For example, Wm can be calculated according to the following formula:
[0076] Wm=Size / (e×2×h×D)
[0077] Wherein, Size represents the capacity of the cache component, e represents the number of execution units sharing the cache component in the same computing unit, and D represents the size (number of bytes) of the element data type in the output gradient tensor.
[0078] In a specific example, the cache component is a shared memory with a capacity of 32KB. A total of 4 execution units share the 32KB cache component. The data type of the elements in the output gradient tensor is FP32 (32-bit floating point number), h=4, so Wm=256 is calculated, that is, when the number of columns of the output gradient matrix is less than or equal to 256, the data processing method provided by at least one embodiment of the present disclosure can be used in the above-mentioned hardware.
[0079] For example, the elements cached in the cache unit are loaded into the register for calculation only when the gradient calculation of the elements is performed. Therefore, the cache unit is introduced to use a hierarchical storage structure to speed up the data loading process.
[0080] For example, data blocks loaded into the cache component are all loaded into the same storage area of fixed capacity in the cache component.
[0081] For example, taking n=2×h as an example, when calculating the elements from the 2×h+1th row to the 4×hth row in the input gradient matrix, the elements from the 2×h+1th row to the 3×hth row in the output gradient matrix can overwrite the elements from the 1st row to the hth row previously loaded into the cache component. In this scenario, the resource allocation of other operators is not affected, thereby improving system performance.
[0082] Of course, the present disclosure is not limited thereto, and the newly loaded elements from the 2×h+1th row to the 3×hth row may also be loaded to other locations in the cache unit, and the elements from the 1st row to the hth row in the cache unit may be discarded.
[0083] For each output gradient matrix, the corresponding input gradient matrix is calculated in the manner described above, which will not be repeated here.
[0084] The data processing method provided by at least one embodiment of the present disclosure loads and stores data in units of data blocks, thereby using more efficient batch data processing instructions, without the need to load data in units of single elements, and reducing the amount of calculation of coordinate points. Two rows of data blocks in the output gradient matrix are loaded each time to calculate the corresponding two rows of data blocks in the input gradient matrix, and a row of data blocks loaded in the previous round is reused, and only a row of data blocks that have not been loaded is loaded, and data is highly reused to avoid loading a large number of duplicate elements. A cache component is introduced to cache the loaded input tensors, and a hierarchical storage structure is used to speed up the data loading process.
[0085] At least one embodiment of the present disclosure further provides a data processing device. Figure 5A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure.
[0086] like Figure 5 As shown, the data processing device 100 includes a loading module 101 and a calculation module 102 .
[0087] The data processing device 100 is used to load the output gradient tensor from the memory to the cache component of the processor to perform the back propagation calculation of the channel-by-channel convolution to obtain the input gradient tensor.
[0088] For example, the output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers, and the elements in the output gradient matrix are arrayed into multiple data blocks of size w×h, and w and h are positive integers greater than 1.
[0089] The back propagation calculation of channel-by-channel convolution includes determining the input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and the corresponding convolution kernel, where the size of the convolution kernel is 3×3, the stride of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H.
[0090] For the back propagation calculation of the input gradient tensor and channel-by-channel convolution, please refer to the relevant description in the aforementioned data processing method, which will not be repeated here.
[0091] The loading module 101 is configured to load all elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache unit in units of data blocks for each output gradient matrix in response to calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, wherein n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h.
[0092] The calculation module 102 is configured to calculate the elements from the n+1th row to the n+2×hth row in the input gradient matrix using the elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix.
[0093] For example, the loading module 101 performs the following operations in response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, loading the elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of data blocks: in response to n=0, loading the elements of the 1st row to the 2×hth row in the output gradient matrix to the cache component in units of data blocks; in response to n being greater than or equal to 2×h, loading the elements of the n / 2+h+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of data blocks, and retaining the elements of the n / 2+1th row to the n / 2+hth row in the output gradient matrix that have been loaded into the cache component.
[0094] For example, the data processing device 100 further includes a storage processing module ( Figure 5 not shown).
[0095] For example, the elements from the n+1th row to the n+2×hth row in the input gradient matrix obtained by back propagation calculation of channel-by-channel convolution are divided into a plurality of data blocks of size w×h. The storage processing module is configured to store the elements from the n+1th row to the n+2×hth row in the input gradient matrix to the memory in units of data blocks.
[0096] For example, the loading module 101 and the computing module 102 include codes and programs stored in the memory, and the processing module 201 is implemented as a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities. The processing unit can be a general-purpose processor, and can also be a single-chip microcomputer, a microprocessor, a digital signal processor, a dedicated image processing chip, or a field programmable logic array, etc. The loading module 101 and the computing module 102 execute the code and program to implement some or all of the functions of the loading module 101 and the computing module 102 as described above. For example, the loading module 101 and the computing module 102 can be a circuit board or a combination of multiple circuit boards, which are used to implement the functions as described above. In the embodiment of the present application, the circuit board or the combination of multiple circuit boards may include: (1) one or more processors; (2) one or more non-temporary memories connected to the processor; and (3) firmware stored in the memory that can be executed by the processor.
[0097] It should be noted that the loading module 101 can be used to implement Figure 3 Step S10 shown; the calculation module 102 can be used to implement Figure 3 The step S20 shown. Therefore, for the specific description of the functions that can be realized by the loading module 101, reference can be made to the relevant description of step S10 in the embodiment of the above data processing method, and for the specific description of the functions that can be realized by the calculation module 102, reference can be made to the relevant description of step S20 in the embodiment of the above data processing method, and the repeated parts will not be repeated here. In addition, the data processing device 100 can achieve the technical effects similar to those of the above data processing method, which will not be repeated here.
[0098] It should be noted that in at least one embodiment of the present disclosure, the data processing device 100 may include more or fewer circuits or units, and the connection relationship between the various circuits or units is not limited and can be determined according to actual needs. The specific configuration of each circuit or unit is not limited and can be composed of analog devices according to circuit principles, or can be composed of digital chips, or can be composed in other applicable ways.
[0099] For example, the data processing device 100 may be implemented in hardware, software, or a combination of hardware and software, and the present disclosure does not impose any specific limitations on this.
[0100] The data processing method provided by at least one embodiment of the present disclosure can achieve a technical effect similar to the data processing method described above, and will not be described in detail here.
[0101] The data processing method and data processing device provided in at least one embodiment of the present disclosure can be applied to different systems or devices, such as Figure 7 The electronic device 300 shown. The electronic device 300 can be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an AR device, a VR device, a vehicle terminal, etc., and can also be a server, etc. The data processing method provided in at least one embodiment of the present disclosure can be applied to scenarios involving CPU, high performance computing (High Performance Computing, HPC for short) and artificial intelligence (Artificial Intelligence, AI) in the electronic device 300, such as tensor computing units, etc. Of course, the present disclosure is not limited to this, and any scenario, device, apparatus, etc. involving back propagation calculation of channel-by-channel convolution can adopt the data processing method or data processing apparatus provided by at least one embodiment of the present disclosure.
[0102] In some embodiments, the data processing device provided by at least one embodiment of the present disclosure may be a chip, for example, the chip is a system-on-a-chip (SoC). The system-on-a-chip includes a processor, which may be a single-core processor or a multi-core processor, a memory, and an I / O interface, etc. After the processor loads the data and application in the memory, it processes the data, for example, performs computational processing of back propagation calculation of channel-by-channel convolution.
[0103] It should be noted that the output gradient tensor and the input gradient tensor of the data processing method or data processing device provided in at least one embodiment of the present disclosure may have different specific physical meanings according to different application scenarios. For example, the data processing method provided in at least one embodiment of the present disclosure may be applied in the fields of speech processing, image processing, text processing, video processing, etc.
[0104] For example, in the field of speech processing, the output gradient tensor and the input gradient tensor can be the input and output parameters of the back propagation calculation involving channel-by-channel convolution in tasks such as feature extraction, speech enhancement, and speech recognition.
[0105] For example, in the field of image processing, the output gradient tensor and the input gradient tensor can be the input and output parameters of the back propagation calculation involving channel-by-channel convolution in tasks such as image recognition, feature extraction, image segmentation, target detection, image classification, and scene reconstruction.
[0106] For example, in the field of text processing, the output gradient tensor and the input gradient tensor can be the input and output parameters of the back propagation calculation involving channel-by-channel convolution in tasks such as text classification, sentiment analysis, and text generation.
[0107] For example, in the field of video processing, the output gradient tensor and the input gradient tensor can be related parameters in the field of image processing as described above, or input and output parameters of back-propagation calculations involving channel-by-channel convolution, such as the optical flow operator (used to estimate motion between video frames) and the target tracking operator (used to track specific targets in the video), which are unique to the field of video processing.
[0108] Of course, the present disclosure is not limited to this. For other application scenarios or fields, as long as back propagation calculation of channel-by-channel convolution is required, the data processing method described in at least one embodiment of the present disclosure can be applied, and will not be described one by one here.
[0109] Figure 6 A schematic structural diagram of a processor provided in at least one embodiment of the present disclosure. Figure 6 As shown, the processor 200 includes an instruction parsing unit 201 , an execution unit 202 , a memory 203 and a cache unit 204 .
[0110] For example, the instruction parsing unit 201 is used to receive and parse data processing instructions.
[0111] For example, the data processing instruction is used to load the output gradient tensor from the memory to the cache component of the processor to perform the back propagation calculation of the channel-by-channel convolution to obtain the input gradient tensor. The data processing instruction includes, for example, a data loading instruction and a calculation instruction, the data loading instruction is used to load the input gradient tensor from the memory 203 to the cache component 204, and the data calculation instruction is used to perform the back propagation calculation of the channel-by-channel convolution on the input gradient tensor.
[0112] For example, the cache component 204 may include a shared memory. For example, the processor 200 may use the aforementioned Figure 2 The graphics processor or general graphics processor architecture shown.
[0113] For example, the output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers, and the elements in the output gradient matrix are arrayed into multiple data blocks of size w×h, and w and h are positive integers greater than 1.
[0114] The back propagation calculation of channel-by-channel convolution includes determining the input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and the corresponding convolution kernel, where the size of the convolution kernel is 3×3, the stride of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H.
[0115] For example, the execution unit 202 executes the data processing instruction after the instruction parsing unit parses the data processing instruction.
[0116] For example, after receiving a data processing instruction, the processor parses the data processing instruction, such as decoding the data processing instruction, generates a microinstruction and sends the microinstruction to an instruction dispatch unit; the instruction dispatch unit sends the microinstruction to a corresponding scheduling queue according to the microinstruction category; in response to the microinstruction, when all or required input matrices are prepared, the execution unit reads the data and executes the relevant operations of the data processing instruction.
[0117] For example, the execution unit may include hardware involved in executing data processing instructions, such as a multiplier, a register, a queue, an ALU (Arithmetic Logic Unit), etc.
[0118] For example, when the execution unit 202 executes the data processing instruction, the execution unit 202 includes performing the following operations: for each output gradient matrix, in response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, all elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix are loaded to the cache unit in units of data blocks, where n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h; using the elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix, the elements of the n+1th row to the n+2×hth row in the input gradient matrix are calculated.
[0119] Specifically, when processor-based upper-level software (for example, AI applications, HPC applications, and scientific computing applications, etc.) can send data processing instructions for computing processing to a processor (such as a CPU or GPU) through a uniformly packaged function library, the data processing instructions can carry input parameters such as storage addresses; when the processor receives the data processing instructions, the instruction parsing unit 201 parses the data processing instructions, obtains the input parameters, loads the data indicated by the storage address from the memory to the register, and caches them in the cache component.
[0120] Regarding the specific process of using the execution unit 202 to execute the data processing instruction, reference may be made to steps S10 - S20 etc. in the aforementioned data processing method, and the repeated parts will not be repeated here.
[0121] The processor provided in at least one embodiment of the present disclosure can achieve technical effects similar to those of the aforementioned data processing method, and the repeated parts will not be repeated.
[0122] Figure 7 The following is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 7As shown, the electronic device 300 is suitable for implementing the data processing method provided by the embodiment of the present disclosure. It should be noted that Figure 7 The components of the electronic device 300 shown are merely exemplary and non-limiting. The electronic device 300 may also have other components according to actual application requirements.
[0123] like Figure 7 As shown, the electronic device 300 may include a processing device (eg, a central processing unit, a graphics processing unit, etc.) 301, which may perform various appropriate actions and processes according to non-transitory computer-readable instructions stored in a memory to implement various functions.
[0124] For example, when the computer readable instructions are executed by the processing device 301, one or more steps in the data processing method described in any of the above embodiments may be executed. It should be noted that for a detailed description of the processing process of the data processing method, reference may be made to the relevant description in the above data processing method embodiments.
[0125] For example, the memory may include any combination of one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) 303 and / or cache memory (cache), etc. For example, computer-readable instructions may be loaded from storage device 308 into random access memory (RAM) 303 to run computer-readable instructions. Non-volatile memory may include, for example, read-only memory (ROM) 302, hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. Various applications and various data, such as style images, and various data used and / or generated by applications, etc., may also be stored in the computer-readable storage medium.
[0126] For example, the processing device 301 , the ROM 302 , and the RAM 303 are connected to one another via a bus 304 . An input / output (I / O) interface 305 is also connected to the bus 304 .
[0127] Typically, the following devices may be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 308 including, for example, a magnetic tape, a hard disk, a flash memory, etc.; and a communication device 309. The communication device 309 may allow the electronic device 300 to communicate with other electronic devices wirelessly or by wire to exchange data. Although Figure 7An electronic device 300 having various devices is shown, but it should be understood that it is not required to implement or have all the devices shown, and the electronic device 300 may alternatively implement or have more or fewer devices. For example, the processing device 301 can control other components in the electronic device 300 to perform the desired functions. The processing device 301 can be a device with data processing capabilities and / or program execution capabilities such as a central processing unit (CPU), a tensor processing unit (TPU) or a graphics processing unit GPU. The central processing unit (CPU) can be an X86, ARM, RISC-V architecture, etc. The GPU can be directly integrated into the SOC, directly integrated into the motherboard, or built into the north bridge chip of the motherboard.
[0128] Figure 8 A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure. Figure 8 As shown, the storage medium 400 may be a non-transitory computer-readable storage medium, and one or more computer-readable instructions 401 may be non-transitory stored on the storage medium 400. For example, when the computer-readable instructions 401 are executed by a processor, one or more steps in the data processing method described above may be executed.
[0129] For example, the storage medium 400 may be applied in the electronic device 300 . For example, the storage medium 400 may include the storage device 308 in the electronic device 300 .
[0130] For example, the storage device may include any combination of one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, flash memory, etc. One or more computer-readable instructions may be stored on the computer-readable storage medium, and the processor may run the computer-readable instructions to implement various functions of the processor. Various applications and various data may also be stored in the storage medium.
[0131] For example, the storage medium may include a memory card of a smart phone, a cache component of a tablet computer, a hard disk of a personal computer, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), flash memory, or any combination of the above storage media, or other applicable storage media.
[0132] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0133] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0134] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0135] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0136] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0137] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
[0138] There are a few points to note about this disclosure:
[0139] (1) The drawings of the embodiments of the present disclosure only relate to the structures related to the embodiments of the present disclosure. Other structures may refer to the general design.
[0140] (2) In the absence of conflict, the embodiments of the present disclosure and the features therein may be combined with each other to obtain new embodiments.
[0141] The above description is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. The protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A data processing method for loading an output gradient tensor from a memory into a cache component of a processor to perform a back propagation calculation of a channel-by-channel convolution to obtain an input gradient tensor, in, The output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers greater than 1, and the elements in the output gradient matrix are array-divided into a plurality of data blocks of size w×h, w and h are positive integers greater than 1, The back propagation calculation of the channel-by-channel convolution includes determining an input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and the corresponding convolution kernel, wherein the size of the convolution kernel is 3×3, the step size of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H, The data processing method comprises: For each output gradient matrix, in response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, loading all elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of the data block, wherein n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h; The elements from the n+1th row to the n+2×hth row in the input gradient matrix are calculated by using the elements from the n / 2+1th row to the n / 2+2×hth row in the loaded output gradient matrix.
2. The data processing method according to claim 1, wherein: In response to calculating the elements of the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, loading the elements of the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of the data block, comprising: In response to n=0, loading the elements from the 1st row to the 2×hth row in the output gradient matrix into the cache component in units of the data block; In response to n being greater than or equal to 2×h, loading the elements of the n / 2+h+1th to n / 2+2×hth rows in the output gradient matrix into the cache unit in units of the data block, and retaining the elements of the n / 2+1th to n / 2+hth rows in the output gradient matrix that have been loaded into the cache unit.
3. The data processing method according to claim 1, wherein: The elements from the n+1th row to the n+2×hth row in the input gradient matrix obtained by the back propagation calculation of the channel-by-channel convolution are divided into a plurality of data blocks of size w×h, The data processing method further includes: Taking the data block as a unit, the elements from the n+1th row to the n+2×hth row in the input gradient matrix are stored in the memory.
4. The data processing method according to claim 1, wherein: W is less than or equal to Wm, Wm is determined according to h, the storage capacity of the cache component, and the data type of the elements in the output gradient tensor, and Wm is a positive number.
5. The data processing method according to claim 4, wherein: Wm is calculated according to the following formula: Wm=Size / (e×2×h×D) Among them, Size represents the capacity of the cache component, e represents the number of execution units sharing the cache component in the same computing unit, and D represents the size of the element data type in the output gradient tensor.
6. The data processing method according to claim 1, wherein: The elements cached in the cache unit are loaded into the register for calculation when gradient calculation is performed on the elements cached.
7. The data processing method according to any one of claims 1 to 6, wherein: The cache component includes a shared memory.
8. The data processing method according to any one of claims 1 to 6, wherein: All data blocks loaded into the cache component are loaded into a same storage area of fixed capacity in the cache component.
9. A processor comprising an instruction parsing unit, an execution unit, a cache component and a memory, wherein: The instruction parsing unit is used to receive and parse data processing instructions, wherein the data processing instructions are used to load the output gradient tensor from the memory to the cache component, perform back propagation calculation of channel-by-channel convolution, and obtain the input gradient tensor, The execution unit executes the data processing method according to any one of claims 1 to 8 after the instruction parsing unit parses the data processing instruction.
10. A data processing device for loading an output gradient tensor from a memory into a cache component of a processor to perform a back propagation calculation of a channel-by-channel convolution to obtain an input gradient tensor, in, The output gradient tensor includes at least one output gradient matrix, each output gradient matrix has a size of W×H, W and H are positive integers greater than 1, and the elements in the output gradient matrix are array-divided into a plurality of data blocks of size w×h, w and h are positive integers greater than 1, The back propagation calculation of the channel-by-channel convolution includes determining an input gradient matrix corresponding to the output gradient matrix according to each output gradient matrix and the corresponding convolution kernel, wherein the size of the convolution kernel is 3×3, the step size of the convolution kernel is 2, and the size of the input gradient matrix is 2×W×2×H, The data processing device comprises: a loading module configured to, for each output gradient matrix, load all elements from the n / 2+1th row to the n / 2+2×hth row in the output gradient matrix to the cache component in units of the data block in response to calculating the elements from the n+1th row to the n+2×hth row in the input gradient matrix corresponding to the output gradient matrix, wherein n is an integer greater than or equal to 0 and less than H, and n is an integer multiple of 2×h; A calculation module is configured to calculate the elements from the n+1th row to the n+2×hth row in the input gradient matrix using the elements from the n / 2+1th row to the n / 2+2×hth row in the loaded output gradient matrix.
11. An electronic device, comprising: A memory non-transitorily stores computer executable instructions; a processor configured to execute the computer executable instructions, Wherein, when the computer executable instructions are executed by the processor, the data processing method according to any one of claims 1-8 is implemented.
12. A non-transitory computer-readable storage medium, wherein: The non-transitory computer-readable storage medium stores computer-executable instructions, When the computer executable instructions are executed by a processor, the data processing method according to any one of claims 1 to 8 is implemented.
