Adaptive tensor convolution kernel for sparse neural networks
Adaptive tensor computation kernels in neural networks dynamically adjust dimensions and operation modes to address inefficiencies in PE arrays, enhancing computational efficiency and resource utilization by supporting varying tensor shapes and sparsity levels.
Patent Information
- Application Number
- JP2024548397
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2022-02-16
- Filing Date
- 2023-02-13
- Publication Date
- 2026-12-04
- Estimated Expiration
- 2043-02-13
AI Technical Summary
Deep learning processing element (PE) arrays in neural networks are inefficient due to inflexible native tensor shapes and operation modes that cannot accommodate varying tensor shapes and operations, particularly in sparse neural networks with sparsity characteristics, leading to suboptimal resource utilization and parallelism.
Adaptive tensor computation kernels dynamically adjust their dimensions and operation modes to accommodate varying input tensor shapes and operations, supporting 1x1 and 3x3 tensor computation modes, and configure PE array buffers based on sparsity granularities to optimize parallel processing.
This approach enhances computational efficiency by maximizing parallel processing and resource utilization in neural networks, adapting to diverse tensor shapes and sparsity levels within the same network, thereby improving performance and reducing computational overhead.
Smart Images

Figure 0007961291000001 
Figure 0007961291000002 
Figure 0007961291000003
Abstract
Description
TECHNICAL FIELD
[0001] This disclosure generally relates to improving the computational efficiency of neural networks, and more particularly, to dynamically adjusting the dimensions and operation modes of native tensors to adapt to various input tensor shapes and operations of sparse neural networks. BACKGROUND ART
[0002] Deep learning PE (processing element) arrays are almost entirely defined by the dimensions and operation modes of native tensors, and typically rely on compilers to use various nested loop mapping approaches to accommodate different tensor shapes (e.g., input feature maps and filters) and operations. It is clearly inefficient to use a PE array to perform calculations for tensor shapes and operations that are incompatible with the native tensor dimensions and operation modes of the PE array. This incompatibility is further exacerbated in sparse neural networks with sparsity characteristics, because the inflexible native tensor shapes and operation modes of the PE array cannot efficiently represent or process tensors with a large number of zeros. SUMMARY OF THE INVENTION
[0003] Various embodiments of the present specification may include systems, methods, and non-transitory computer-readable media for using adaptive tensor computation kernels in neural network computations.
[0004] According to one embodiment, a method for using an adaptive tensor computation kernel in neural network computation is to receive a first input feature map (IFM) and one or more first filters in the first layer of a convolutional neural network (CNN) for convolution using a processing element (PE) array, wherein each PE in the PE array comprises (Y1) multipliers, and the PE array is arranged in (Y2) rows and (X) columns, and to determine the native tensor shape based on the first IFM and one or more first filters, wherein the native tensor shape comprises a first outer dimension, an inner dimension, and a second outer dimension. The native tensor shape includes the first IFM and one or more first filters, which are mapped to a PE array, and the second layer of the CNN performs convolution using the PE array, receiving the second IFM and one or more second filters, and reshaping the native tensor shape based on the second IFM and one or more second filters, the reshaping which includes expanding the internal dimension and shrinking one of the first external dimension and the second external dimension, the expansion and shrinking which are performed by coefficient F, and the reshaped The method may include supplying one or more second filters and second IFMs to a PE array to perform a convolution according to a native tensor, wherein if the first external dimension is reduced, the convolution obtains a partial sum by summing the outputs from the same row of the PE over F rounds, and if the second external dimension is reduced, the convolution obtains a partial sum by summing the outputs from all F times rows of the PE, and obtaining the output tensor of the convolution in the second layer of the CNN by summing multiple partial sums, wherein Y1, Y2, X, and F are all integers greater than 1.
[0005] In some embodiments, the second layer of the CNN is located after the first layer of the CNN, and the second IFM has more input channels than the first IFM and a lower resolution than the first IFM.
[0006] In some embodiments, each of one or more second filters comprises multiple channels of a two-dimensional (2D) kernel, each 2D kernel having dimensions of 1 × 1 (one by one) or 3 × 3 (three by three).
[0007] In some embodiments, supplying one or more second filters to a PE array according to a deformed native tensor includes transforming one or more second filters into a matrix according to the first external and internal dimensions of the deformed native tensor, wherein, if each 2D kernel of one or more second filters has a 1x1 (one by one) dimension, each row of the matrix contains weights from different input channels of one or more second filters; and distributing the weights of each row of the matrix to different columns of the PE so that multiple input channels are processed simultaneously at one time.
[0008] In some embodiments, supplying one or more second filters to a PE array according to a modified native tensor includes transforming one or more second filters into a matrix according to the first external and internal dimensions of the modified native tensor, such that if each 2D kernel of one or more second filters has dimensions of 3x3 and contains 9 weights, the 9 weights are placed in the same row of the matrix; and distributing the 9 weights from the same row of the matrix to different columns of the PE so that weights from the same channel are processed simultaneously at one time.
[0009] In some embodiments, supplying an IFM to a PE array according to a deformed native tensor includes transforming the IFM into a matrix according to the internal and second external dimensions of the deformed native tensor, and supplying the input values of the IFM corresponding to the columns of the matrix to the row buffers of the PE.
[0010] In some embodiments, the method further includes dividing the channels of one or more filters into a plurality of channel groups, each channel group containing a constant channel that is an integer greater than 1, and pruning each of the one or more filters such that only some channels in each of the plurality of channel groups contain non-zero input values, and all other channels in each channel group contain zero. After pruning, each of the plurality of channel groups contains weights in the same proportion as the non-zero weights.
[0011] In some embodiments, the method may further include determining the depth of the buffer associated with each PE in the PE array. If the buffer depth is greater than a constant, the buffer is configured as private memory for each PE; if the buffer depth is less than a constant, the buffer of the PE is combined with one or more buffers of adjacent PEs as shared memory.
[0012] In some embodiments, the private memory of each PE stores input values obtainable by (Y1) multipliers within the PE.
[0013] In some embodiments, the shared memory stores input values obtainable by the PE and (Y1) multipliers in one or more adjacent PEs.
[0014] In some embodiments, each row of the PE is associated with (Y1) adder trees corresponding to (Y1) multipliers within each PE, and each multiplier within each PE sends an integral power to the corresponding adder tree for summation.
[0015] In some embodiments, each of one or more second filters includes a plurality of non-zero weights, and feeding one or more second filters to a PE array for convolution includes feeding each non-zero weight as an index-value pair including the non-zero weight and the corresponding index to the multiplier of the corresponding PE, and the convolution includes taking an input value from the buffer of the corresponding PE according to the index, sending the taken value and the non-zero weight to the multiplier to take an output, and sending the output to the corresponding adder tree to sum with the outputs produced by other multipliers of other PEs in the same row as the corresponding PE.
[0016] In some embodiments, the (Y1) multipliers within each PE process the data in parallel, and the PEs within the PE array process the data in parallel.
[0017] In yet another embodiment, the system may comprise one or more processors and one or more non-temporary computer-readable memories coupled to the one or more processors and consisting of instructions executable by the one or more processors, and configured to cause the system to perform any of the methods described herein.
[0018] In yet another embodiment, a non-temporary computer-readable storage medium may consist of instructions executable by one or more processors such that one or more processors perform any of the methods described herein.
[0019] The functions and other features of the systems, methods, and non-temporary computer-readable media disclosed herein, as well as the operation and function of related elements of the structure, and some combinations and the economy of the manufacturer, will be more clearly illustrated by considering the appended claims with reference to the following description and the appended drawings, all of which constitute part of this specification, and similar reference numbers refer to the corresponding parts in various figures. However, it should be understood that the drawings are for illustrative and illustrative purposes only and are not intended to limit the invention. [Brief explanation of the drawing]
[0020] [Figure 1] Figure 1 shows exemplary system diagrams for neural network computation processing in PE arrays according to various embodiments. [Figure 2] Figure 2 shows exemplary architectural diagrams of PE arrays according to various embodiments. [Figure 3] Figure 3 shows exemplary neural network computations in PE arrays using native tensor shapes in various embodiments. [Figure 4A] Figure 4A shows exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments. [Figure 4B] Figure 4B shows an exemplary PE array with an inter-cluster adder for neural network computation using adaptive tensor shapes according to various embodiments. [Figure 5A] Figure 5A shows another exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments. [Figure 5B] Figure 5B shows another exemplary PE array with an intra-cluster adder for neural network computation using adaptive tensor shapes according to various embodiments. [Figure 6A] Figure 6A shows an exemplary neural network computation with a 1x1 tensor operation mode according to various embodiments. [Figure 6B] FIG. 6B illustrates an example neural network computation with 3×3 tensor operation mode according to various embodiments. [Figure 7] FIG. 7 is a diagram illustrating an example method of neural network computation using adaptive tensor shape and 3×3 tensor operation mode in a PE array according to various embodiments. [Figure 8] FIG. 8 is a diagram illustrating an example method of neural network computation using adaptive tensor shape according to various embodiments. [Figure 9] FIG. 9 is a diagram illustrating an example computer system in which any of the embodiments described herein may be implemented. DETAILED DESCRIPTION
[0021] Embodiments described herein provide a method, system, and apparatus for neural network computation in a PE array using adaptive tensor shape and operation mode. In the following description, an adaptive tensor computation kernel is described as having multiple native tensor dimensions and operation modes to handle input feature map (IMF) and weight tensor (e.g., filter) of different shapes. According to the input and output tensor shape and operation mode, the dimensions and operation mode of the adaptive tensor computation kernel (also referred to as adaptive native tensor) are dynamically adjusted to fully utilize the underlying hardware resources of the PE array for parallel processing.
[0022] These adaptive tensor computation kernels address the technical challenges in neural network computation (described in the background section) by providing three technical solutions. First, adaptive tensor computation kernels can adapt and adjust their shape to various shapes of input tensors / weight tensors. These various shapes of input tensors / weight tensors exist not only across different neural networks but can also exist within the same neural network pipeline. For example, when processing the first few layers of a neural network, the tensors are typically configured to be high resolution (large height and width) but have fewer input and output channels, while when processing the last few layers of a neural network, the tensors are configured to be low resolution (small height and width) but have more input and output channels. This is thought to be because the first few layers of a neural network focus on feature extraction from input feature maps, while the last few layers focus on learning the underlying correlations between the extracted features.
[0023] Secondly, adaptive tensor computation kernels can support two different tensor computation modes: a 1x1 tensor computation mode and a 3x3 tensor computation mode. In these neural network layers involving matrix multiplication, 1x1 kernel convolutions (e.g., each kernel in the weight tensor has a 1x1 shape) are mapped to the 1x1 tensor computation mode, while other convolutions (3x3, 5x5, 7x7, etc.) can be mapped to the 3x3 tensor computation mode. These different tensor computation modes can be dynamically determined at runtime based on the shape of the weight tensor.
[0024] Thirdly, the underlying PE array can configure each PE's internal buffer (e.g., register file) differently to support different compression ratios and sparsity granularities of sparse neural networks. When a sparse neural network is pruned with finer granularity (e.g., selecting one or more non-zero input channels from a small number of input channels, and that small number is less than a threshold), the register file within each PE can be configured as private memory (e.g., used only by the corresponding PE). When a sparse neural network is pruned with coarser granularity (e.g., selecting one or more non-zero input channels from a large number of input channels, and that large number is greater than a threshold), multiple register files within adjacent PEs can be configured as multi-port memory shared by adjacent PEs.
[0025] In the following description, certain non-limiting embodiments of the present invention will be described with reference to the drawings. Certain features and aspects of any embodiment disclosed herein may be used in conjunction with and / or combined with any other embodiments disclosed herein. It should also be understood that such embodiments are illustrative and only illustrate a small number of embodiments within the scope of the present invention. Various changes and modifications in the art that are obvious to those skilled in the art are considered to be within the spirit, scope, and intent of the present invention, as further defined in the appended claims.
[0026] Figure 1 shows an exemplary system diagram for neural network computation processing in a PE array according to various embodiments. The diagram in Figure 1 shows a typical neural network computation workflow performed in a pipeline using a PE array. Embodiments described herein may be implemented as part of the neural network computation in Figure 1 or in other suitable environments.
[0027] In a given (e.g., convolutional) layer within a neural network (e.g., CNN), one or more input feature maps (IFMs) 120 may be obtained from an input source (e.g., an input image) or a previous layer (e.g., a tensor output from a previous layer), and one or more weight tensors 110 may be used to convolve the IFMs to extract various features. The convolutional operation may be performed in parallel within an array of processing elements (PEs) called a PE array 160. Each PE may refer to a processor having processing power and memory capacity (e.g., a buffer or cache). The PEs may be arranged in a particular way within a PE array with interconnect wiring and may not be dynamically rearranged at runtime. The PE array may be reused and participate in operations in different layers of the neural network or across different neural networks and different use cases. Incompatibility between a fixed internal PE arrangement in a PE array and a potentially infinite number of tensor shapes (in IFMs and / or weight tensors) typically leads to inefficient resource utilization and suboptimal parallelism.
[0028] Referring to Figure 1, in some embodiments, the IFM 120 may be stored in the IFM cache 140, and the weight tensor 110 may be stored in the weight cache 130 for computation in the PE array 160. The PE array 160 may include a matrix of PEs (e.g., X × Y), and each PE may include multiple multipliers for parallel processing. In some embodiments, each IFM from the IFM cache 140 may pass through a matrix transformation layer 150 to facilitate computation in the PE array 160. The matrix transformation may include a Toeplitz matrix transformation that transforms the IFM from the original HWC format (where H is height, W is weight, and C is channel) to the RSC format (where R is row, S is column, and C is channel) using the im2col tool, where the RSC format is determined based on the shape of the weight tensor. Here, transformation means duplicating and arranging the input values in the IFM to form a transformed IFM, so that matrix multiplication between the transformed IFM and the weight tensor is performed in parallel within the PE array 160 while minimizing dependencies between PEs within the PE array 160. In some embodiments, each round of parallel convolution in the PE array 160 may produce multiple partial sums, which may be summed in the cumulative buffer 170 to produce one or more output values. The output values may ultimately become part of the output tensor produced by the current layer.
[0029] Figure 2 shows exemplary architecture diagrams of PE arrays in various embodiments. The arrangement of PEs in the PE array in Figure 2 is illustrative and can be implemented in other ways depending on the use case.
[0030] As shown in the left portion of Figure 2, the PE array 200 may contain a matrix of PEs. As shown in the right portion of Figure 2, each PE 240 may contain multiple multipliers (MUL gates). The multipliers in each PE 240 may be operated in parallel, and the PEs in the PE array 220 may be operated in parallel. For ease of reference, in the following description, the number of columns 220 of PEs in the PE array 200 will be denoted as X, the number of rows 210 of PEs in the PE array 200 will be denoted as Y2, and the number of multipliers in each PE 240 will be denoted as Y1. Each row of PE 210 is called a PE cluster, and each PE cluster may be coupled to a Y1 adder tree (Y1 adder tree) 230 to sum the partial sums generated by the multipliers in the PE cluster. That is, the first multiplier in each PE 240 in the PE cluster is coupled to a first adder tree 230 for summing, the second multiplier in each PE 240 in the PE cluster is coupled to a second adder tree 230 for summing, and so on. The sum of the adder trees 230 (total Y1 × Y2 adder trees) across all PE clusters may be fed to adder 250 for summation. Adder 250 may refer to a digital circuit that performs numerical addition and is part of the network-on-chip (NOC) subsystem.
[0031] In some embodiments, the PE array 200 may broadcast weights to the PEs. In the case of a sparse neural network, the majority of weights are zero, and therefore all weights broadcast to the PEs are non-zero weights. Since non-zero weights can arise from any position in the weight tensor, each broadcasted weight may include not only the weight value but also an index indicating the position of the weight value, i.e., an index-value pair such as (index, weight value). Based on the index, each PE 240 can retrieve the corresponding input value from the IFM and multiply it with the weight value. The multiplication result can be fed to the corresponding adder tree. As shown in Figure 1, the first multiplier MUL1 receives the weight in the form (index 1, value 1), retrieves the input value IFM1 from the IBUF260 (which stores the IFM) based on index 1, multiplies the input value IFM1 based on value 1, and sends the result for summation to the adder tree 1 (e.g., the first adder tree of the Y1 adder tree 230 of the PE cluster where the PEs are located).
[0032] Figure 3 shows an exemplary neural network computation in a PE array using native tensor shapes according to various embodiments. The exemplary computation in Figure 3 involves matrix multiplication between the transformed weight tensor A(310) and the transformed IFM tensor B(320), which generates the output feature map (OFM) tensor C(330). The matrix multiplication uses the native tensor shape corresponding to the PE array 340, which has dimensions X and Y.
[0033] In some embodiments, the transformed weight tensor A(310) is obtained by integrating all the weight tensors in RSC format (3-dimensional) into a 2-dimensional matrix denoted as m'*k' (for example, weights from different channels are rearranged into the same channel), where m' is the number of output channels determined by the number of weight tensors (usually denoted as K) and k' is the product of the R, S, and C dimensions of each weight tensor (R and S refer to the dimensions of each kernel in the weight tensor, and C refers to the number of input channels).
[0034] In some embodiments, the transformed IFM tensor B(320) can be obtained by integrating all IFMs in HWC form (3-dimensional) based on RSC form into a 2-dimensional matrix denoted as k'*n', where k' is still the R, S, and C-dimensional product of each weight tensor, and n' is the H and W-dimensional product of the IFMs (H being the height and W being the width). The matrix product of the matrix m'*k' (weight tensor A(310)) and the matrix k'*n' (IFMB(320)) can produce the OFM tensor C(330) as the matrix m'*n'.
[0035] The above transformation allows the transformed weight tensor A(310) and transformed IFM tensor B(320) to be mapped to PEs in PE array 340 for parallel processing. Assuming that PE array 340 contains PEs with Y2 rows and X columns, and each PE contains Y1 multipliers, tensors A and B can be mapped to PE array 340 as follows: That is, the internal dimension k' of tensors A(310) and tensor B(320) is mapped to the X (row) dimension of PE array 340, i.e., X=k'=R*S*C, and the multiplication of tensors A and tensor B with external dimension m'*=n' is mapped to the Y (column) dimension of PE array 340. Since each column of PE contains a Y1*Y2 multiplier, the above mapping allows the multiplication Y=m'*n'=K*H*W to be processed in parallel by the Y1*Y2 multipliers. For example, within each PE, one multiplier processes the weights corresponding to the same output channel (e.g., weights from the same position across all weight tensors), i.e., Y1=K=m', and each column of the PE processes H*W weights in parallel, i.e., Y2=H*W=n'.
[0036] In the above explanation, the native tensor shape m'*k'*n' is determined to map the workload (e.g., pairs of weights for multiplication and corresponding input values) to the PEs in PE array 340, where X=k' and Y1*Y2=m'*n'. That is, the native tensor shape is determined based on the layout of the PEs in the PE array. Once the layout of the PE array is determined, the shape of the native tensor is also determined. All input tensors (such as IFMs and filter / weight tensors) must be transformed according to the determined native tensor shape. However, input tensors in real-world applications have various shapes, and performing transformations based on the shape of the input tensor rather than the layout of the PEs in PE array 340 allows for optimal parallel processing. In many cases, transformations using a determined native tensor shape determined based on the PE layout may cause some consecutive dependencies between specific PEs (e.g., one PE waiting for the output of another PE), even if they map the workload to the PEs. The following description describes a transformation that uses an adaptive native tensor shape determined based on the dimensions of the IFM and filter, while simultaneously mapping the workload to the PE to maximize parallelism.
[0037] Figure 4A shows an exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments. As described above (Figure 3), if the input tensor (IFM) and weight tensor can be transformed into matrices A(410) and B(420) using a fixed native tensor shape m'*k'*n' (i.e., covering matrices A and B), the transformed tensors can be distributed to the corresponding PE arrays. However, in real-world applications, the IFM and weight tensors used for multiplication (e.g., tensors with different levels of sparsification in different layers of a CNN) may have various shapes that cannot be perfectly mapped to the PE arrays. Forcing tensor transformation using a fixed native tensor shape may result in some PEs being idle or sequential dependencies arising during computation. For example, even within the same convolutional neural network (CNN), the tensors of the first few layers of the CNN may have high resolution (e.g., H*W=64) and a small number of input channels (C=16), while the tensors of the last few layers of the CNN may have low resolution (e.g., H*W=16) and a large number of input channels (C=64). Here, "small" and "large" are determined based on thresholds. In other words, even within the same CNN, different tensor shapes can appear.
[0038] In some embodiments, the shape of the native tensor may be dynamically transformed to accommodate the changing shapes of the input tensor and weight tensor. For example, if the input tensor changes from high resolution (many pixels) with a small number of input channels (e.g., in the first few layers of the CNN) to low resolution with a large number of input channels (e.g., in the last few layers of the CNN), the native tensor shape can be transformed accordingly. In some embodiments, the native tensor shape has three dimensions, indicated as the first external dimension, the internal dimension, and the second external dimension. The first two dimensions (first external dimension and internal dimension) can be used to transform the weight tensor into a matrix, and the last two dimensions (internal dimension and second external dimension) can be used to transform the IFM into a matrix. The transformed matrix can provide guidance on how the weights and input values are mapped to the PE array (e.g., how to distribute the weights and input values to achieve optimal parallelism).
[0039] In some embodiments, if the previous tensor uses a native tensor shape m'*k'*n' for mapping and transformation, and the input tensor has more input channels with lower resolution compared to the previous tensor, the three dimensions of the native tensor shape can be transformed into m'*(F*k')*(n' / F), where F is an integer greater than 1 and represents a scaling factor, with the first two dimensions (i.e., the first external dimension m' and the internal dimension F*k') representing the weight tensor matrix 420, and the next two dimensions (i.e., the internal dimension F*k' and the second external dimension n' / F) representing the IFM tensor matrix 422 for convolution. That is, the native tensor shape can be scaled by the coefficient F in its internal dimension and by the coefficient F in its second external dimension (corresponding to the IFM tensor matrix). This transformation method is sometimes referred to as the k'&n' transformation in the following description. In some embodiments, F is any of 2, 4, 8, etc.
[0040] In some embodiments, the internal dimension F*k' of the transformed tensor shape is shared by the weight tensor matrix 420 and the IFM tensor matrix 422 (e.g., having the same internal dimension) and corresponds to the number of columns of PEs in the PE array; the first external dimension (e.g., the external dimension m' of the weight tensor matrix 420) corresponds to the number of multipliers in each PE; and the second external dimension (e.g., the external dimension n' / F of the IFM tensor matrix 422) corresponds to the number of rows of PEs in the PE array. Here, "corresponds" refers to a mapping relationship that indicates how the weights and input values of the transformed tensor matrices are distributed across the PE array. For example, the weights in each external dimension (e.g., each column) of the weight tensor matrix 420 may be distributed across multipliers in a single PE for parallel processing, and the input values in each external dimension (e.g., each column) of the IFM tensor matrix 422 may be distributed across the rows of PEs in the PE array.
[0041] As shown in Figure 4A, this deformed native tensor shape expands the weight tensor matrix 410 by a factor of F while keeping its external dimension m' the same, thereby forming a new weight tensor matrix 420. That is, the internal dimension of the weight tensor matrix changes from k'=R*S*C (e.g., matrix A in 410) to F*k'=R*S*(F*C) (e.g., matrix A in 420), and as a result, the new matrix 420 can support more input channels (from C to F*C). Similarly, the IFM matrix 412 reduces its external dimension by a coefficient F and expands its internal dimension in the same way as the reduced internal dimension of the weight tensor matrix 420, thereby forming a new IFM tensor matrix 422. That is, the internal dimension of the IFM tensor matrix changes from k'=R*S*C (e.g., matrix B in 412) to F*k'=R*S*(F*C) (e.g., matrix B in 422), and the external dimension of the IFM tensor matrix changes from n' (e.g., matrix B in 412) to n' / F (e.g., matrix B in 422), so that the new matrix 422 may support fewer pixels. Thus, the new matrices 420 and 422 are better suited to representing tensors from the last few CNN layers having lower resolution with fewer input channels. In some embodiments, "the first few CNN layers" and "the last few CNN layers" may refer to the first number of CNN layers counting from the beginning of the CNN structure and the second number of CNN layers counting from the end of the CNN structure, respectively.
[0042] For example, the tensor of the first new CNN layer may be high resolution H*W=64 with a small number of input channels C=16. Here, "small number" refers to a number smaller than the threshold, which can be determined by a compiler configured according to the underlying PE array. The native tensor shape of these tensors from the first few CNN layers may have the shape m'=K=16, k'=1*1*16, n'=64, assuming that the convolution is based on a 1*1 kernel. As the convolution progresses to the last few CNN layers, the tensor may become low resolution H*W=16, and if there are more input channels C=64 (e.g., larger than the threshold), the native tensor shape may be transformed to m'=K=16, k'=1*1*64, n'=16.
[0043] After transforming the tensor using the k'&n' deformation described above, the transformed tensor matrices 420 and 422 can be distributed across PE arrays for parallel processing. Figure 4B shows an exemplary PE array with inter-cluster adders for neural network computation using adaptive tensor shapes based on the k'&n' deformation according to various embodiments. The parallel processing scheme using the PE array shown in Figure 4B may correspond to the k'&n' deformation of the native tensor described in Figure 4A. For consistency, we assume that the PE array has PEs with Y2 rows and X columns, and each PE has Y1 multipliers.
[0044] By manipulating k'&n', the internal dimensions of the weight tensor matrix and the IFM tensor matrix are expanded by a factor of F, and the external dimension of the IFM tensor matrix is reduced by a factor of F. The distribution of weights and input values to the PE array may be such that weights from the same row of the weight tensor matrix (i.e., along the expanded internal dimension / row) and input values from the same column of the IFM tensor matrix (i.e., along the similarly expanded internal dimension / column) are assigned to the PE row by row. This means that these weight-and-input value pairs can be distributed across the F rows of the PE. Thus, the PE array has inter-cluster (i.e., inter-PE cluster or inter-row) adders 400 that add the outputs produced by each row of the PE to obtain partial sums of the convolution process. Each inter-cluster adder 400 can sum the outputs from the Y1 adder tree of the F rows of the PE as Y1 partial sums. These partial sums are summed to construct the output tensor as a result of the convolution. In this process, the sum of the partial sums is Y1*(Y2 / F), which means that the number of output channels (for example, the number of channels in the output tensor of the convolution process) is Y1, and the number of output pixels is Y2 / F = H*W / F.
[0045] Figure 5A shows another exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments. Compared to the k'&n' variations described above, the native tensor shape can also be dynamically modified based on the sparsity of the weight tensor. In many practical applications, the weight tensor in the convolution process can be pruned or sparsified to improve computational efficiency and reduce the neural network footprint. A carefully pruned weight tensor can improve convolution speed without sacrificing feature extraction accuracy by introducing zero-value weights, thereby reducing the total number of computations (e.g., zero-value weights are skipped). In some embodiments, pruning the weight tensor may include dividing the channels (also called filters) of the weight tensor into multiple channel groups such that all channel groups have the same number of channels, and keeping only a small number of channels in each channel group as non-zero input channels (e.g., non-zero weights), while making all other channels in that channel group zero (e.g., all weights are zero). After the pruning process, each channel group contains the same proportion of non-zero weights. In some embodiments, the size of the channel groups for pruning (e.g., the number of channels in each channel group) may be determined based on the number of weight tensors (filters), i.e., the number of output channels. Generally, pruning of weight tensors may be classified into two levels: high weight sparsity, where the number of output channels (e.g., the number of weight tensors) is greater than a first threshold and the number of non-zero input channels is less than a second threshold; and low weight sparsity, where the number of output channels (e.g., the number of weight tensors) is less than a first threshold and the number of non-zero input channels is greater than a second threshold.For example, when the sparsity of the weights is high (16 times), the native tensor shape is m'=K=16 (e.g., 16 weight tensors or filters), k'=3*3*4 (e.g., each kernel is 3*3, and there are 4 non-zero channels in one filter), and n'=64. On the other hand, when the sparsity of the weights is low (4 times), the native tensor shape is m'=K=4 (e.g., 4 weight tensors or filters), k'=3*3*16 (e.g., each kernel is 3*3, and there are 16 non-zero channels in one filter), and n'=64.
[0046] In some embodiments, when the sparsity of the weights changes from high to low, the shape of the native tensor (denoted as first_outer_dimension*inner_dimension*second_outer_dimension) may be deformed by expanding the inner dimension (shared by the weight tensor matrix and the IFM tensor matrix) by a coefficient F and shrinking the first outer dimension (corresponding to the weight tensor matrix) by a coefficient F. As shown in Figure 5A, the original native tensor shape m'*k'*n' becomes (m' / F)*(F*k')*n', the weight tensor matrix 510 changes from m'*k' to a deformed tensor matrix 520 with dimension (m' / F)*(F*k'), and the IFM tensor matrix 512 changes from k'*n' to a deformed IFM matrix 522 with dimension (F*k')*n'. This deformation method may be referred to as the k'&m' deformation in the following description. We show that the internal dimension expanded by coefficient F supports more input channels (from C to F*C), and that the external dimension reduced by the weight tensor matrix supports fewer output channels (from K to K / F).
[0047] After transforming the tensor using the k'&m' deformation described above, the transformed tensor matrices 520 and 522 can be distributed across PE arrays for parallel processing. Figure 5B shows another exemplary PE array with inter-cluster adders for neural network computation using adaptive tensor shapes based on k'&m' deformation according to various embodiments. The parallel processing scheme using the PE array shown in Figure 5B may correspond to the k'&m' deformation of the native tensor described in Figure 5A.
[0048] For consistency, we assume that the PE array has PEs with Y2 rows and X columns, and each PE has Y1 multipliers. Furthermore, the weight matrix 520 and the IFM matrix 522 have identical internal dimensions corresponding to (X) columns of PEs in the PE array, the external dimension of the weight matrix 520 corresponds to (Y1) multipliers in each PE in the PE array, and the external dimension of the IFM matrix 522 corresponds to (Y2) rows of PEs in the PE array.
[0049] The deformed native tensor has a first external dimension of m' / F (corresponding to the external dimension of the weight matrix 520), so that the weights of each column of the weight tensor matrix can be supplied to the Y1 / F multiplier in each PE. To obtain partial sums from the PE array, an intra-cluster adder 500 may be implemented that stores and sums the outputs from the Y1 adder tree for F rounds, where "round" refers to a cycle in which multiplication is performed using the multipliers in the PE. Between each round, the outputs of the Y1 / F multipliers may be temporarily stored in one intra-cluster adder 500. After F rounds, the intra-cluster adder 500 may store F*Y1 / F=Y1 partial sums collected from the Y1 adder tree. These partial sums may be summed to construct an output tensor as a result of convolution. The sum of the partial sums in this process is *Y1 / F)*Y2, which means that the number of output channels (e.g., the number of channels in the output tensor of the convolution process) is Y1 / F and the number of output pixels is Y2=H*W.
[0050] In the field of convolutional neural networks, a weight tensor is sometimes referred to as a 3D filter containing multiple 2D kernels. The number of 2D kernels in each 3D filter is sometimes referred to as the number of channels in the filter, and each 2D kernel may be a 1x1 or 3x3 matrix. Figure 6A shows exemplary neural network computations using the 1x1 (one by one) tensor operation mode (i.e., using 1x1 (one by one) kernels) according to various embodiments, and Figure 6B shows exemplary neural network computations using the 3x3 tensor operation mode (i.e., using 3x3 kernels) according to various embodiments.
[0051] In some embodiments, general matrix multiplication (GEMM) and 1x1 convolution operations may be mapped to 1x1 operation modes (e.g., using 1x1 kernels). As shown in Figure 6A, 2D kernels (i.e., weights) from different input channels (or channel groups for a sparsed input tensor) may be placed in different columns of the PE so that multiple input channels are processed simultaneously at once, and 2D kernels from the same input channel may be distributed among multiple multipliers in a single PE so that the multipliers can process multiple output channels simultaneously at once. For example, the number of weights Y1 from channel 1 (C=1) and the 1~Y1 kernel from the filter (i.e., weights from the same input channel of multiple filters) may be supplied to the first PE, and the number of weights Y1 from channel 2 (C=2) and the 1~Y1 kernel from the filter may be supplied to the second PE. In this way, 2D kernels from different input channels are distributed among the columns of the PE.
[0052] In some embodiments involving a sparsed input tensor, each weight can be represented as an index-value pair. The value of the index-value pair is the value of the non-zero weight, and the index of the index-value pair is the index of the non-zero weight, which can be used to identify the corresponding input value for multiplication in a single multiplier. In some embodiments, if the number of channels is less than the number of PEs in each PE cluster (each row), the remaining PEs can be used for other vector operations.
[0053] In some embodiments, convolution operations other than the 1x1 convolution operation described above may be decomposed into one or more 3x3 convolutions and mapped to a 3x3 native operation mode (e.g., using a 3x3 kernel). As shown in Figure 6B, each 2D 3x3 kernel has nine weights ((0,0), (0,1), (0,2), (1,0), (1,1), (1,2), (2,0), (2,1), (2,2)) from the same input channel, and they can be distributed to the same row (different column) of the PE for simultaneous processing. Nine weights from different input channels can be distributed to different rows of the PE.
[0054] Figure 7 shows exemplary architectural diagrams of internal buffers in an array of PEs according to various embodiments. In some embodiments, each PE in the PE array is coupled with an input buffer (IBUF) 722 for storing input values. These input values can be retrieved by the PE based on a predetermined weight index to find the corresponding input value. The retrieved input value can be multiplied by the weight value in a multiplier in the PE. In practical implementations, the depth of the IBUF is usually limited, and one IBUF 722 can only store input values from a constant number of input channels. Since the number of non-zero input channels is also limited, this design works well for sparsed input tensors. However, it is common for the number of non-zero input channels to exceed the depth of the IBUF 722. In such cases, the IBUF 722 must perform cache substitution to read the required input values from external memory, which is costly and inefficient.
[0055] In some embodiments, the IBUF of each PE can be configured as private memory or shared memory depending on the degree of sparsification of the weight tensor (filter). For example, sparsifying one or more weight tensors may include dividing the input channels of one or more weight tensors into multiple channel groups, where each channel group contains a constant number of channels that are integers greater than 1, and pruning one or more weight tensors so that in each of the multiple channel groups, only a small number of channels in each channel group contain non-zero input values, and all other channels in each channel group contain zeros. That is, after the pruning process, each channel group contains the same proportion of non-zero weights. The granularity of sparsification can be classified into fine-grained 710 and coarse-grained 750. Fine-grained sparsity of 710 occurs when the non-zero input channels are selected from a number of channels smaller than a constant, and coarse-grained sparsity of 750 occurs when the non-zero input channels are selected from a number of channels larger than a constant. For example, if the sparsity of the weights is 15 / 16 (one of the 16 channels is a non-zero input channel), selecting one non-zero input channel for every 16 input channels (e.g., one channel group contains 16 input channels) may be determined as a sparsity of fine grain size 710, while selecting four non-zero input channels for every 64 input channels (e.g., one channel group contains 64 input channels) may be determined as a sparsity of coarse grain size 750.
[0056] In some embodiments, the IBUF722 can be configured as private memory for sparse weight tensors with fine granularity, or as shared memory for sparse tensors with coarse granularity. That is, the depth of the IBUF722 can be compared to a constant used to classify the sparsity of fine and coarse granularity. If the depth of the IBUF722 is greater than the constant, it means that the IBUF722 is sufficient to store the required input values. Thus, dedicated private memory optimizes data acquisition performance. If the depth of the IBUF722 is less than the constant, multiple adjacent PEs share their IBUFs, which are referred to as shared IBUFs, thereby storing the input values that they can acquire. Thus, redundant input values are reduced, improving overall memory efficiency.
[0057] Figure 8 shows an exemplary method 800 for neural network computation using adaptive tensor shapes according to various embodiments. Method 800 may be performed by the devices, apparatus, or systems described in Figures 1-7. The operation of Method 800 presented below is intended to be illustrative. Depending on the implementation, Method 800 may include additional, fewer, or alternative steps performed in various orders or in parallel.
[0058] Block 810 includes receiving a first input feature map (IFM) and one or more first filters in the first layer of a convolutional neural network (CNN) for convolution using a processing element (PE) array, where each PE in the PE array comprises (Y1) multipliers, and the PE array is arranged in (Y2) rows and (X) columns. In some embodiments, each row of the PE is coupled with (Y1) adder trees corresponding to the (Y1) multipliers in each PE, and each multiplier in each PE sends an integral power to the corresponding adder tree for summation. The (Y1) multipliers in each PE process the processing data in parallel, and the PEs in the PE array process the processing data in parallel.
[0059] Block 820 includes determining a native tensor shape based on a first IFM and one or more first filters, the native tensor shape including a first external dimension, an internal dimension, and a second external dimension, and the native tensor shape maps the first IFM and one or more first filters to a PE array.
[0060] Block 830 includes receiving a second IFM and one or more second filters in the second layer of a CNN that performs convolution using a PE array. In some embodiments, the second layer of the CNN follows the first layer, and the second IFM has more input channels and a lower resolution than the first IFM. In some embodiments, each of the one or more second filters has channels of multiple two-dimensional (2D) kernels, each 2D kernel having dimensions of 1 × 1 (one by one) or 3 × 3 (three by three).
[0061] Block 840 includes deforming the shape of the native tensor based on a second IFM and one or more second filters, the deformation including expanding the internal dimensions and contracting one of the first and second external dimensions, the expansion and contraction being performed by coefficients F.
[0062] Block 850 includes supplying one or more second filters and second IFMs to a PE array to perform a convolution according to a deformed native tensor, wherein if the first external dimension is reduced, the convolution includes summing the outputs from the same row of the PE over F rounds to obtain a partial sum, and if the second external dimension is reduced, the convolution includes summing the outputs from all F times rows of the PE to obtain a partial sum. In some embodiments, supplying one or more second filters to a PE array according to a deformed native tensor includes transforming one or more second filters into a matrix according to the first external and internal dimensions of the deformed native tensor, wherein each row of the matrix includes weights from different input channels of one or more second filters, depending on whether each 2D kernel of one or more second filters has a 1x1 (one by one) dimension, and distributing the weights of each row of the matrix to different columns of the PE so that multiple input channels are processed simultaneously at one time. In some embodiments, supplying one or more second filters to a PE array according to a modified native tensor includes transforming one or more second filters into a matrix according to the first external and internal dimensions of the modified native tensor, wherein if each 2D kernel of one or more second filters has a 3x3 dimension and contains nine weights, the nine weights are placed in the same row of the matrix; and distributing the nine weights from the same row of the matrix to different columns of the PE so that weights from the same channel are processed simultaneously at one time. In some embodiments, supplying an IFM to a PE array according to a modified native tensor includes transforming the IFM into a matrix according to the internal and second external dimensions of the modified native tensor; and supplying the input values of the IFM corresponding to the columns of the matrix to buffers of the rows of the PE.
[0063] Block 860 involves obtaining the output tensor of the convolution in the second layer of the CNN by summing multiple partial sums.
[0064] In the above explanation, Y1, Y2, X, and F are all integers greater than 1.
[0065] In some embodiments, Method 800 further includes dividing the channels of one or more filters into a plurality of channel groups, each channel group containing a constant number of channels that are integers greater than 1; and pruning each of the one or more filters such that only one of the few channels in each of the plurality of channel groups contains non-zero input values, and all other channels in each channel group contain zeros. In some embodiments, Method 800 may further include determining the depth of a buffer associated with each PE in the PE array; configuring the buffer as private memory for each PE if the buffer depth is greater than a constant; and combining the buffer of the PE with one or more buffers of adjacent PEs as shared memory if the buffer depth is less than a constant. In some embodiments, the private memory of each PE stores input values obtainable by (Y1) multipliers in the PE, and the shared memory stores input values obtainable by (Y1) multipliers in the PE and one or more adjacent PEs.
[0066] In some embodiments, each of one or more second filters includes a plurality of non-zero weights, and feeding one or more second filters to a PE array for convolution includes feeding each non-zero weight to the multiplier of the corresponding PE as an index-value pair including the non-zero weight and the corresponding index, and the convolution includes taking an input value from the buffer of the corresponding PE according to the index, sending the taken value and the non-zero weight to the multiplier to take an output, and sending that output to the corresponding adder tree to sum with the outputs produced by other multipliers of other PEs in the same row as the corresponding PE.
[0067] Figure 9 shows an exemplary arithmetic unit capable of performing any embodiment described herein. This arithmetic unit can be used to implement one or more components of the systems and methods shown in Figures 1 to 8. The arithmetic unit 900 may comprise a bus 902 or other communication mechanism for transmitting information and one or more hardware processors 704 coupled to the bus 902 for processing information. The hardware processor(s) 704 may be, for example, one or more general-purpose microprocessors.
[0068] The arithmetic unit 900 may also include main memory 907, such as random access memory (RAM), a cache, and / or other storage devices coupled to the bus 902 for storing information and instructions executed by the processor(s) 904. The main memory 907 can also be used to store temporary variables or other intermediate information during the execution of instructions by the processor(s) 904. When such instructions are stored in a storage medium accessible to the processor(s) 904, the arithmetic unit 900 can be made a dedicated machine customized to perform the operations defined by the instructions. The main memory 907 may include non-volatile media and / or volatile media. Non-volatile media may include, for example, optical disks or magnetic disks. Volatile media may include dynamic memory. Common media forms include, for example, floppy disks, flexible disks, hard disks, semiconductor drives, magnetic tapes, other magnetic data storage media, CD-ROMs, other optical data storage media, perforated physical media, RAM, DRAM, PROM, EPROM, Flash® EPROM, NVRAM, other memory chips or cartridges, or networked versions thereof.
[0069] The arithmetic unit 900 may use customized wiring logic, one or more ASICs or FPGAs, firmware, and / or program logic that, when combined with the arithmetic unit, can make the arithmetic unit 900 a special-purpose machine, to implement the techniques described herein. According to one embodiment, the techniques described herein are executed by the arithmetic unit 900 in response to a processor 904 that executes one or more sequences of one or more instructions contained in main memory 907. Such instructions can be read into main memory 907 from other storage media, such as storage device 909. The execution of a set of instructions contained in main memory 907 allows the processor 904 to perform the processing steps described herein. For example, the process / method disclosed herein can be executed by computer program instructions stored in main memory 907. When these instructions are executed by the processor 904, they can perform the steps described above, as shown in the corresponding figures. In alternative embodiments, wiring circuits may be used instead of, or in combination with, software instructions.
[0070] The arithmetic unit 900 also includes a communication interface 910 coupled to the bus 902. The communication interface 910 can provide bidirectional data communication coupled to one or more network links connected to one or more networks. As another example, the communication interface 910 may be a local area network (LAN) card that provides data communication connectivity to a compatible LAN (or a WAN component communicating with a WAN). A wireless link may also be implemented.
[0071] The execution of specific operations may be distributed not only within a single machine but also across processors deployed across multiple machines. In some exemplary embodiments, the processor or processor implementation engine may be located in a single geographical location (e.g., a home environment, an office environment, or a server farm). In other exemplary embodiments, the processor or processor implementation engine may be distributed across multiple geographical locations.
[0072] The processes, methods, and algorithms described in the preceding sections may be implemented in code modules executed by a computer processor comprising one or more computer systems or computer hardware, and may be fully or partially automated. The processes and algorithms may be implemented, partially or completely, in application-specific circuits.
[0073] When the functions disclosed herein are implemented as software function units and sold or used as independent products, they may be stored on a processor-executable, non-volatile, computer-readable storage medium. Any specific technical solution (in whole or in part) or an aspect contributing to the current art disclosed herein may be embodied in the form of a software product. A software product may include a number of instructions stored on a storage medium that cause a computing device (such as a personal computer, server, or network device) to perform all or some steps of the methods of the embodiments of the invention. The storage medium may include flash® drives, portable hard drives, ROM, RAM, magnetic disks, optical disks, other media operable for storing program code, or a combination thereof.
[0074] Certain embodiments further include a processor and a non-temporary computer-readable storage medium storing instructions that the processor can execute, and the system is configured to perform operations corresponding to the steps in any of the embodiments described above. Certain embodiments further include a non-temporary computer-readable storage medium containing instructions that one or more processors can execute, and one or more processors are configured to perform operations corresponding to the steps in any of the embodiments described above.
[0075] The embodiments disclosed herein can be implemented through a cloud platform, server, or group of servers (collectively, the "Service System") that interacts with a client. The client may be a terminal device or a client registered by a user on the platform, and the terminal device may be a mobile device, a personal computer (PC), or any device on which a platform application program can be installed.
[0076] The various functions and processes described above may be used independently of each other or combined in various ways. All possible combinations and partial combinations are intended to be included within the scope of this disclosure. Furthermore, in some implementations, certain methods or process blocks may be omitted. Also, the methods and processes described herein are not limited to a specific order, and the blocks or states associated with them may be executed in other appropriate orders. For example, the described blocks or states may be executed in an order other than the order specifically disclosed, or multiple blocks or states may be combined into a single block or state. Exemplary blocks or states may be executed in series, in parallel, or in some other way. Blocks or states may be added to or removed from the disclosed exemplary embodiments. The exemplary systems and components described herein may be configured in ways different from those described. For example, elements may be added, removed, or rearranged compared to the disclosed exemplary embodiments.
[0077] Various operations of the exemplary methods described herein can be performed, at least in part, by algorithms. Algorithms may include program code or instructions stored in memory (e.g., the non-temporary computer-readable storage medium described above). Such algorithms may include machine learning algorithms. In some embodiments, machine learning algorithms can learn from training samples to create a predictive model that performs a function, rather than explicitly programming a computer to perform a function.
[0078] Various operations of the exemplary methods described herein can be performed, at least partially, by one or more processors configured temporarily (e.g., by software) or permanently to perform the operations in question. Whether configured temporarily or permanently, such processors can constitute a processor implementation engine configured to operate to perform one or more operations or functions described herein.
[0079] Similarly, at least part of the methods described herein may be performed by a processor, and a particular processor or group of processors is an example of hardware. For example, at least some operations of the methods may be performed by one or more processors or processor implementation engines. Furthermore, one or more processors may operate to support the execution of the relevant operations within a “cloud computing” environment or as “Software as a Service” (SaaS). For example, some operations in this embodiment are performed by a group of computers, which is an example of a machine including a processor, and these operations are accessible via a network (e.g., the Internet) and one or more appropriate interfaces (e.g., application programming interfaces (APIs)).
[0080] The execution of specific operations may be distributed among processors deployed across multiple machines, rather than within a single machine. In some exemplary embodiments, the processor or processor implementation engine may be located in a single geographical location (e.g., a home environment, an office environment, or a server farm). In other exemplary embodiments, the processor or processor implementation engine may be distributed across multiple geographical locations.
[0081] Throughout this specification, multiple examples may implement components, operations, or structures described as single examples. While the individual operations of one or more methods are illustrated and described as separate operations, they may be performed simultaneously, and do not need to be performed in the illustrated order. Structures and functions shown as individual components in the examples may be implemented as integrated structures or components. Similarly, structures and functions presented as single components may be implemented as individual components. These and other variations, modifications, additions, and improvements are included within the scope of the present invention.
[0082] Where used herein, “or” is inclusive and non-exclusive unless otherwise explicitly indicated or the context indicates. Thus, “A, B, or C” means “A, B, A and B, A and C, B and C, or A, B, and C,” unless otherwise explicitly indicated or the context indicates. Furthermore, “and” is inclusive and specific unless otherwise explicitly indicated or the context indicates. Thus, “A and B” means “both or either A and B,” unless otherwise explicitly indicated or the context indicates. Furthermore, for resources, operations, or structures described as a single example herein, multiple examples may be provided. Additionally, the boundaries between various resources, operations, engines, and data storage devices are somewhat arbitrary, and certain operations are described in the context of specific exemplary configurations. Other functional assignments are also envisioned and may be included within the scope of various embodiments of this disclosure. Generally, structures and functions presented as individual resources in exemplary configurations can be implemented as integrated structures or resources. Similarly, structures and functions presented as single resources can be implemented as individual resources. These variations, modifications, additions, and improvements are included within the scope of the embodiments of this disclosure as set forth in the appended claims. Accordingly, this specification and the drawings should be interpreted as illustrative rather than restrictive.
[0083] The terms “includes” or “equip” are used to indicate the presence of features described later, but do not preclude the addition of other features. Conditional statements such as “can,” “could have,” “may,” and “may,” unless otherwise specified or interpreted in context, generally mean that certain features, elements, and / or steps are included in certain embodiments but not in others. Thus, such conditional expressions do not mean that features, elements, and / or steps are required in any way in one or more embodiments, nor do they necessarily mean that one or more embodiments include logic for determining, with or without user input or prompting, whether these features, elements, and / or steps are included in or should be performed in a particular embodiment.
[0084] While the invention has been described in detail with reference to specific exemplary embodiments, various modifications and changes can be made to these embodiments without departing from the broader scope of the embodiments of this disclosure. Such embodiments of the invention may be referred to herein individually or collectively, for convenience, simply by the term “invention,” but the scope of this application is not intended to be arbitrarily limited to any single disclosure or concept, even if multiple disclosures or concepts are actually disclosed.
[0085] The embodiments described herein are described in sufficient detail so that those skilled in the art can carry out the disclosed invention. Other embodiments may also be available and derived therefrom, and structural and logical substitutions and modifications may be made without departing from the scope of this disclosure. Accordingly, the detailed description should not be constrained, and the scope of the various embodiments is defined solely by the appended claims and together with all equivalents contained therein.
Claims
1. A method that is performed on a computer, In the first layer of a convolutional neural network (CNN) for performing convolution using a processing element (PE) array, the receiving of a first input feature map (IFM) and one or more first filters, wherein each PE in the PE array comprises (Y1) multipliers, and the PE array is arranged in (Y2) columns and (X) rows, the receiving is as follows: Determining the native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape includes a first external dimension, an internal dimension, and a second external dimension, and the first IFM and the one or more first filters are mapped to the PE array based on the native tensor shape. In the second layer of the CNN that performs convolution using the PE array, a second IFM and one or more second filters are received. A deformation of the native tensor shape based on the second IFM and the one or more second filters, wherein the deformation includes expanding the internal dimension and contracting one of the first external dimension and the second external dimension, the expansion being performed by a coefficient F and the contraction being performed by a coefficient 1 / F, The method involves supplying the one or more second filters and the second IFM to the PE array for convolution according to the deformed native tensor shape, If the first external dimension is reduced, this includes summing the outputs from the same row of PE over F steps to obtain a partial sum. If the second external dimension is reduced, the convolution includes summing the outputs from all F-fold rows of PE to obtain a partial sum. To supply, The method involves obtaining the output tensor of the convolution in the second layer of the CNN by summing multiple partial sums, wherein Y1, Y2, X, and F are all integers greater than 1. Methods that include...
2. The method according to claim 1, wherein the second layer of the CNN is located after the first layer of the CNN, and the second IFM has more input channels than the first IFM and fewer pixels than the first IFM.
3. The method according to claim 1, wherein each of the one or more second filters comprises a plurality of channels of a two-dimensional (2D) kernel, and each 2D kernel has dimensions of 1 × 1 or 3 × 3.
4. Supplying the one or more second filters to the PE array according to the modified native tensor shape is: The transformation involves converting the one or more second filters into a matrix according to the first external dimension and the internal dimension of the modified native tensor shape, wherein, if each 2D kernel in the one or more second filters has the 1x1 dimension, each row of the matrix includes weights from different input channels of the one or more second filters. The weights of each row of the matrix are distributed to different PEs so that multiple input channels are processed simultaneously at once, The method according to claim 3, including the method described in claim 3.
5. Supplying the one or more second filters to the PE array according to the modified native tensor shape is: The transformation involves converting one or more second filters into a matrix according to the first external dimension and the internal dimension of the modified native tensor shape, wherein if each 2D kernel in the one or more second filters has the 3x3 dimension and contains nine weights, the nine weights are placed in the same row of the matrix. Distributing the nine weights from the same row of the matrix to different PEs so that the weights from the same channel are processed simultaneously in a single operation, The method according to claim 3, including the method described in claim 3.
6. Supplying the IFM to the PE array according to the deformed native tensor shape is: The second IFM is transformed into a matrix according to the internal dimension and the second external dimension of the modified native tensor shape, The input values of the second IFM corresponding to the rows of the matrix are supplied to the buffer of the row of the PE, The method according to claim 5, including the method described in claim 5.
7. The division of the channels of one or more filters into multiple channel groups, wherein each channel group includes a constant number of channels that are integers greater than 1. Pruning each of the aforementioned channel groups such that the fixed weight ratio within each channel group is non-zero, The method according to claim 1, further comprising:
8. The further includes determining the size of the buffer associated with each PE in the PE array, If the size of the buffer is greater than the constant, the buffer is configured as private memory for each PE. If the size of the buffer is smaller than the constant, the buffer of the PE and one or more buffers of adjacent PEs are configured as shared memory. The method according to claim 7.
9. The method according to claim 8, wherein the private memory of each PE stores input values obtainable by the (Y1) multipliers in the PE.
10. The method according to claim 8, wherein the shared memory stores input values obtainable by the PE and the (Y1) multipliers in one or more neighboring PEs.
11. The method according to claim 1, wherein each row of the PE is associated with (Y1) adder trees corresponding to the (Y1) multipliers in each PE, and each multiplier in each PE transmits an integral power to the corresponding adder tree for summation.
12. Each of the one or more second filters includes a plurality of non-zero weights, and supplying the one or more second filters to the PE array for convolution is The convolution includes supplying each non-zero weight as an index-value pair including the non-zero weight and the corresponding index to the multiplier of the corresponding PE, The input value is obtained from the corresponding PE buffer according to the index, The acquired value and the non-zero weight are sent to the multiplier, and the output is obtained. Send the output to the corresponding adder tree in order to sum it with the outputs generated by other multipliers of other PEs in the same row as the corresponding PE, The method according to claim 1, including the method described in claim 1.
13. The method according to claim 1, wherein the (Y1) multipliers in each PE process data in parallel, and the PEs in the PE array process data in parallel.
14. A system for neural network computation comprising one or more processors, and one or more non-temporary computer-readable memories coupled to the one or more processors and configured to cause the system to perform calculations, wherein the system comprises one or more processors and has instructions that can be executed by the one or more processors, In the first layer of a convolutional neural network (CNN) for performing convolution using a processing element (PE) array, the receiving of a first input feature map (IFM) and one or more first filters, wherein each PE in the PE array comprises (Y1) multipliers, and the PE array is arranged in (Y2) columns and (X) rows, Determining the native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape includes a first external dimension, an internal dimension, and a second external dimension, and the first IFM and the one or more first filters are mapped to the PE array based on the native tensor shape. In the second layer of the CNN that performs convolution using the PE array, a second IFM and one or more second filters are received. A deformation of the native tensor shape based on the second IFM and the one or more second filters, wherein the deformation includes expanding the internal dimension and contracting one of the first and second external dimensions, the expansion being performed by a coefficient F and the contraction by a coefficient 1 / F, The method involves supplying the one or more second filters and the second IFM to the PE array for convolution according to the deformed native tensor shape, If the first external dimension is reduced, the convolution includes summing the outputs from the same row of PE over F steps to obtain a partial sum. If the second external dimension is reduced, the convolution includes summing the outputs from all F-fold rows of PE to obtain a partial sum. To supply, The method involves obtaining the output tensor of the convolution in the second layer of the CNN by summing multiple partial sums, wherein Y1, Y2, X, and F are all integers greater than 1. A system that includes this.
15. The system according to claim 14, wherein the second layer of the CNN is located after the first layer of the CNN, and the second IFM has more input channels than the first IFM and fewer pixels than the first IFM.
16. The above calculation further, The division of the channels of one or more filters into multiple channel groups, wherein each channel group includes a constant number of channels that are integers greater than 1. Pruning the channels of one or more filters such that in each of the aforementioned multiple channel groups, only one channel contains a non-zero input value, and all other channels in each channel group contain zeros. The system according to claim 14, including the system described in claim 14.
17. The above operation is, Further including determining the size of the buffer associated with each PE in the PE array, If the size of the buffer is greater than the constant, the buffer is configured as private memory for each PE. If the size of the buffer is smaller than the constant, the buffer of the PE and one or more buffers of adjacent PEs are configured as shared memory. The system according to claim 16.
18. The system according to claim 14, wherein each of the one or more second filters includes a plurality of channels of a two-dimensional (2D) kernel, and each 2D kernel has dimensions of 1 × 1 or 3 × 3.
19. Supplying the one or more second filters to the PE array according to the modified native tensor shape is: The transformation involves converting the one or more second filters into a matrix according to the first external dimension and the internal dimension of the modified native tensor shape, wherein, if each 2D kernel in the one or more second filters has the 1x1 dimension, each row of the matrix includes weights from different input channels of the one or more second filters. The weights of each row of the matrix are distributed to different PEs so that multiple input channels are processed simultaneously at once, The system according to claim 18, including the system described in claim 18.
20. A computer program that can be executed by one or more processors, wherein the one or more processors In the first layer of a convolutional neural network (CNN) for convolution using an array of external processing elements (PEs) coupled to one or more processors, receiving a first input feature map (IFM) and one or more first filters, wherein each PE in the PE array comprises (Y1) multipliers, and the PE array is arranged in (Y2) columns and (X) rows, Determining the native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape includes a first external dimension, an internal dimension, and a second external dimension, and the first IFM and the one or more first filters are mapped to the PE array based on the native tensor shape. In the second layer of the CNN that performs convolution using the PE array, a second IFM and one or more second filters are received. A deformation of the native tensor shape based on the second IFM and the one or more second filters, wherein the deformation includes expanding the internal dimension and contracting one of the first and second external dimensions, the expansion being performed by a coefficient F and the contraction by a coefficient 1 / F, The method involves supplying the one or more second filters and the second IFM to the PE array in order to perform convolution according to the deformed native tensor shape, If the first external dimension is reduced, the convolution includes summing the outputs from the same row of PE over F steps to obtain a partial sum. If the second external dimension is reduced, the convolution includes summing the outputs from all F-fold rows of PE to obtain a partial sum. To supply, The method involves obtaining the output tensor of the convolution in the second layer of the CNN by summing multiple partial sums, wherein Y1, Y2, X, and F are all integers greater than 1. A computer program that performs calculations that include [a specific operation].
Citation Information
Patent Citations
Performing successive MAC operations on a set of data using different kernels in a MAC circuit
JP2021531572A
Convolution Engine for Neural Networks
US20200159809A1
NPU device performing convolution operation based on the number of channels and operating method thereof
US20220188612A1
Redistributing tensor elements between machine learning computing units
US20220245453A1
