Data processing method and device, processor, electronic device and storage medium
By dividing the input matrix into data blocks and loading them into the cache component in units of data blocks for convolution operations, the problem of low data loading efficiency in large-scale input tensor processing in the existing technology is solved, and efficient convolution calculations are achieved. .
Patent Information
- Application Number
- CN202410947841.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-16
AI Technical Summary
In the convolution operation of neural networks, when existing technology processes large-scale input tensors, the limitation of shared memory leads to low data loading efficiency. Especially when calculating edge elements, a large amount of repeated data needs to be loaded, resulting in performance degradation.
By dividing the input matrix into multiple data blocks, and loading the required data blocks from the memory to the cache component in units of data blocks, performing convolution-related operations, using batch data processing instructions to reduce the amount of coordinate point calculations, and using hierarchical The storage structure speeds up the data loading process and supports input matrices of any size.
It improves the efficiency of data loading and storage, reduces the reading of repeated data, improves the performance of convolution operations, and is suitable for input matrices of any size.
Smart Images

Figure CN118503601B
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to a data processing method, a data processing 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 point-wise 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. The back propagation of the neural network 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 the point-wise 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, including: a data processing method for loading an input tensor from a memory into a cache component of a processor to perform convolution-related operations, wherein the input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers, and the elements in the input 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, and the size of the convolution kernel used in the convolution-related operation is greater than 1×1. The data processing method includes: for each input matrix, taking the operation area as a unit, performing the convolution-related operation on each operation area in turn according to the convolution sliding direction to obtain an output matrix corresponding to the input matrix, wherein each operation area includes part of the multiple data blocks, and different operation areas do not overlap with each other; wherein, performing the convolution-related operation on each operation area in turn according to the convolution sliding direction includes: taking the data block as a unit, loading the data blocks required by each operation area when performing the convolution-related operation from the memory to the cache component in turn, so as to perform the convolution-related operation on the data blocks in the operation area, wherein the data blocks required by each operation area when performing the convolution-related operation include multiple data blocks adjacent to the operation area in a preset direction, and the data blocks in the operation area, and the preset direction includes an orthogonal direction and a diagonal direction.
[0006] For example, in the data processing method provided by at least one embodiment of the present disclosure, the data blocks required by each operation area when performing the convolution-related operations are loaded from the memory in sequence to the cache component in units of data blocks, so as to perform the convolution-related operations on the data blocks in the operation area, including: for the target operation area that currently needs to perform the convolution-related operations, the data blocks required by the target operation area when performing the convolution-related operations are loaded into the cache component, and the convolution-related operations are performed on the data blocks in the target operation area; the next operation area is determined as the target operation area according to the convolution sliding direction, and all the data blocks required by the next operation area when performing the convolution-related operations are loaded into the cache component, wherein, during loading, only the data blocks that have not been loaded into the cache component among all the data blocks are loaded, and the data blocks that have been loaded into the cache component among all the data blocks are retained.
[0007] For example, in the data processing method provided by at least one embodiment of the present disclosure, each operation area includes m×m data blocks, where m is a positive integer, and for the target operation area that currently needs to perform the convolution-related operation, the data blocks required by the target operation area when performing the convolution-related operation are loaded into the cache component, including: in response to the target operation area including the first column of data blocks located on the leftmost side of the input matrix: pre-loading L data blocks in the first column of data blocks to the cache component, wherein the L data blocks include m data blocks in the first column of data blocks belonging to the target operation area, and the L data blocks also include a first data block and a second data block. at least one of the m data blocks, the first data block being a data block directly adjacent to the top data block among the m data blocks and located on the upper side of the top data block, and the second data block being a data block directly adjacent to the bottom data block among the m data blocks and located on the lower side of the bottom data block; performing a first operation, wherein the first operation is used to load data blocks that have not been loaded among the data blocks required by the target operation area when performing the convolution-related operation, and perform the convolution-related operation on the target operation area using the required data blocks; in response to the target operation area not including the first column of data blocks: performing the first operation.
[0008] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to the step size of the convolution-related operation being 1, m=1, the target operation area includes a data block located in the ath row and bth column of the input matrix, a and b are positive integers, and the first operation includes the following process: in response to a=1, loading 2 data blocks located in the ath row to the a+1th row of the data block located in the b+1th column of the input matrix to the cache component; in response to a being greater than 1, loading 3 data blocks located in the a-1th row to the a+1th row of the data block located in the b+1th column of the input matrix to the cache component; performing the convolution-related operation on the data blocks in the target operation area.
[0009] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to the step size of the convolution-related operation being 2, m=2, the target operation area includes 2×2 data blocks located from the ath row to the a+1th row and from the bth column to the b+1th column in the input matrix, a and b are positive integers, and the first operation includes the following process: in response to a=1, loading 6 data blocks located from the ath row to the a+2th row and from the b+1th column to the b+2th column in the input matrix to the cache component; in response to a being greater than 1, loading 8 data blocks located from the a-1th row to the a+2th row and from the b+1th column to the b+2th column in the input matrix to the cache component; performing the convolution-related operation on the data blocks in the target operation area.
[0010] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to the target operation area including the topmost first row of data blocks in the input matrix, the L data blocks include the second data block but do not include the first data block; in response to the target operation area not including the first row of data blocks, the L data blocks include the first data block and the second data block.
[0011] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to the operating area including the topmost first row of data blocks and the leftmost first column of data blocks in the input matrix, the orthogonal directions include directly below and directly to the right, and the diagonal directions include the lower right; in response to the operating area including the first row of data blocks but not including the first column of data blocks, the orthogonal directions include directly to the left, directly below and directly to the right, and the diagonal directions include the lower left and lower right; in response to the operating area not including the first row of data blocks, the orthogonal directions include directly above, directly below, directly to the right and directly left, and the diagonal directions include the lower left, lower right, upper left and upper right.
[0012] For example, in the data processing method provided by at least one embodiment of the present disclosure, the convolution-related operations include channel-by-channel convolution and back-propagation calculation of channel-by-channel convolution, the channel-by-channel convolution includes applying the corresponding convolution kernel to each input matrix respectively to obtain an output matrix corresponding to the input matrix, and the back-propagation calculation of the channel-by-channel convolution includes performing gradient calculation on each input matrix to obtain an output matrix corresponding to the input matrix, wherein, in response to the convolution-related operation being the back-propagation calculation of channel-by-channel convolution, the elements in the input matrix represent the output gradients, and the elements in the output matrix represent the input gradients.
[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, data blocks required by different operation areas when performing the convolution-related operations are all loaded into the same fixed-capacity storage area in the cache component.
[0015] For example, in the data processing method provided by at least one embodiment of the present disclosure, in response to the step size of the convolution-related operation being 1, the storage capacity of the storage area is 9 times the total data amount of a single data block; in response to the step size of the convolution-related operation being 2, the storage capacity of the storage area is 16 times the total data amount of a single data block.
[0016] For example, in the data processing method provided by at least one embodiment of the present disclosure, the size of the operation calculation result of each operation area is the same as the size of the data block, the output matrix includes the operation calculation results of each operation area in the input matrix, and the operation calculation result of each operation area is stored as a whole in the memory as a unit of the operation calculation result.
[0017] For example, in the data processing method provided by at least one embodiment of the present disclosure, the data blocks cached in the cache component are loaded into the register for calculation when performing convolution-related operations on the target operation area.
[0018] At least one embodiment of the present disclosure provides a processor, comprising an instruction parsing unit, an execution unit, a memory and a cache component, wherein the instruction parsing unit is used to receive and parse data processing instructions, wherein the data processing instructions are used to load input tensors from the memory to the cache component and perform convolution-related operations, and the execution unit executes the data processing method described in any embodiment of the present disclosure after the instruction parsing unit parses the data processing instructions.
[0019] At least one embodiment of the present disclosure provides a data processing device, which is used to load an input tensor from a memory into a cache component of a processor to perform convolution-related operations, wherein the input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers, and the elements in the input 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, and the size of the convolution kernel used in the convolution-related operation is greater than 1×1. The data processing device includes: a processing module, configured to perform the convolution-related operation on each operation area in sequence according to the convolution sliding direction for each input matrix, taking the operation area as a unit, so as to obtain an output matrix corresponding to the input matrix, wherein each operation area includes part of the multiple data blocks, and different operation areas do not overlap with each other; wherein, when the processing module performs the convolution-related operation on each operation area in sequence according to the convolution sliding direction, it includes performing the following steps: taking the data block as a unit, sequentially loading the data blocks required by each operation area when performing the convolution-related operation from the memory to the cache component, so as to perform the convolution-related operation on the data blocks in the operation area, wherein the data blocks required by each operation area when performing the convolution-related operation include multiple data blocks adjacent to the operation area in a preset direction, and the data blocks in the operation area, and the preset direction includes an orthogonal direction and a diagonal direction.
[0020] 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.
[0021] 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
[0022] 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.
[0023] Figure 1 A schematic diagram of a channel-by-channel convolution;
[0024] Figure 2 A schematic structural diagram of a general-purpose graphics processing unit (GPGPU);
[0025] Figure 3 A schematic flow chart of a data processing method provided for at least one embodiment of the present disclosure;
[0026] Figure 4 A schematic diagram of performing a convolution operation on a data block provided by at least one embodiment of the present disclosure;
[0027] Figure 5A and Figure 5B A schematic diagram of the position relationship of data blocks provided for at least one embodiment of the present disclosure;
[0028] Fig. 6A A schematic diagram of an input matrix provided in an embodiment of the present disclosure;
[0029] Figure 6B and Figure 6C At least one embodiment of the present disclosure provides Fig. 6A The schematic diagram of the processing process of the input matrix executing the data processing method is shown;
[0030] Figure 7 A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure;
[0031] Figure 8 A schematic structural diagram of a processor provided for at least one embodiment of the present disclosure;
[0032] Fig. 9A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure;
[0033] Fig.10 A schematic block diagram of an electronic device provided according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] 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.
[0035] 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.
[0036] 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.
[0037] Figure 1 is a schematic diagram of channel-by-channel convolution, such as Figure 1 As shown, assuming that the input 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 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.
[0038] 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.
[0039] 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.
[0040] Figure 2 A schematic structural diagram of a general-purpose graphics processing unit (GPGPU).
[0041] 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.
[0042] like Figure 2 As shown, taking stream processor cluster 1 as an example, one stream processor cluster includes multiple computing units, such as Figure 1 In 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 1 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.
[0043] 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 1 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.
[0044] In each compute unit, the warp scheduling / dispatching module ( Figure 1 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.
[0045] When using a general-purpose graphics processor to perform channel-by-channel convolution, a common implementation method is to load the required input tensor (activation) into shared memory or registers, load the weight parameters of the convolution layer into registers, and then perform multiplication and addition operations one by one to perform a single-channel two-dimensional plane convolution operation, thereby implementing the convolution operation. When using a general-purpose graphics processor to perform back propagation calculations for channel-by-channel convolution, it is also necessary to load the required input tensor (activation) into shared memory or registers, load the weight parameters of the convolution layer into registers, and then calculate the input gradients one by one.
[0046] 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 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).
[0047] However, the size of shared memory is limited. When the size of the input tensor is large, it cannot be loaded into the shared memory as a whole. However, batch data processing instructions can only load or store data in fixed-size blocks. At this time, data loading in data blocks is no longer possible. This is because for the edge elements of a data block, the elements of other adjacent data blocks are required when performing convolution-related operations, which results in data loading only in the form of data loading for a single element. 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.
[0048] 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 input tensor from a memory to a cache unit of a processor to perform convolution-related operations, wherein the input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers, the input matrix is divided into a plurality of data blocks of size w×h, w and h are positive integers greater than 1, and the size of the convolution kernel used in the convolution-related operation is greater than 1×1. For example, in at least one embodiment, the data processing method includes: for each input matrix, taking the operation area as a unit, performing convolution-related operations on each operation area in turn according to the convolution sliding direction to obtain an output matrix corresponding to the input matrix, wherein each operation area includes a part of the multiple data blocks, and different operation areas do not overlap with each other; wherein, performing convolution-related operations on each operation area in turn according to the convolution sliding direction includes: taking the data block as a unit, loading the data blocks required by each operation area when performing the convolution-related operations from the memory to the cache component in turn to perform convolution-related operations on the data blocks in the operation area, wherein the data blocks required by each operation area when performing the convolution-related operations include multiple data blocks adjacent to the operation area in a preset direction, as well as data blocks in the operation area, and the preset direction includes an orthogonal direction and a diagonal direction.
[0049] In at least one embodiment, the data processing method can load and store data in units of data blocks, and dynamically load the data blocks required by each operation area when performing convolution-related operations in turn according to the convolution sliding direction, that is, only load the data blocks required by one operation area for performing convolution-related operations at a time, and use these data blocks to generate the operation calculation results of the operation area, thereby using more efficient batch data processing instructions, without the need to load data in units of single elements, reducing the amount of calculation of coordinate points; highly reuse data to avoid loading a large number of repeated elements; introduce a cache component to cache the loaded input tensors, and use a hierarchical storage structure to speed up the data loading process; there is no limit on the size of the input matrix, and it can be applied to input matrices of any size. Even if the size of the input matrix is large, for example, the amount of data is greater than or even much greater than the capacity of the cache component, the data processing method provided by at least one embodiment of the present disclosure can still be applied to data loading and convolution-related calculations.
[0050] 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.
[0051] Figure 3 A schematic flowchart of a data processing method provided for at least one embodiment of the present disclosure.
[0052] At least one embodiment of the present disclosure provides a data processing method for loading an input tensor from a memory into a cache component of a processor for performing convolution-related operations. The cache component is used to cache the input tensor and send the input tensor to a corresponding register when the computing core performs convolution-related operations on the input tensor. For example, the cache component may be the aforementioned Figure 2 The data blocks cached in the cache unit are loaded into the register for calculation when performing convolution-related operations on the target operation area.
[0053] For example, the input tensor includes at least one input matrix, and the size of each input matrix is W×H, where W and H are positive integers. The input tensor can be a 2-dimensional tensor, for example, including 1 input matrix; the input tensor can be a 3-dimensional tensor, for example, [C, W, H], and the input tensor includes, for example, an input matrix of C channels; the input tensor can also be a 4-dimensional tensor, for example, [N, C, W, H], where N represents a batch, and the input tensor includes, for example, N batches, and each batch includes an input matrix of C channels. The present disclosure does not impose specific restrictions on this.
[0054] For example, the input matrix is divided 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 cache component 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 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.
[0055] For example, the data format of a single element may be FP32 (32-bit floating point number).
[0056] For example, convolution-related operations use convolution kernels with a size larger than 1×1.
[0057] For example, the convolution-related operation includes a convolution operation or a back propagation calculation of the convolution. For example, the convolution operation includes performing a convolution calculation on each input matrix with a corresponding convolution kernel. For example, the back propagation calculation of the convolution includes calculating the gradient of the loss function with respect to the convolution kernel parameters.
[0058] For example, convolution-related operations include channel-by-channel convolution and back-propagation calculation of channel-by-channel convolution.
[0059] For example, the input tensor includes an input matrix of C channels, where C is a positive integer. Of course, as mentioned above, the input tensor may also include N dimensions. For example, channel-by-channel convolution includes applying a corresponding convolution kernel to the input matrix of each channel, respectively, to obtain an output tensor including C output matrices.
[0060] For example, the back propagation calculation of the channel-by-channel convolution includes performing gradient calculation on each input matrix to obtain an output matrix corresponding to the input matrix. For example, in response to the convolution-related operation being the back propagation calculation of the channel-by-channel convolution, the elements in the input matrix represent the output gradients, and the elements in the output matrix represent the input gradients.
[0061] Of course, the present disclosure is not limited to this, and can also be applied to other scenarios where a single input matrix and a single convolution kernel perform convolution operations or back propagation calculations of convolution.
[0062] like Figure 3 As shown, the data processing method provided by at least one embodiment of the present disclosure includes step S10.
[0063] In step S10, for each input matrix, taking the operation area as a unit, convolution-related operations are performed on each operation area in turn according to the convolution sliding direction to obtain an output matrix corresponding to the input matrix.
[0064] For example, each operation area includes a portion of the data blocks among the multiple data blocks, and different operation areas do not overlap with each other.
[0065] For example, the size of the operation calculation result of each operation area is the same as the size of the data block. The output matrix includes the operation calculation results of each operation area in the input matrix, that is, the operation calculation results of each operation area are combined according to the position relationship between the operation areas.
[0066] For example, to improve storage efficiency, the operation calculation results of each operation area are stored in the memory as a whole in units of operation calculation results, so that more efficient batch data storage instructions can be used to store data, thereby improving performance and efficiency.
[0067] In order to use the batch data storage instruction to store the operation calculation results, it is necessary to ensure that the size of the operation calculation results is the same as the size of the data block. Therefore, the size of the operation area is different according to the different step sizes.
[0068] For example, each operation area includes m×m data blocks, where m is a positive integer. When the step size of the convolution kernel is 1, m=1, that is, each operation area includes 1 data block. When the step size of the convolution kernel is 2, m=2, that is, each operation area includes 4 data blocks in 2 rows and 2 columns. Therefore, when convolution-related operations are performed on each operation area, the size of the operation calculation result obtained by each operation area is also w×h, so that the operation calculation result can be used as a unit and stored in the memory as a whole using more efficient batch data storage instructions, thereby improving performance and data storage efficiency.
[0069] Different operation areas do not overlap with each other, that is, a data block belongs to only one operation area, and does not belong to multiple operation areas.
[0070] Figure 4 A schematic diagram of performing a convolution operation on a data block according to at least one embodiment of the present disclosure.
[0071] like Figure 4 As shown, each rectangular box on the right (2) represents a data block into which the input matrix is divided, for example Figure 4 In FIG. 1 , data blocks B1, B2, ..., B8, and B9 are shown. Of course, the input matrix may also include more data blocks, which are not shown one by one here. Each data block includes w rows and h columns of elements. For example, Figure 4 In the example, w may be equal to 4 and h may be equal to 8. Of course, the present disclosure is not limited thereto.
[0072] like Figure 4 As shown, the left side (1) is the structure of data block B5, which includes 4 rows and 8 columns of elements. Figure 4 The dotted box in the figure shows a 3×3 convolution kernel. Figure 4 is a schematic diagram showing the convolution operation of the element located at the upper left corner of the data block B5. The convolution kernel slides on the input matrix in the convolution sliding direction (e.g., from left to right, from top to bottom), and the weight in the convolution kernel is multiplied by the element at the corresponding position. The cumulative sum of the 9 multiplication results is used as the convolution calculation result corresponding to an element in the input matrix. The specific process will not be repeated here.
[0073] For example, in at least one embodiment of the present disclosure, the convolution operation for each operation area can refer to Figure 4 The multiplication and accumulation process shown is performed.
[0074] In step S101, the data blocks required for performing convolution-related operations in each operation area are loaded from the memory to the cache component in sequence in units of data blocks, so as to perform convolution-related operations on the data blocks in each operation area in sequence.
[0075] For example, the data blocks required for each operation area when performing convolution-related operations include multiple data blocks adjacent to the operation area in a preset direction, and data blocks in the operation area. Here, the preset direction includes an orthogonal direction and a diagonal direction.
[0076] For example, the orthogonal directions include directly above, directly below, directly to the left, and directly to the right, and the diagonal directions include upper left, lower left, upper right, and lower right.
[0077] Figure 5A and Figure 5B A schematic diagram of the data block position relationship provided for at least one embodiment of the present disclosure.
[0078] For example, if the operation area includes 1 data block, such as Figure 5A Data block 5 in, such as Figure 5A As shown, the data blocks adjacent to the operation area in the orthogonal direction may be data block 2 adjacent to the upper side of data block 5, data block 8 adjacent to the lower side of data block 5, data block 4 adjacent to the left side of data block 5, and data block 6 adjacent to the right side of data block 5. The data blocks adjacent to the operation area in the diagonal direction may be data block 1 adjacent to the upper left side of data block 5, data block 7 adjacent to the lower left side of data block 5, data block 3 adjacent to the upper right side of data block 5, and data block 9 adjacent to the lower right side of data block 5.
[0079] For example, if the operation area includes m×m data blocks, m is greater than 1, such as Figure 5B The data blocks 6, 7, 10 and 11 in the data block 10, and the data blocks adjacent to the operation area in the orthogonal direction may include: m data blocks adjacent to the topmost column of data blocks in the operation area (for example Figure 5B ), and the m data blocks located directly below the bottom row of data blocks in the operation area (e.g. Figure 5B The data blocks 14 and 15 are located in the operation area, and the m data blocks (for example Figure 5B 5 and 9), and the m data blocks located to the right of the rightmost column of data blocks in the operation area (for example Figure 5B data blocks 8 and 12).
[0080] Similarly, the data blocks adjacent to the operation area in the orthogonal direction may be data block 1, data block 4, data block 13 and data block 16.
[0081] In at least one embodiment of the present disclosure, a data block required for performing convolution-related operations on an operation area is loaded into a cache component at a time, and when performing convolution-related operations on the next operation area in the convolution sliding direction, the data block required for performing convolution-related operations on the next operation area is loaded into the cache component, so that only the currently required data block needs to be loaded into the cache component each time, and more efficient batch data processing instructions that load in units of data blocks are used to improve loading efficiency; a hierarchical storage structure is used to cache the required data in the cache component first, and then transfer it to the corresponding register when calculation needs to be performed, thereby speeding up the data loading process.
[0082] For example, step S101 may include: for a target operation area that currently needs to perform convolution-related operations, loading data blocks required by the target operation area when performing convolution-related operations into a cache component, and performing convolution-related operations on the data blocks in the target operation area; determining the next operation area as the target operation area according to the convolution sliding direction, and loading all data blocks (for example, A, where A is a positive integer greater than 1) required by the next operation area when performing convolution-related operations into the cache component, wherein only the data blocks among the A data blocks that have not been loaded into the cache component are loaded during loading, and the data blocks among the A data blocks that have been loaded into the cache component are retained.
[0083] In at least one embodiment of the present disclosure, data blocks required for performing convolution-related operations in each operation area are loaded in sequence according to the convolution sliding direction. For each operation area containing the same row of data blocks, the data blocks required for performing convolution-related operations are repeated. There are multiple data blocks that can be reused in two adjacent operation areas. At this time, only the data blocks that have not been loaded into the cache component are loaded, and the data blocks that have been loaded in the required data blocks are retained, so that these data blocks can be reused, and the data are highly reused, which reduces the reading of a large amount of duplicate data from the memory.
[0084] For example, for a target operation area that currently needs to perform convolution-related operations, loading data blocks required by the target operation area when performing convolution-related operations to a cache component may include: in response to the target operation area including the first column of data blocks located on the leftmost side of the input matrix: preloading L data blocks in the first column of data blocks to the cache component, wherein the L data blocks include m data blocks in the first column of data blocks belonging to the target operation area, and the L data blocks also include at least one of a first data block and a second data block, the first data block is a data block that is directly adjacent to the topmost data block of the m data blocks and is located on the upper side of the topmost data block, and the second data block is a data block that is directly adjacent to the bottommost data block of the m data blocks and is located on the lower side of the bottommost data block; performing a first operation, wherein the first operation is used to load data blocks that have not been loaded among the data blocks required by the target operation area when performing convolution-related operations, and use the required data blocks to perform convolution-related operations on the target operation area; in response to the target operation area not including the first column of data blocks: performing the first operation.
[0085] For example, when performing convolution-related operations on each operation area in turn in the convolution sliding direction, the convolution-related operations are usually performed starting from the first operation area at the upper left corner. Taking the data block at the upper left corner of the input matrix as the origin and the data block as the unit, the leftmost column of data blocks in the input matrix is determined to be the first column of data blocks, and the top row of data blocks is determined to be the first row of data blocks.
[0086] For example, if the target operation area includes the first column of data blocks, that is, the convolution-related operation is performed on a new row of data blocks, first preload L data blocks in the first column of data blocks to the cache component. When the target operation area includes the first row of data blocks, L=m+1, and when the target operation area does not include the first row of data blocks, L=m+2.
[0087] The L data blocks at least include m data blocks in the first column of data blocks belonging to the target operation area. In some embodiments, if the target operation area includes the first row of data blocks at the top of the input matrix, the L data blocks also include the second data block but do not include the first data block. If the target operation area does not include the first row of data blocks, the L data blocks include the first data block and the second data block. In other embodiments, if the target operation area includes the last row of data blocks, the L data blocks also include the first data block but do not include the second data block.
[0088] In addition, L×m data blocks located on the right side of the L data blocks and adjacent to the L data blocks are also loaded into the cache unit, where the L×m data block array is arranged as L rows and m columns, and the leftmost column of the L×m data blocks is directly adjacent to the L data blocks.
[0089] Thus, all data blocks required by the target operation area are loaded.
[0090] Afterwards, convolution related operations are performed on the target operation area.
[0091] Afterwards, the next operation area for performing convolution-related operations is determined as a new target operation area according to the convolution sliding direction, and the data blocks that have not been loaded among the data blocks required by the new target operation area are loaded into the data blocks of the cache component.
[0092] For example, in response to the operating area including the topmost row of data blocks and the leftmost column of data blocks in the input matrix, the orthogonal directions include directly below and directly to the right, and the diagonal directions include the lower right; in response to the operating area including the first row of data blocks but not including the first column of data blocks, the orthogonal directions include directly to the left, directly below and directly to the right, and the diagonal directions include the lower left and lower right; in response to the operating area not including the first row of data blocks, the orthogonal directions include directly above, directly below, directly to the right and directly left, and the diagonal directions include the lower left, lower right, upper left and upper right.
[0093] For example, in response to the step size of the convolution-related operation being 1, m=1, if the target operation area includes a data block located in the ath row and bth column of the input matrix, a and b are positive integers, the first operation includes the following process: in response to a=1, using a batch data loading instruction to load two data blocks located in the b+1th column and from the ath row to the a+1th row in the input matrix to the cache component; in response to a being greater than 1, using a batch data loading instruction to load three data blocks located in the b+1th column and from the a-1th row to the a+1th row in the data blocks in the b+1th column of the input matrix to the cache component; performing convolution-related operations on the data blocks in the target operation area.
[0094] For example, in response to the step size of the convolution-related operation being 2, m=2, the target operation area includes 2×2 data blocks located from the ath row to the a+1th row and from the bth column to the b+1th column in the input matrix, a and b are positive integers, and the first operation includes the following process: in response to a=1, use a batch data loading instruction to load 6 data blocks located from the ath row to the a+2th row and from the b+1th column to the b+2th column in the input matrix to the cache unit; in response to a being greater than 1, use a batch data loading instruction to load 8 data blocks located from the a-1th row to the a+2th row and from the b+1th column to the b+2th column in the input matrix to the cache unit; perform convolution-related operations on the data blocks in the target operation area.
[0095] The following describes in detail the processing of the data processing method provided by at least one embodiment of the present disclosure when the step size of the convolution kernel is 1 and 2 with reference to the accompanying drawings.
[0096] Fig. 6A A schematic diagram of an input matrix provided by an embodiment of the present disclosure, Figure 6B and Figure 6C At least one embodiment of the present disclosure provides Fig. 6A Schematic diagram of the processing process of executing the data processing method on the input matrix shown.
[0097] like Fig. 6A As shown, the input matrix is divided into multiple data blocks. Fig. 6A Each rectangular box represents a data block, and each data block consists of h rows and w columns of elements. The specific structure can be referred to above Figure 4 The relevant description will not be repeated here.
[0098] Fig. 6A In the diagram, the upper left corner data block is taken as the origin, the horizontal coordinate is represented by col, and the vertical coordinate is represented by row. The coordinates of the upper left corner data block are col=1, row=1. The first row at the top is the first row data block (row = 1), the second row is the second row data block (row = 2), and so on; the first column on the left is the first column data block (col = 1), the second column is the second column data block (col = 2), and so on.
[0099] Figure 6B The figure shows the case where the convolution kernel step size is 1, in which case m=1, that is, each operation area includes 1 data block. Figure 6B In the figure, a rectangular box with a dark background and lines represents a target operation area, a rectangular box with a white background and lines represents a data block that has been loaded and cached in the cache component, and a white rectangular box represents a data block that is not in the cache component.
[0100] like Figure 6B As shown in , when performing the convolution operation for the first time, the data block with the coordinates of row=1, col=1 is used as the target operation area. Figure 6B As shown in (1), since the target operation area includes the first row of data blocks, first use the batch data loading instruction to preload the data block with coordinates row=1, col=1 and the data block with coordinates row=2, col=1 to the cache unit in units of data blocks; then, as shown in Figure 6B As shown in (2), a batch data loading instruction is used to load a data block with coordinates row=1, col=2 and a data block with coordinates row=2, col=2 to a cache unit; then, a convolution-related operation is performed on the target operation area using the loaded data blocks to obtain an operation calculation result, and the operation calculation result is stored in the memory using a batch storage instruction. For example, the convolution-related operation includes a convolution operation or a back propagation calculation of a convolution, and the operation calculation result is, for example, an output feature map obtained by a convolution operation, or an input gradient obtained by a back propagation calculation.
[0101] Afterwards, if Figure 6BAs shown in (3), the data block with coordinates row=1, col=2 is used as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly below, directly to the left, directly to the right, and the data blocks at the lower left and lower right. Among these data blocks, only the data blocks with coordinates row=1, col=3 and row=2, col=3 have not been loaded. Use the batch data loading instruction to load these two data blocks into the cache component, thereby obtaining all the data blocks required for the convolution-related operations of the target operation area. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0102] Afterwards, if Figure 6B As shown in (4), the data block with coordinates row=1, col=3 is used as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly below, directly to the left, directly to the right, and the data blocks at the lower left and lower right. Among these data blocks, only the data blocks with coordinates row=1, col=4 and row=2, col=4 have not been loaded. Use the batch data loading instruction to load these two data blocks into the cache component, thereby obtaining all the data blocks required for the target operation area to perform convolution-related operations. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0103] For example, in order to occupy as little limited cache space as possible, the data blocks of row=1, col=1 and row=2, col=1 can be discarded.
[0104] For example, the data blocks required by different operation areas when performing convolution-related operations are all loaded into the same fixed-capacity storage area in the cache component. In response to the step size of 1, the storage capacity of the storage area is 9 times the total amount of data of a single data block. For example, a limited storage space is reserved in advance for convolution-related operations to cache the data blocks required by the target operation area currently performing convolution-related operations, without affecting the resource allocation of other operators, and making full use of the limited storage resources of the cache component.
[0105] For example, the loaded data blocks with coordinates row=1, col=4 and row=2, col=4 may overwrite the data blocks with coordinates row=1, col=1 and row=2, col=1 previously cached in the cache component.
[0106] After that, continue to repeat the above process until the convolution-related operations of the first row of data blocks are completed.
[0107] Then, convolution related operations are performed on the second row of data blocks one by one.
[0108] like Figure 6B As shown in (5) in , since the target operation area does not include the first row of data blocks, first use the batch data loading instruction to preload the data blocks with coordinates row=1,col=1, row=2,col=1 and row=3,col=1 to the cache unit; then, as Figure 6B As shown in (6), a batch data loading instruction is used to load data blocks with coordinates of row=1,col=2, row=2,col=2, and row=3,col=2 into the cache component; then, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using a batch storage instruction.
[0109] Afterwards, if Figure 6B As shown in (7), the data block with coordinates row=2, col=2 is used as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly above, directly below, directly to the left, directly to the right, and the data blocks at the upper left, lower left, upper right, and lower right. Among these data blocks, only the data blocks with coordinates row=1, col=3, row=2, col=3, and row=3, col=3 have not been loaded. These three data blocks are loaded into the cache unit using the batch data loading instruction, thereby obtaining all the data blocks required for the target operation area to perform convolution-related operations. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0110] Afterwards, if Figure 6B As shown in (8), the data block with coordinates row=2, col=3 is used as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly above, directly below, directly to the left, directly to the right, and the data blocks at the upper left, lower left, upper right, and lower right. Among these data blocks, only the data blocks with coordinates row=1, col=4, row=2, col=4, and row=3, col=4 have not been loaded. These three data blocks are loaded into the cache unit using the batch data loading instruction, thereby obtaining all the data blocks required for the target operation area to perform convolution-related operations. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0111] For example, in order to occupy as little limited cache space as possible, the data blocks with row=1, col=1, row=2, col=1, row=3, col=1 can be discarded. For example, the loaded data blocks with coordinates row=1, col=4, row=2, col=4, row=1, col=4, row=3, col=4 can overwrite the data blocks with coordinates row=1, col=1, row=2, col=1, row=3, col=1 previously cached in the cache component.
[0112] Figure 6C The figure shows the case where the convolution kernel step size is 2, in which case m=2, that is, each operation area includes 2×2 data blocks. Figure 6C In the figure, a rectangular box with a dark background and lines represents a target operation area, a rectangular box with a white background and lines represents a data block that has been loaded and cached in the cache component, and a white rectangular box represents a data block that is not in the cache component.
[0113] like Figure 6C As shown, when performing the convolution operation for the first time, the data blocks with coordinates row=1, col=1, row=1, col=2, row=2, col=1 and row=2, col=2 are used as the target operation area. Figure 6C As shown in (1), since the target operation area includes the first row of data blocks, first use the batch data loading instruction to preload the data block with coordinates row=1, col=1, row=2, col=1 and row=3, col=1 to the cache unit in units of data blocks; then, as Figure 6C As shown in (2), a batch data loading instruction is used to load data blocks with coordinates of row=1,col=2, row=2,col=2, row=3,col=2, row=1,col=3, row=2,col=3, and row=3,col=3 into the cache component; then, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using a batch storage instruction.
[0114] Afterwards, if Figure 6CAs shown in (3), the data blocks with coordinates of row=1,col=3, row=1,col=4, row=2,col=3 and row=2,col=4 are taken as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly below, directly to the left, directly to the right, and the data blocks at the lower left and lower right of the target operation area. Among these data blocks, only the data blocks with coordinates of row=1,col=4, row=2,col=4, row=3,col=4, row=1,col=5, row=2,col=5 and row=3,col=5 have not been loaded. The batch data loading instruction is used to load these 6 data blocks into the cache unit, thereby obtaining all the data blocks required for the convolution-related operations of the target operation area. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0115] For example, in order to occupy as little limited cache space as possible, three data blocks from the first row to the third row in the first column originally cached in the input matrix may be discarded or overwritten.
[0116] Afterwards, if Figure 6C As shown in (4), the data blocks with coordinates of row=1,col=5, row=1,col=6, row=2,col=5 and row=2,col=6 are taken as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly below, directly to the left, directly to the right, and the data blocks at the lower left and lower right of the target operation area. Among these data blocks, only the data blocks with coordinates of row=1,col=6, row=2,col=6, row=3,col=6, row=1,col=7, row=2,col=7 and row=3,col=7 have not been loaded. The batch data loading instruction is used to load these 6 data blocks into the cache unit, thereby obtaining all the data blocks required for the convolution-related operations in the target operation area. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using the batch storage instruction.
[0117] For example, in order to occupy the limited cache space as little as possible, the six data blocks from the first row to the third row and the second column to the third column originally cached in the input matrix can be discarded.
[0118] For example, the data blocks required by different operation areas when performing convolution-related operations are all loaded into the same fixed-capacity storage area in the cache component. In response to the step size of 2, the storage capacity of the storage area is 16 times the total amount of data of a single data block.
[0119] For example, the loaded data blocks with coordinates row=1,col=6, row=2,col=6, row=3,col=6, row=1,col=7, row=2,col=7, and row=3,col=7 can cover the six data blocks from the first to the third rows and the second to the third columns in the original cached input matrix in the cache component.
[0120] After that, continue to repeat the above process until the convolution-related operations of the first row of data blocks are completed.
[0121] Then, convolution related operations are performed on the second row of data blocks one by one.
[0122] like Figure 6C As shown in (5), the data blocks with coordinates row=3, col=1, row=3, col=2, row=4, col=1 and row=4, col=2 are taken as the target operation area. Since the target operation area does not include the first row of data blocks, firstly, a batch data loading instruction is used to preload the data blocks with coordinates row=2, col=1, row=3, col=1, row=4, col=1 and row=5, col=1 into the cache unit in units of data blocks; then, as shown in Figure 6C As shown in (6), 8 data blocks are loaded into the cache component using a batch data loading instruction, and the coordinates of the 8 data blocks are row greater than or equal to 2 and less than or equal to 5, and col is equal to 2 or 3. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using a batch storage instruction.
[0123] Afterwards, if Figure 6CAs shown in (7), the data blocks with coordinates row=3,col=3, row=3,col=4, row=4,col=3 and row=4,col=4 are taken as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly above, directly below, directly to the left, directly to the right, and the data blocks at the upper left, lower left, upper right and lower right. Among these data blocks, only 8 data blocks with coordinates row greater than or equal to 2 and less than or equal to 5 and col equal to 4 or 5 have not been loaded. These 8 data blocks are loaded into the cache unit using batch data loading instructions, thereby obtaining all the data blocks required for convolution-related operations in the target operation area. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using batch storage instructions.
[0124] Afterwards, if Figure 6C As shown in (8), the data blocks with coordinates row=3,col=5, row=3,col=6, row=4,col=5 and row=4,col=6 are taken as the target operation area. For the target operation area, the data blocks required for convolution-related operations include the data blocks directly above, directly below, directly to the left, directly to the right, and the data blocks at the upper left, lower left, upper right and lower right. Among these data blocks, only 8 data blocks with coordinates row greater than or equal to 2 and less than or equal to 5, and col equal to 6 or 7 have not been loaded. These 8 data blocks are loaded into the cache unit using batch data loading instructions, thereby obtaining all the data blocks required for convolution-related operations in the target operation area. Afterwards, the loaded data blocks are used to perform convolution-related operations on the target operation area to obtain the operation calculation results, which are stored in the memory using batch storage instructions.
[0125] In the above embodiment, when data is loaded and stored in units of data blocks, the data blocks required for each operation area when performing convolution-related operations are dynamically loaded in sequence according to the convolution sliding direction, that is, only one operation area is loaded at a time to perform convolution-related operations. The data blocks are used to generate the operation calculation results of the operation area, so that more efficient batch data processing instructions can be used, without loading data in units of single elements, reducing the amount of calculation of coordinate points. In the process of iterative calculation of a row of data blocks, data is highly reused to avoid loading a large number of repeated elements. For example, taking a step size of 1 as an example, there are 6 data blocks that can be reused for loading two adjacent operation areas. In fact, only 3 data blocks need to be loaded each time, and the data is highly reused. A cache component is introduced to cache the loaded input tensor, and a hierarchical storage structure is used to speed up the data loading process. In addition, there is no limit on the size of the input matrix, supports multiple convolution kernel step sizes, and can be applied to input matrices of any size. Even if the size of the input matrix is large, for example, the amount of data is greater than the capacity of the cache component, the above data processing method can still be applied to data loading and convolution-related operations.
[0126] At least one embodiment of the present disclosure further provides a data processing device. Figure 7 A schematic block diagram of a data processing device provided for at least one embodiment of the present disclosure.
[0127] The data processing device is used to load an input tensor from a memory into a cache unit of a processor for performing convolution-related operations, wherein the input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers greater than 1, and the elements in the input matrix are arrayed into a plurality of data blocks of size w×h, w and h are positive integers greater than 1.
[0128] For example, the convolution-related operation includes a convolution operation or a back-propagation calculation of a convolution. The convolution-related operation uses a convolution kernel with a size greater than 1×1.
[0129] For example, a convolution operation includes convolving each input matrix with a corresponding convolution kernel. For example, a backpropagation calculation of a convolution includes calculating the gradient of a loss function with respect to the convolution kernel parameters.
[0130] For example, convolution-related operations include channel-by-channel convolution and back propagation calculations of channel-by-channel convolution. For example, the input tensor includes an input matrix of C channels, where C is a positive integer. Of course, as mentioned above, the input tensor may also include N dimensions.
[0131] For the contents of convolution related operations, please refer to the relevant description in the aforementioned data processing method, which will not be repeated here.
[0132] like Figure 7As shown, the data processing device 200 includes a processing module 201 .
[0133] For example, the processing module 201 is configured to perform convolution-related operations on each operation area in sequence according to the convolution sliding direction for each input matrix, taking the operation area as a unit, so as to obtain an output matrix corresponding to the input matrix.
[0134] For example, each operation area includes a portion of the data blocks among the multiple data blocks, and different operation areas do not overlap with each other.
[0135] For example, when the processing module 201 performs convolution-related operations on each operating area in sequence according to the convolution sliding direction, it includes executing the following steps: in units of data blocks, the data blocks required by each operating area when performing convolution-related operations are loaded from the memory to the cache component in sequence, so as to perform convolution-related operations on the data blocks in each operating area in sequence, wherein the data blocks required by each operating area when performing convolution-related operations include multiple data blocks adjacent to the operating area in a preset direction, as well as data blocks in the operating area, and the preset direction includes an orthogonal direction and a diagonal direction.
[0136] For example, the processing module 201 includes codes and programs stored in a memory. 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 processing module 201 executes the code and program to implement some or all of the functions of the processing module 201 described above. For example, the processing module 201 can be a circuit board or a combination of multiple circuit boards, which is used to implement the functions described above. In an 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.
[0137] It should be noted that the processing module 201 can be used to implement Figure 3 The step S10 shown. Therefore, the specific description of the functions that the processing module 201 can achieve can refer to the relevant description of step S10 in the embodiment of the above data processing method, and the repeated parts will not be repeated. In addition, the data processing device 200 can achieve technical effects similar to the above data processing method, which will not be repeated here.
[0138] It should be noted that in at least one embodiment of the present disclosure, the data processing device 200 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.
[0139] For example, the data processing device 200 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.
[0140] 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.
[0141] 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 Fig.10 The electronic device 500 shown. The electronic device 500 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 (HPC) and artificial intelligence (AI) in the electronic device 500 related to convolution operations, such as tensor computing units, etc. Of course, the present disclosure is not limited to this, and any scenario, device, apparatus, etc. involving convolution operations can adopt the data processing method or data processing apparatus provided by at least one embodiment of the present disclosure.
[0142] 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 involving convolution operations (especially channel-by-channel convolution and back propagation computation of channel-by-channel convolution).
[0143] It should be noted that the input 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.
[0144] For example, in the field of speech processing, the input tensor can be the input parameters of convolution operations involved in tasks such as feature extraction, speech enhancement, and speech recognition, such as speech feature vectors.
[0145] For example, in the field of image processing, the input tensor can be the input parameters of convolution operations involved in tasks such as image recognition, feature extraction, image segmentation, object detection, image classification, and scene reconstruction, such as image feature vectors.
[0146] For example, in the field of text processing, the input tensor can be the input parameters of convolution operations involved in tasks such as text classification, sentiment analysis, and text generation, such as the semantic feature vector of the text.
[0147] For example, in the field of video processing, the input tensor can be the input parameters in the image processing field as mentioned above, or input parameters involving convolution operations that are specific to the video processing field, such as the optical flow operator (used to estimate motion between video frames), the target tracking operator (used to track specific targets in the video), etc.
[0148] Of course, the present disclosure is not limited to this. For other application scenarios or fields, as long as convolution operations are required, especially channel-by-channel convolution and back propagation calculations of channel-by-channel convolution, the data processing method described in at least one embodiment of the present disclosure can be applied, and they will not be described one by one here.
[0149] Figure 8 A schematic structural diagram of a processor provided in at least one embodiment of the present disclosure. Figure 8 As shown, the processor 300 includes an instruction parsing unit 301 , an execution unit 302 , a memory 303 and a cache unit 304 .
[0150] For example, the instruction parsing unit 301 is used to receive and parse data processing instructions.
[0151] For example, the data processing instruction is used to load the input tensor from the memory 303 to the cache component 304 and perform convolution-related operations. 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 tensor from the memory 303 to the cache component 304, and the calculation instruction is used to perform convolution-related operations on the input tensor, such as convolution operations or back propagation calculations of convolutions.
[0152] For example, the cache component 304 may include a shared memory. Figure 2 The graphics processor or general-purpose graphics processor shown.
[0153] For example, the input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers, the elements in the input matrix are arrayed into multiple data blocks of size w×h, w and h are positive integers greater than 1, and the size of the convolution kernel used in convolution-related operations is greater than 1×1.
[0154] For example, the execution unit 302 executes the data processing instruction after the instruction parsing unit parses the data processing instruction.
[0155] 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.
[0156] For example, the execution unit 302 may include hardware involved in executing data processing instructions, such as a multiplier, a register, a queue, an ALU (Arithmetic Logic Unit), and the like.
[0157] For example, when executing a data processing instruction, the execution unit 302 includes performing the following operations: for each input matrix, taking the operation area as a unit, performing convolution-related operations on each operation area in turn according to the convolution sliding direction to obtain an output matrix corresponding to the input matrix, wherein each operation area includes a partial data block among multiple data blocks, and different operation areas do not overlap with each other.
[0158] For example, convolution-related operations are performed on each operating area in sequence according to the convolution sliding direction, including: in units of data blocks, the data blocks required by each operating area when performing convolution-related operations are loaded from the memory in sequence to the cache component to perform convolution-related operations on the data blocks in the operating area, wherein the data blocks required by each operating area when performing convolution-related operations include multiple data blocks adjacent to the operating area in a preset direction, and the data blocks in the operating area, and the preset direction includes an orthogonal direction and a diagonal direction.
[0159] 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 301 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.
[0160] Regarding the specific process of using the execution unit 302 to execute the data processing instruction, reference may be made to step S10 in the aforementioned data processing method, and the repeated parts will not be repeated here.
[0161] 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.
[0162] Fig. 9 A schematic diagram of a non-transitory computer-readable storage medium provided for at least one embodiment of the present disclosure. Fig. 9 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.
[0163] For example, the storage medium 400 may be applied in an electronic device 500 . For example, the storage medium 400 may include a storage device 508 in the electronic device 500 .
[0164] 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.
[0165] 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.
[0166] Fig.10 The following is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Fig.10 As shown, the electronic device 500 is suitable for implementing the data processing method provided by the embodiment of the present disclosure. It should be noted that Fig.10The components of the electronic device 500 shown are merely exemplary and non-limiting. The electronic device 500 may also have other components according to actual application requirements.
[0167] like Fig.10 As shown, the electronic device 500 may include a processing device (eg, a central processing unit, a graphics processing unit, etc.) 501, which may perform various appropriate actions and processes according to non-transitory computer-readable instructions stored in a memory to implement various functions.
[0168] For example, when the computer readable instructions are executed by the processing device 501, 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.
[0169] 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) 503 and / or cache memory (cache), etc. For example, computer-readable instructions may be loaded from storage device 508 into random access memory (RAM) 503 to run computer-readable instructions. Non-volatile memory may include, for example, read-only memory (ROM) 502, 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.
[0170] For example, the processing device 501 , the ROM 502 , and the RAM 503 are connected to one another via a bus 504 . An input / output (I / O) interface 505 is also connected to the bus 504 .
[0171] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, a flash memory, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other electronic devices wirelessly or by wire to exchange data. Although Fig.10An electronic device 500 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 500 may alternatively implement or have more or fewer devices. For example, the processing device 501 can control other components in the electronic device 500 to perform the desired functions. The processing device 501 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.
[0172] 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.
[0173] 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, constitute a limitation on the unit itself.
[0174] 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.
[0175] 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.
[0176] 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.
[0177] 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.
[0178] There are a few points to note about this disclosure:
[0179] (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.
[0180] (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.
[0181] 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 input tensor from a memory into a cache component of a processor for performing a convolution-related operation, wherein: The input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers greater than 1, and the elements in the input matrix are array-divided into a plurality of data blocks of size w×h, w and h are positive integers greater than 1, The size of the convolution kernel used in the convolution-related operations is greater than 1×1. The data processing method comprises: For each input matrix, taking the operation area as a unit, performing the convolution-related operation on each operation area in turn according to the convolution sliding direction, so as to obtain an output matrix corresponding to the input matrix, wherein each operation area includes a part of the multiple data blocks, and different operation areas do not overlap with each other; The convolution-related operations are performed on each operation area in sequence according to the convolution sliding direction, including: The data blocks required by each operation area when performing the convolution-related operations are loaded from the memory to the cache component in sequence in units of data blocks, so as to perform the convolution-related operations on the data blocks in each operation area in sequence, wherein the data blocks required by each operation area when performing the convolution-related operations include a plurality of data blocks adjacent to the operation area in a preset direction, and the data blocks in the operation area, and the preset direction includes an orthogonal direction and a diagonal direction.
2. The data processing method according to claim 1, wherein: The method of sequentially loading data blocks required by each operation area when performing the convolution-related operation from the memory to the cache component in units of data blocks to perform the convolution-related operation on the data blocks in the operation area comprises: For a target operation area that currently needs to perform the convolution-related operation, load the data blocks required by the target operation area when performing the convolution-related operation into the cache component, and perform the convolution-related operation on the data blocks in the target operation area; Determine the next operation area as the new target operation area according to the convolution sliding direction, and load all data blocks required by the next operation area when performing the convolution-related operations into the cache component, wherein only the data blocks that have not been loaded into the cache component among all the data blocks are loaded during loading, and the data blocks that have been loaded into the cache component among all the data blocks are retained.
3. The data processing method according to claim 1, wherein: Each operation area includes m×m data blocks, where m is a positive integer. For a target operation area that currently needs to perform the convolution-related operation, loading a data block required by the target operation area when performing the convolution-related operation into the cache component includes: In response to the target operation area including the first column of data blocks located at the leftmost side of the input matrix: Preloading L data blocks in the first column of data blocks to the cache component, wherein the L data blocks include m data blocks in the first column of data blocks belonging to the target operation area, and the L data blocks also include at least one of a first data block and a second data block, the first data block is a data block directly adjacent to the top data block of the m data blocks and located above the top data block, and the second data block is a data block directly adjacent to the bottom data block of the m data blocks and located below the bottom data block; Executing a first operation, wherein the first operation is used to load data blocks that have not been loaded among the data blocks required by the target operation area when performing the convolution-related operation, and perform the convolution-related operation on the target operation area using the required data blocks; In response to the target operation area not including the first column of data blocks: The first operation is performed.
4. The data processing method according to claim 3, wherein: In response to the step size of the convolution-related operation being 1, m=1, the target operation area includes a data block located at the ath row and the bth column in the input matrix, where a and b are positive integers, The first operation includes the following process: In response to a=1, two data blocks located in the ath row to the a+1th row in the b+1th column data block in the input matrix are loaded into the cache component, In response to a being greater than 1, loading three data blocks located in the a-1th row to the a+1th row in the b+1th column data block in the input matrix into the cache component; The convolution-related operation is performed on the data block in the target operation area.
5. The data processing method according to claim 3, wherein: In response to the step size of the convolution-related operation being 2, m=2, the target operation area includes 2×2 data blocks located from the ath row to the a+1th row and from the bth column to the b+1th column in the input matrix, where a and b are positive integers, The first operation includes the following process: In response to a=1, six data blocks located at rows a to a+2 and columns b+1 to b+2 in the input matrix are loaded into the cache component, In response to a being greater than 1, loading 8 data blocks located from the a-1th row to the a+2th row and from the b+1th column to the b+2th column in the input matrix into the cache component; The convolution-related operation is performed on the data block in the target operation area.
6. The data processing method according to claim 3, wherein: In response to the target operation area including the topmost first row of data blocks in the input matrix, the L data blocks include the second data block but do not include the first data block, In response to the target operation area not including the first row of data blocks, the L data blocks include the first data block and the second data block.
7. The data processing method according to any one of claims 1 to 6, wherein: In response to the operating area including the topmost first row data block and the leftmost first column data block in the input matrix, the orthogonal direction includes directly below and directly to the right, and the diagonal direction includes the lower right; In response to the operating area including the first row data block but not including the first column data block, the orthogonal direction includes the left, the bottom and the right, and the diagonal direction includes the lower left and the lower right; In response to the operating area not including the first row of data blocks, the orthogonal direction includes directly above, directly below, directly to the right and directly to the left, and the diagonal direction includes the lower left, the lower right, the upper left and the upper right.
8. The data processing method according to any one of claims 1 to 6, wherein: The convolution-related operations include channel-by-channel convolution and back propagation calculation of channel-by-channel convolution. The channel-by-channel convolution includes applying the corresponding convolution kernel to each input matrix to obtain an output matrix corresponding to the input matrix. The back propagation calculation of the channel-by-channel convolution includes performing gradient calculation on each input matrix to obtain an output matrix corresponding to the input matrix, wherein, in response to the convolution-related operation being the back propagation calculation of the channel-by-channel convolution, the elements in the input matrix represent the output gradients, and the elements in the output matrix represent the input gradients.
9. The data processing method according to any one of claims 1 to 6, wherein: The cache component includes a shared memory.
10. The data processing method according to any one of claims 1 to 6, wherein: The data blocks required by different operation areas when performing the convolution-related operations are all loaded into the same storage area with a fixed capacity in the cache component.
11. The data processing method according to claim 10, wherein: In response to the step size of the convolution-related operation being 1, the storage capacity of the storage area is 9 times the total amount of data of a single data block, In response to the step size of the convolution-related operation being 2, the storage capacity of the storage area is 16 times the total amount of data of a single data block.
12. The data processing method according to any one of claims 1 to 6, wherein: The size of the operation calculation result of each operation area is the same as the size of the data block. The output matrix includes the operation calculation results of each operation area in the input matrix, The operation calculation result of each operation area is stored in the memory as a whole in units of the operation calculation result.
13. The data processing method according to claim 2, wherein: The data blocks cached in the cache component are loaded into registers for calculation when performing the convolution-related operations on the target operation area.
14. A processor comprising an instruction parsing unit, an execution unit, a memory and a cache component, wherein: The instruction parsing unit is used to receive and parse data processing instructions, wherein the data processing instructions are used to load input tensors from the memory to the cache component and perform convolution-related operations, The execution unit executes the data processing method according to any one of claims 1 to 13 after the instruction parsing unit parses the data processing instruction.
15. A data processing device for loading an input tensor from a memory into a cache component of a processor for performing a convolution-related operation, wherein: The input tensor includes at least one input matrix, each input matrix has a size of W×H, W and H are positive integers greater than 1, and the elements in the input matrix are array-divided into a plurality of data blocks of size w×h, w and h are positive integers greater than 1, The size of the convolution kernel used in the convolution-related operations is greater than 1×1. The data processing device comprises: The processing module is configured to perform the convolution-related operation on each operation area in sequence according to the convolution sliding direction for each input matrix, taking the operation area as a unit, so as to obtain an output matrix corresponding to the input matrix, wherein each operation area includes a part of the multiple data blocks, and different operation areas do not overlap with each other; Wherein, when the processing module performs the convolution-related operations on each operation area in sequence according to the convolution sliding direction, the processing module includes executing the following steps: The data blocks required by each operation area when performing the convolution-related operations are loaded from the memory to the cache component in sequence in units of data blocks, so as to perform the convolution-related operations on the data blocks in each operation area in sequence, wherein the data blocks required by each operation area when performing the convolution-related operations include a plurality of data blocks adjacent to the operation area in a preset direction, and the data blocks in the operation area, and the preset direction includes an orthogonal direction and a diagonal direction.
16. 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-13 is implemented.
17. 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 13 is implemented.
