Adaptive tensor calculation kernel for sparse neural networks

Through the dynamic adjustment of the adaptive tensor computing core and matrix transformation technology, the problem of low computational efficiency of the deep learning processing element array when processing sparse neural networks is solved, and more efficient resource utilization and parallel processing capabilities are achieved.

CN118715527APending Publication Date: 2024-09-27MOFFETT AI TECHNOLOGY SHENZHEN CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202380021998.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-02-16
Filing Date
2023-02-13
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

The existing array of deep learning processing elements is fixed in native tensor dimensions and operation modes, and cannot efficiently handle different input tensor shapes and operations in sparse neural networks, resulting in low computational efficiency.

Method used

An adaptive tensor computing core is used to dynamically adjust tensor dimensions and operation modes to adapt to input feature maps and weight tensors of different shapes. The resource utilization and parallel processing capabilities of the PE array are optimized through matrix transformation and shaping technology.

Benefits of technology

It improves the efficiency of neural network calculations, supports parallel processing of different shapes and operating modes, reduces resource waste and sequential dependencies, and improves computing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118715527A
    Figure CN118715527A
Patent Text Reader

Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, are disclosed for improving the efficiency of neural network calculations using adaptive tensor calculation kernels. First, an adaptive tensor calculation core may adjust the shape according to different shapes of input / weight tensors in order to assign weights and input values to an array of processing elements (PEs) for parallel processing. Depending on the shape of the tensor calculation kernel, additional inter-cluster or intra-cluster adders may be required to perform convolution calculations. Secondly, the adaptive tensor calculation kernel may support two different tensor operation modes, i.e., a 1 * 1 tensor operation mode and a 3 * 3 tensor operation mode, to cover all types of convolution calculations. Third, the underlying PE array may differently configure individual PE-internal buffers (e.g., register files) to support different compression ratios and sparse granularity of the sparse neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure generally relates to improving neural network computation efficiency, and more particularly to dynamically adjusting native tensor dimensions and operation modes to accommodate different input tensor shapes and operations of sparse neural networks. Background Art

[0002] Almost all deep learning processing element (PE) arrays are fixed in native tensor dimensions and operation modes, and usually rely on the compiler to use different nested loop mapping methods to handle different tensor shapes (e.g., input feature maps or filters) and operations. Obviously, it is inefficient to use PE arrays to perform calculations on tensor shapes or operations that are incompatible with the original tensor dimensions or operation modes of the PE arrays. This incompatibility is more serious for sparse neural networks with sparse features, because the inflexible native tensor shapes and modes of PE arrays cannot efficiently represent and process tensors with a large number of zeros. Summary of the invention

[0003] Various embodiments of the present description may include systems, methods, and non-transitory computer-readable media for using adaptive tensor compute kernels in neural network computations.

[0004] According to one aspect, a method for using an adaptive tensor computation kernel in a neural network computation may include: receiving a first input feature map (IFM) and one or more first filters at a first layer of a convolutional neural network (CNN) for convolution using a processing element (PE) array, wherein each PE in the PE array includes a plurality of (Y1) multipliers, and the PE array is arranged as a plurality of (Y2) rows and a plurality of (X) columns; determining a native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape includes a first outer dimension, an inner dimension, and a second outer dimension, wherein the native tensor shape maps the first IFM and the one or more first filters into the PE array; receiving a second IFM and one or more second filters at a second layer of the CNN for convolution using the PE array Perform convolution; reshape the native tensor shape based on the second IFM and one or more second filters, wherein the reshaping includes scaling up the inner dimension and scaling down one of the first outer dimension and the second outer dimension, and the scaling up and scaling down factor is F; feed the one or more second filters and the second IFM into the PE array according to the shaped native tensor for convolution, wherein: in response to the first outer dimension being scaled down, the convolution includes: aggregating the outputs from the same row of PEs F rounds to obtain partial sums, and in response to the second outer dimension being scaled down, the convolution includes: aggregating the outputs from every F rows of PEs to obtain partial sums; and obtaining the output tensor of the convolution at the second layer of the CNN by aggregating the multiple partial sums, wherein Yl, Y2, X and F are all integers greater than one.

[0005] In some embodiments, the second layer of the CNN follows the first layer of the CNN, and the second IFM includes more input channels than the first IFM and a lower resolution than the first IFM.

[0006] In some embodiments, each of the one or more second filters comprises a plurality of channels of a 2-dimensional (2D) kernel, each 2D kernel having a dimension of one by one (1*1) or three by three (3*3).

[0007] In some embodiments, feeding one or more second filters into the PE array according to the shaped native tensor includes: transforming the one or more second filters into a matrix according to a first outer dimension and an inner dimension of the shaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a one-by-one dimension, each row of the matrix includes weights of different input channels from the one or more second filters; and assigning the weights in each row of the matrix to PEs of different columns so that multiple input channels are processed simultaneously at a time.

[0008] In some embodiments, feeding one or more second filters into the PE array according to the shaped native tensor includes: transforming the one or more second filters into a matrix according to a first outer dimension and an inner dimension of the shaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a three by three dimension and including nine weights, the nine weights are placed in the same row of the matrix; and assigning the nine weights from the same row of the matrix to PEs in different columns, so that weights from the same channel are processed simultaneously at one time.

[0009] In some embodiments, feeding the IFM into the PE array according to the reshaped native tensor includes: transforming the IFM into a matrix according to the inner dimension and the second outer dimension of the reshaped native tensor; and feeding the input values ​​of the IFM corresponding to the columns of the matrix into the buffer of the PE row.

[0010] In some embodiments, the method may further include: dividing the channels of the one or more filters into a plurality of channel groups, each channel group including a fixed number of channels that is an integer greater than one; and pruning each of the one or more filters so that only a few channels in each of the plurality of channel groups include non-zero input values, and other channels in each channel group include all zeros. After pruning, each of the plurality of channel groups includes the same percentage of weights as non-zero weights.

[0011] In some embodiments, the method may further include: determining the depth of a buffer associated with each PE in the PE array; in response to the depth of the buffer being greater than a fixed number, configuring the buffer as dedicated memory for each PE; and in response to the depth of the buffer being less than the fixed number, combining the buffer of the PE with one or more buffers of an adjacent PE as a shared memory.

[0012] In some embodiments, dedicated memory of each PE stores input values ​​that may be retrieved by multiple (Y1) multipliers within the PE.

[0013] In some embodiments, the shared memory stores input values ​​that can be retrieved by multiple (Y1) multipliers within a PE and one or more neighboring PEs.

[0014] In some embodiments, each row of PEs is coupled to multiple (Y1) adder trees corresponding to multiple (Y1) multipliers in each PE, respectively, wherein each multiplier in each PE sends the multiplication output to the corresponding adder tree for aggregation.

[0015] In some embodiments, each of the one or more second filters includes multiple non-zero weights, and feeding the one or more second filters into the PE array for convolution includes: feeding each non-zero weight into the multiplier of the corresponding PE as an index value pair including the non-zero weight and the corresponding index; and the convolution includes: retrieving the input value from the buffer of the corresponding PE according to the index; and sending the retrieved value and the non-zero weight to the multiplier to obtain an output; and sending the output to the corresponding adder tree for aggregation with the outputs generated by other multipliers of other PEs in the same row as the corresponding PE.

[0016] In some embodiments, multiple (Y1) multipliers within each PE process data in parallel, and the PEs in the PE array process data in parallel.

[0017] According to yet another aspect, a system may include: one or more processors; and one or more non-transitory computer-readable memories coupled to the one or more processors and configured with instructions executable by the one or more processors to cause the system to perform any of the methods described herein.

[0018] According to yet another aspect, a non-transitory computer-readable storage medium may be configured with instructions executable by one or more processors to cause the one or more processors to perform any of the methods described herein.

[0019] These and other features of the systems, methods and non-transitory computer-readable media disclosed herein, as well as the methods of operation and functionality of the related elements and combinations of parts of the structures and the economies of manufacturing will become more apparent after considering the following description and the appended claims with reference to the accompanying drawings, all of which form a part of this specification and in which like reference numerals represent corresponding parts in the various figures. It should be expressly understood, however, that the drawings are for illustration and description purposes only and are not intended as a definition of the limits of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 An exemplary system diagram for processing neural network computations in a PE array according to various embodiments is illustrated.

[0021] Figure 2 An exemplary architectural diagram of a PE array according to various embodiments is illustrated.

[0022] Figure 3 Exemplary neural network computations in a PE array using native tensor shapes according to various embodiments are illustrated.

[0023] Figure 4A Exemplary neural network computations in a PE array using adaptive tensor shapes in accordance with various embodiments are illustrated.

[0024] Figure 4B An exemplary PE array with inter-cluster adders using adaptive tensor shapes for neural network computations is illustrated in accordance with various embodiments.

[0025] Figure 5A Another exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments is illustrated.

[0026] Figure 5B Another exemplary PE array with intra-cluster adders that uses adaptive tensor shapes for neural network computations in accordance with various embodiments is illustrated.

[0027] Fig. 6A An exemplary neural network computation with a 1*1 tensor operation mode according to various embodiments is illustrated.

[0028] Figure 6B An exemplary neural network computation with a 3*3 tensor operation mode according to various embodiments is illustrated.

[0029] Figure 7 An example method for performing neural network computation using adaptive tensor shapes and 3*3 tensor operation modes in a PE array according to various embodiments is illustrated.

[0030] Figure 8 Example methods for neural network computations using adaptive tensor shapes in accordance with various embodiments are illustrated.

[0031] Fig. 9 An example computer system is illustrated in which any of the embodiments described herein may be implemented. DETAILED DESCRIPTION

[0032] Embodiments described herein provide methods, systems, and apparatus for performing neural network computations in a PE array using adaptive tensor shapes and operation modes. In the following description, an adaptive tensor computation core is described as having multiple native tensor dimensions and operation modes to process input feature maps (IMFs) and weight tensors (e.g., filters) of different shapes. Depending on the input and output tensor shapes and operation modes, the dimensions and operation modes of the adaptive tensor computation core (also referred to as an adaptive native tensor) can be dynamically adjusted to fully utilize the underlying hardware resources of the PE array for parallel processing.

[0033] These adaptive tensor compute cores address the technical challenges in neural network computing (identified in the background section) by providing three technical solutions. First, the adaptive tensor compute core can adjust the shape according to the different shapes of the input / weight tensors. The different shapes of the input / weight tensors can exist not only across different neural networks, but also within the same neural network pipeline. For example, when processing the first few layers in a neural network, tensors are typically configured with high resolution (more height and width) but fewer input and output channels; when processing the last few layers in a neural network, tensors can be configured with low resolution (less height and width) but more input and output channels. This may be because the first few layers of the neural network are more concerned with feature extraction from the input feature map, while the last few layers of the neural network are more concerned with learning the potential correlations between the extracted features.

[0034] Secondly, the adaptive tensor computing core can support two different tensor operation modes: 1*1 tensor operation mode and 3*3 tensor operation mode. In these neural network layers, matrix multiplication involving 1*1 kernel convolution (for example, each kernel in the weight tensor has a 1*1 shape) can be mapped to the 1*1 tensor operation mode, and any other convolution (3*3, 5*5, 7*7, etc.) can be mapped to the 3*3 tensor operation mode. These different tensor operation modes can be dynamically determined at runtime based on the weight tensor shape.

[0035] Third, the underlying PE array can configure each PE-internal buffer (e.g., register file) differently to support different compression ratios and sparsity granularities of the sparse neural network. If the sparse neural network is pruned at a finer granularity (e.g., one or more non-zero input channels are selected from a small number of input channels, the small number is less than a threshold), the register file within each PE can be configured as a dedicated memory (e.g., used only by the corresponding PE). If the sparse neural network is pruned at a coarse granularity (e.g., one or more non-zero input channels are selected from a large number of input channels, the large number is greater than a threshold), multiple register files in adjacent PEs can be configured as multi-port memories shared by adjacent PEs.

[0036] In the following description, specific, non-limiting embodiments of the present invention will be described with reference to the accompanying drawings. The specific features and aspects of any embodiment disclosed herein may be used and / or combined with the specific features and aspects of any other embodiment disclosed herein. It should also be understood that these embodiments are exemplary and are merely illustrations of a small number of embodiments within the scope of the present invention. Various changes and modifications that are obvious to those skilled in the art to which the present invention belongs are considered to be within the spirit, scope and conception of the present invention as further defined in the appended claims.

[0037] Figure 1An exemplary system diagram for processing neural network computations in a PE array according to various embodiments is illustrated. Figure 1 The figure in illustrates a typical neural network computation workflow executed in a pipeline with a PE array. The embodiments described in the present disclosure may be implemented as Figure 1 or part of a neural network computation in other suitable environments.

[0038] At a given (e.g., convolutional) layer within a neural network (e.g., a 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 through the IFMs to extract various features. The convolution process may be performed in parallel in an array of processing elements (PEs) (referred to as a PE array 160). Each PE may refer to a processor having processing power and storage capacity (e.g., a buffer or cache). PEs may be arranged into PE arrays with interconnects in a particular manner and cannot be dynamically rearranged at run time. PE arrays may be reused and may be included in calculations at different layers of a neural network or across different neural networks and different use cases. The incompatibility between the fixed internal PE arrangement in the PE array and the potentially infinite variation of tensor shapes (in IFMs and / or weight tensors) often results in inefficient resource utilization and suboptimal parallel processing.

[0039] refer 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 consumption by the PE array 160. The PE array 160 may include a PE matrix (e.g., X times 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 calculations in the PE array 160. The matrix transformation may include a Toeplitz matrix transformation, which reshapes the IFM from the original HWC format (H refers to height, W refers to weight, and C refers to channel) to an RSC format (R refers to row, S refers to column, and C refers to channel) by using the im2col tool, where the RSC format is determined based on the weight tensor shape. Here, the transformation is to copy and arrange the input values ​​in the IFM to form a transformed IFM so that the matrix multiplication between the transformed IFM and the weight tensor can be performed in parallel in the PE array 160 with minimal dependencies between PEs in the PE array 160. In some embodiments, each round of parallel convolution in PE array 160 may generate multiple partial sums, which may be aggregated in accumulation buffer 170 to generate one or more output values. The output value may ultimately be a portion of the output tensor generated by the current layer.

[0040] Figure 2 An exemplary architectural diagram of a PE array according to various embodiments is illustrated. Figure 2 The arrangement of PEs in the PE array in FIG. 1 is for illustrative purposes and may be implemented in other ways depending on usage scenarios.

[0041] like Figure 2 As shown in the left part of FIG, the PE array 200 may include a PE matrix. Figure 2 As shown in the right part of , each PE 240 may include multiple multipliers (MUL gates). The multipliers within each PE 240 may operate in parallel, and the PEs within the PE array 220 may operate in parallel. For ease of reference, the following description represents the number of columns 220 of PEs in the PE array 200 as X, the number of rows 210 of PEs in the PE array 200 as Y2, and the number of multipliers within each PE 240 as Y1. Each row 210 of PEs may be referred to as a PE cluster, and each PE cluster may be coupled to a Y1 adder tree 230 to aggregate partial sums generated by the multipliers within the PE cluster. That is, the first multiplier in each PE 240 within the PE cluster is coupled to the first adder tree 230 for aggregation, and the second multiplier in each PE 240 within the PE cluster is coupled to the second adder tree 230 for aggregation, and so on. Aggregated results from adder trees 230 across all PE clusters (Y1*Y2 adder trees in total) may be fed into adder 250 for aggregation. Adder 250 may refer to a digital circuit that performs digital addition as part of a network-on-chip (NoC) subsystem.

[0042] In some embodiments, the PE array 200 may broadcast weights to the PEs. For a sparse neural network, most weights are zero, so the weights broadcast to the PEs are all non-zero weights. Since the non-zero weights can come from any position within the weight tensor, the broadcasted weights may include not only the weight value, but also an index indicating the location information of the weight value, that is, an index value pair such as (index, weight value). Based on the index, each PE 240 may retrieve the corresponding input value from the IFM to perform multiplication with the weight value. The multiplication result may be fed to the corresponding adder tree. Figure 1 As shown, the first multiplier MULl can receive a weight in the form of (index l, value l), retrieve the input value IFMl from the IBUF 260 (storing IFM) based on the index l, perform multiplication based on the input value IFMl and the value l, and send the result to the adder tree 1 (for example, the first adder tree among the Y1 adder trees 230 for the PE cluster where the PE is located) for aggregation.

[0043] Figure 3Exemplary neural network computations in a PE array using native tensor shapes according to various embodiments are illustrated. Figure 3 The illustrative calculation in involves a matrix multiplication between a transformed weight tensor A 310 and a transformed IFM tensor B 320, which generates an output feature map (OFM) tensor C 330. The matrix multiplication uses a native tensor shape corresponding to the PE array 340 having dimensions of X and Y.

[0044] In some embodiments, the transformed weight tensor A 310 can be obtained by aggregating all weight tensors in RSC format (three-dimensional) into a two-dimensional matrix represented as m'*k' (e.g., rearranging weights from different channels into the same channel), where m' is the number of output channels determined by the number of weight tensors (typically represented 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).

[0045] In some embodiments, the transformed IFM tensor B 320 can be obtained by aggregating all IFMs in the HWC format (three-dimensional) based on the RSC format into a two-dimensional matrix represented as k'*n', where k' is still the product of the R, S, and C dimensions of the respective weight tensors, and n' is the product of the H and W dimensions of the IFM (H refers to the height and W refers to the width of the IFM). The matrix multiplication of the matrix m'*k' (weight tensor A 310) and the matrix k'*n' (IFM B 320) can produce the OFM tensor C 330 as the matrix m'*n'.

[0046] Using the above transformations, the transformed weight tensor A 310 and the transformed IFM tensor B 320 can be mapped to the PEs in the PE array 340 for parallel processing. Assuming that the PE array 340 includes Y2 rows of PEs, X columns of PEs, and each PE includes Yl multipliers, the tensors A and B can be mapped to the PE array 340 as follows: the inner dimension k' of the tensor A 310 and the tensor B 320 can be mapped to the X (row) dimension of the PE array 340, that is, X=k'=R*S*C, and the product m'*n' of the outer dimensions of the tensors A and B can be mapped to the Y (column) dimension of the PE array 340. Since each column of PE includes Yl*Y2 multipliers, the above mapping means that Y=m'*n'=K*H*W multiplications will be processed in parallel by Yl*Y2 multipliers. For example, within each PE, one multiplier processes weights corresponding to the same output channel (e.g., weights from the same position across all weight tensors), i.e., Yl=K=m', and each column of PEs processes H*W weights in parallel, i.e., Y2=H*W=n'.

[0047] In the above description, in order to map a workload (e.g., a pair of multiplication weights and corresponding input values) to a PE within the PE array 340, the native tensor shape m'*k'*n' is fixed, where X=k', Yl*Y2=m'*n'. This means that the native tensor shape is determined based on the layout of the PEs within the PE array. Once the layout of the PE array is fixed, the native tensor shape is fixed. All input tensors (e.g., IFMs and filter / weight tensors) must be transformed according to the fixed native tensor shape. However, the input tensors in actual applications may vary in shape, and optimal parallelism can be achieved when the transformation is based on the shape of the input tensor rather than the PE layout in the PE array 340. In many cases, even if the workload can be mapped to the PE using a transformation based on a fixed native tensor shape determined based on the PE layout, it may result in some serialization dependencies between certain PEs (e.g., one PE must wait for the output of another PE). The following description describes a transformation that utilizes an adaptive native tensor shape that is determined based on the dimensions of the IFM and filters, while mapping workloads to PEs to maximize parallelism.

[0048] Figure 4A An exemplary neural network computation in a PE array using adaptive tensor shapes according to various embodiments is illustrated. As described above (in Figure 3 ), if the input tensor (IFM) and the weight tensor can be transformed into matrix A 410 and matrix B 420 (i.e., covering matrices A and B) using a fixed native tensor shape m'*k'*n', the transformed tensors can be allocated to the corresponding PE arrays. However, in practical applications, the IFM and weight tensors used for multiplication (e.g., tensors that undergo different levels of sparsification at different layers of a CNN) may have various shapes that may not be perfectly mapped to the PE arrays. The forced transformation of tensors using a fixed native tensor shape may leave some PEs idle or cause sequential dependencies during calculations. For example, within the same convolutional neural network (CNN), tensors in the first few CNN layers may have a high resolution (e.g., H*W=64) with a smaller number of input channels (C=16), and tensors in the last few CNN layers may have a low resolution (e.g., H*W=16) with a larger number of input channels (C=64). Here, "less" and "more" are determined based on a threshold. This means that even convolutions within the same CNN may experience tensors of different shapes.

[0049] In some embodiments, the native tensor shape can be dynamically reshaped to accommodate the changing shapes of the input tensors and weight tensors. For example, if the input tensor changes from a high resolution (more pixels) with fewer input channels (e.g., in the first few CNN layers) to a low resolution with more input channels (e.g., in the last few CNN layers), the native tensor shape can be reshaped accordingly. In some embodiments, the native tensor shape has three dimensions, represented as the first outer dimension (first_outer_dimension), the inner dimension (inner_dimension), and the second outer dimension (second_outer_dimension). The first two dimensions (first_outer_dimension and inner_dimension) can be used to transform the weight tensor into a matrix, and the last two dimensions (inner_dimension and second_outer_dimension) can be used to transform the IFM into a matrix. The transformed matrix can provide guidance on how to map weights and input values ​​to PE arrays (e.g., how to allocate weights and input values ​​to achieve optimal parallelism).

[0050] In some embodiments, assuming that the previous tensor uses a native tensor shape m'*k'*n' for mapping and transformation, and the input tensor has a lower resolution with more input channels than the previous tensor, the three dimensions of the native tensor shape can be shaped as m'*(F*k')*(n' / F), where F is an integer greater than one and represents a scaling factor, and the first two dimensions (i.e., the first outer dimension m' and the inner dimension F*k') represent the weight tensor matrix 420, and the next two dimensions (i.e., the inner dimension F*k' and the second outer dimension n' / F) represent the IFM tensor matrix 422 used for convolution. That is, the native tensor shape can scale up its inner dimension by a factor of F, and scale down the second outer dimension (corresponding to the IFM tensor matrix) by a factor of F. This shaping method may be referred to as k' and n' shaping in the following description. In some embodiments, F may be one of 2, 4, 8, etc.

[0051] In some embodiments, the internal dimension F*k' of the reshaped tensor shape is shared by the weight tensor matrix 420 and the IFM tensor matrix 422 (e.g., they have 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 within 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, "correspondence" refers to a mapping relationship that guides how the weights and input values ​​in the transformation tensor matrix are assigned to the PE array. For example, the weights of the various external dimensions (e.g., the various columns) of the weight tensor matrix 420 can be assigned to multipliers within a single PE for parallel processing; and the input values ​​of the various external dimensions (e.g., the various rows) of the IFM tensor matrix 422 can be assigned across PE rows in the PE array.

[0052] like Figure 4A As shown, using this reshaped native tensor shape, the weight tensor matrix 410 can be reshaped by scaling up its internal dimension by a factor F and 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), thereby, the new matrix 420 can support more input channels (from C to F*C). Similarly, the IFM matrix 412 can scale down its external dimension by a factor F, and scale up its internal dimension in the same manner as the scaled 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), whereby the new matrix 422 can support fewer pixels. Therefore, the new matrices 420 and 422 are more suitable for representing tensors from the last few CNN layers, which have a low resolution with more 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 from the beginning of the CNN structure and the second number of CNN layers from the end of the CNN structure, respectively.

[0053] As an example, the tensors from the first few CNN layers may have a high resolution H*W=64 with a smaller number of input channels C=16. Here, "smaller number" refers to a number less than a threshold, and the threshold may be determined by the compiler according to the configuration of the underlying PE array. Assuming that the convolution is based on a 1*1 kernel, the native tensor shapes of these tensors from the first few CNN layers may have shapes of m'=K=16, k'=l*l*16, and n'=64. When the convolution proceeds to the last few CNN layers, the tensors may have a low resolution H*W=16, but have more input channels C=64 (e.g., greater than the threshold), and the native tensor shapes may be reshaped to m'=K=16, k'=l*l*64, and n'=16.

[0054] After transforming the tensors using k′ and n′ as described above, the transformed tensor matrices 420 and 422 may be distributed to the PE array for parallel processing. Figure 4B An exemplary PE array with inter-cluster adders for performing neural network computations using adaptive tensor shapes based on k' and n' shaping is illustrated in accordance with various embodiments. Figure 4B The parallel processing scheme of the PE array illustrated may correspond to Figure 4A The k' and n' shapes of the native tensor are described. For consistency, we still assume that the PE array has Y2 rows and X columns of PEs, and each PE has Y1 multipliers.

[0055] Using k' and n' shaping, the internal dimensions of the weight tensor matrix and the IFM tensor matrix are scaled up by F times, and the external dimensions of the IFM tensor matrix are scaled down by F times. The allocation of weights and input values ​​to the PE array can make the weights from the same row of the weight tensor matrix (i.e., along the scaled internal dimension / row) and the input values ​​from the same column of the IFM tensor matrix (i.e., also along the scaled internal dimension / column) be allocated to the PEs in rows. This means that these weight and input value pairs can be allocated across F rows of PEs. Therefore, the PE array may have an inter-cluster (i.e., between PE clusters or rows) adder 400 to aggregate the outputs generated by each row of PEs in order to obtain the partial sums of the convolution process. Each inter-cluster adder 400 can aggregate the outputs of Yl adder trees from F rows of PEs into Yl partial sums. These partial sums can then be aggregated to construct an output tensor as a result of the convolution. During this process, the total number of partial sums is Yl*(Y2 / F), which means that the number of output channels (e.g., the number of channels of the output tensor of the convolution process) is Yl, and the number of output pixels is Y2 / F=H*W / F.

[0056] Figure 5AAnother exemplary neural network calculation in a PE array using adaptive tensor shapes according to various embodiments is illustrated. Compared with the above-mentioned k' and n' shaping, the native tensor shape can also be dynamically shaped based on the sparsity of the weight tensor. In many practical applications, the weight tensor in the convolution process can be pruned or sparsed to improve computational efficiency and reduce the occupied area of ​​the neural network. Carefully pruned weight tensors can increase the convolution speed by introducing zero-valued weights and thereby reducing the total number of calculations (e.g., skipping zero weights) without sacrificing feature extraction accuracy. In some embodiments, pruning the weight tensor may include dividing the channels of the weight tensor (also referred to as a filter) into a plurality of channel groups, wherein all channel groups have the same number of channels; then only a few channels of each channel group are maintained as non-zero input channels (e.g., having non-zero weights), and all other channels within the channel group are zeroed (e.g., having all zero weights). After the pruning process, each channel group includes the same percentage of non-zero weights. In some embodiments, the size of the channel group for pruning (e.g., the number of channels within each channel group) can be determined based on the number of weight tensors (filters) (i.e., the number of output channels). In general, weight tensor pruning can 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, the native tensor shape for the high weight sparsity (16X) case can be m'=K=16 (e.g., 16 weight tensors or filters), k'=3*3*4 (e.g., each core is 3*3, and the number of non-zero channels within a filter is 4) and n'=64; while the native tensor shape for the low weight sparsity (4X) case can be m'=K=4 (e.g., 4 weight tensors or filters), k'=3*3*16 (e.g., each core is 3*3, and the number of non-zero channels within a filter is 16) and n'=64.

[0057] In some embodiments, when weight sparsity changes from high to low, the native tensor shape represented as first_outer_dimension*inner_dimension*second_outer_dimension can be reshaped by scaling up its inner dimension (shared by the weight tensor matrix and the IFM tensor matrix) by a factor of F and scaling down the first outer dimension (corresponding to the weight tensor matrix) by a factor of F. Figure 5AAs shown, the original native tensor shape m'*k'*n' is changed to (m' / F)*(F*k')*n', wherein the weight tensor matrix 510 is changed from m'*k' to a shaped tensor matrix 520 with dimension (m' / F)*(F*k'), and the IFM tensor matrix 512 is changed from k'*n' to a shaped IFM matrix 522 with dimension (F*k')*n'. ​​This shaping method may be referred to as k' and m' shaping in the following description. The inner dimension scaled up by factor F indicates that more input channels are supported (from C to F*C), and the outer dimension scaled down by factor F indicates fewer output channels (from K to K / F).

[0058] After the tensors are transformed using k′ and m′ as described above, the transformed tensor matrices 520 and 522 may be distributed to the PE array for parallel processing. Figure 5B Another exemplary PE array with inter-cluster adders for neural network computations using adaptive tensor shapes based on k' and m' shaping is illustrated in accordance with various embodiments. Figure 5B The parallel processing scheme of the PE array illustrated may correspond to Figure 5A The k' and m' shapes of the native tensor.

[0059] For consistency, it is still assumed that the PE array has Y2 rows and X columns of PEs, and each PE has Y1 multipliers. In addition, the weight matrix 520 and the IFM matrix 522 have the same inner dimension, which corresponds to the number of columns of PEs in the PE array (X), the outer dimension of the weight matrix 520 corresponds to the number of multipliers in each PE in the PE array (Y1), and the outer dimension of the IFM matrix 522 corresponds to the number of rows of PEs in the PE array (Y2).

[0060] Since the reshaped native tensor has a first outer dimension as m' / F (corresponding to the outer dimension of the weight matrix 520), the weights in each column of the weight tensor matrix can be fed to Y1 / F multipliers in each PE. In order to obtain partial sums from the PE array, the intra-cluster adder 500 can be implemented to store and aggregate F rounds of outputs from Yl adder trees. Here, "round" refers to a loop in which multiplication is performed using a multiplier in a PE. During each round, the outputs of Yl / F multipliers can be temporarily stored in an intra-cluster adder 500. After F rounds, the intra-cluster addition 500 may have F*Y1 / F=Y1 partial sums collected from Yl adder trees. These partial sums can then be aggregated to construct an output tensor as a result of the convolution. During this process, the total number of partial sums is *Yl / F)*Y2, which means that the number of output channels (e.g., the number of channels of the output tensor of the convolution process) is Yl / F, and the number of output pixels is Y2=H*W.

[0061] In the field of convolutional neural networks, a weight tensor can be referred to as a 3D filter, which includes multiple 2D cores. The number of 2D cores within each 3D filter can be referred to as the number of channels in the filter, and each 2D core can be a one-by-one or three-by-three matrix. Fig. 6A illustrates an exemplary neural network computation with a 1*1 tensor operation mode (i.e., using a one-by-one kernel) according to various embodiments, and Figure 6B An exemplary neural network computation with a 3*3 tensor operation mode (ie, using a three by three kernel) according to various embodiments is illustrated.

[0062] In some embodiments, general matrix multiplication (GEMM) and 1*1 convolution operations may be mapped to a 1*1 operation mode (eg, using a 1*1 kernel). Fig. 6A As shown, 2D cores (i.e., weights) from different input channels (or channel groups for sparse input tensors) can be placed in PEs of different columns so that multiple input channels are processed simultaneously at one time, and 2D cores from the same input channel can be distributed between multipliers within a PE so that the multipliers can process multiple output channels simultaneously at one time. For example, multiple (Y1) weights from channel 1 (C=1) and 1 to Y1 cores from filters (i.e., weights from the same input channel of multiple filters) can be fed into the first PE, and multiple (Y1) weights from channel 2 (C=2) and 1 to Y1 cores from filters can be fed into the second PE. In this way, 2D cores from different input channels are distributed between PE columns.

[0063] In some embodiments involving sparse input tensors, each weight may 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 may be used to identify the corresponding input value to perform multiplication with a multiplier. In some embodiments, if the number of channels is less than the number of PEs within each PE cluster (each row), the remaining PEs may be used for other vector operations.

[0064] In some embodiments, the convolution operations other than the 1*1 convolution operation described above may be decomposed into one or more 3*3 convolutions and mapped to a 3*3 native operation mode (eg, using a 3*3 kernel). Figure 6B As shown, each 2D 3*3 core has nine weights from the same input channel, represented as (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), which can be allocated to PEs in the same row (different columns) for simultaneous processing. Nine weights from different input channels can be allocated in different PE rows.

[0065] Figure 7 An example architecture diagram of an internal buffer in a PE array according to various embodiments is illustrated. In some embodiments, each PE in the PE array is coupled to an input buffer (denoted as IBUF) 722 to store input values. These input values ​​can be retrieved by the PE based on a given weight index to find the corresponding input value. Then, the retrieved input value can be multiplied by the weight value in the multiplier in the PE. In actual implementation, the depth of the IBUF is usually limited, which means that an IBUF 722 can only store input values ​​from a fixed number of input channels. This design works well for sparse input tensors because the number of non-zero input channels is also limited. However, it is often seen that the number of non-zero input channels may exceed the depth of the IBUF 722. In these cases, the IBUF 722 may have to perform cache replacement to read the necessary input values ​​from external memory, which is expensive and inefficient.

[0066] In some embodiments, the IBUF of each PE may be configured as a dedicated memory or a 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, each channel group including a fixed number of channels, and the fixed number is an integer greater than one; and pruning each of the one or more weight tensors so that only a few channels in each of the multiple channel groups include non-zero input values, and the other channels in each channel group include all zeros. After the pruning process, each channel group includes the same percentage of non-zero weights. The granularity of sparsification can be classified as fine particles 710 and coarse particles 750. When a non-zero input channel is selected from a plurality of channels less than a fixed number, fine particle sparsification 710 occurs, and when a non-zero input channel is selected from a plurality of channels greater than a fixed number, coarse particle sparsification 750 occurs. For example, if weight sparsity is 15 / 16 (1 non-zero input channel out of 16 channels), selecting a non-zero input channel from every 16 input channels (e.g., a channel group includes 16 input channels) can be determined as fine-grained sparsification 710, while selecting 4 non-zero input channels from every 64 input channels (e.g., a channel group includes 64 input channels) can be determined as coarse-grained sparsification 750.

[0067] In some embodiments, IBUF 722 can be configured as a dedicated memory with fine-grained sparse weight tensors, or a shared memory with coarse-grained sparse tensors. This means that the depth of IBUF 722 can be compared with a fixed number for classifying fine-grained and coarse-grained sparsification. If the depth of IBUF 722 is greater than the fixed number, this means that IBUF 722 is sufficient to store the necessary input values. In this way, due to the exclusive dedicated memory, data retrieval performance is optimal. If the depth of IBUF 722 is less than the fixed number, multiple adjacent PEs can share their IBUFs, expressed as shared IBUF 780, to store input values ​​that can be retrieved by them. In this way, the input values ​​that are copied are reduced, and the overall storage efficiency is improved.

[0068] Figure 8 An example method 800 for performing neural network computations using adaptive tensor shapes according to various embodiments is illustrated. The method 800 may be performed by Figures 1 to 7 The operations of method 800 presented below are intended to be illustrative. Depending on the implementation, method 800 may include additional, fewer, or alternative steps performed in various orders or in parallel.

[0069] Block 810 includes receiving a first input feature map (IFM) and one or more first filters at a first layer of a convolutional neural network (CNN) for convolution using a processing element (PE) array, wherein each PE in the PE array includes a plurality of (Y1) multipliers, and the PE array is arranged into a plurality of (Y2) rows and a plurality of (X) columns. In some embodiments, each row of PEs is coupled to a plurality of (Y1) adder trees corresponding to the plurality of (Y1) multipliers in each PE, respectively, wherein each multiplier in each PE sends a multiplication output to a corresponding adder tree for aggregation. The plurality of (Y1) multipliers in each PE processes data in parallel, and the PEs in the PE array process data in parallel.

[0070] Block 820 includes determining a native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape includes a first outer dimension, an inner dimension, and a second outer dimension, wherein the native tensor shape maps the first IFM and the one or more first filters into the PE array.

[0071] Block 830 includes receiving a second IFM and one or more second filters at a second layer of the CNN for convolution using the PE array. In some embodiments, the second layer of the CNN is after the first layer of the CNN, and the second IFM includes more input channels than the first IFM and a lower resolution than the first IFM. In some embodiments, each of the one or more second filters includes multiple channels of a 2-dimensional (2D) kernel, each 2D kernel having a dimension of one by one (1*1) or three by three (3*3).

[0072] Block 840 includes reshaping the native tensor shape based on the second IFM and the one or more second filters, wherein the shaping includes scaling up the inner dimension and scaling down one of the first outer dimension and the second outer dimension, the scaling up and scaling down by a factor of F.

[0073] Box 850 includes feeding one or more second filters and a second IFM into the PE array for convolution based on the reshaped native tensor, wherein: in response to the first outer dimension being scaled down, the convolution includes: aggregating the outputs F rounds from the same row of PEs to obtain partial sums, and in response to the second outer dimension being scaled down, the convolution includes: aggregating the outputs from every F rows of PEs to obtain partial sums. In some embodiments, feeding the one or more second filters into the PE array based on the reshaped native tensor includes: transforming the one or more second filters into a matrix based on the first outer dimension and the inner dimension of the reshaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a one-by-one dimension, each row of the matrix includes weights of different input channels from the one or more second filters; and assigning the weights in each row of the matrix to PEs of different columns so that multiple input channels are processed simultaneously at one time. In some embodiments, feeding one or more second filters into the PE array according to the shaped native tensor includes: transforming the one or more second filters into a matrix according to a first outer dimension and an inner dimension of the shaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a three-by-three dimension and including nine weights, the nine weights are placed in the same row of the matrix; and assigning the nine weights from the same row of the matrix to PEs of different columns so that weights from the same channel are processed simultaneously at one time. In some embodiments, feeding the IFM into the PE array according to the shaped native tensor includes: transforming the IFM into a matrix according to the inner dimension and the second outer dimension of the shaped native tensor; and feeding the input values ​​of the IFM corresponding to the columns of the matrix into the buffer of the PE row.

[0074] Block 860 includes obtaining an output tensor of the convolution at the second layer of the CNN by aggregating the plurality of partial sums.

[0075] In the above description, Y1, Y2, X and F are all integers greater than one.

[0076] In some embodiments, the method 800 may further include: dividing the channels of one or more filters into a plurality of channel groups, each channel group including a fixed number of channels that is an integer greater than one; and pruning each of the one or more filters so that only a few channels in each of the plurality of channel groups include non-zero input values, and other channels in each channel group include all zeros. In some embodiments, the method 800 may further include: determining the depth of a buffer associated with each PE in the PE array; in response to the depth of the buffer being greater than the fixed number, configuring the buffer as a dedicated memory for each PE; and in response to the depth of the buffer being less than the fixed number, combining the buffer of the PE with one or more buffers of an adjacent PE as a shared memory. In some embodiments, the dedicated memory of each PE stores input values ​​that can be retrieved by multiple (Y1) multipliers within the PE, and the shared memory stores input values ​​that can be retrieved by multiple (Y1) multipliers within the PE and one or more adjacent PEs.

[0077] In some embodiments, each of the one or more second filters includes multiple non-zero weights, and feeding the one or more second filters into the PE array for convolution includes: feeding each non-zero weight into the multiplier of the corresponding PE as an index value pair including the non-zero weight and the corresponding index; and the convolution includes: retrieving the input value from the buffer of the corresponding PE according to the index; and sending the retrieved value and the non-zero weight to the multiplier to obtain an output; and sending the output to the corresponding adder tree for aggregation with the outputs generated by other multipliers of other PEs in the same row as the corresponding PE.

[0078] Fig. 9 An example computing device is illustrated in which any of the embodiments described herein may be implemented. The computing device may be used to implement Figures 1 to 8 The computing device 900 may include a bus 902 or other communication mechanism for transmitting information, and one or more hardware processors 904 coupled to the bus 902 for processing information. The hardware processor(s) 904 may be, for example, one or more general-purpose microprocessors.

[0079] The computing device 900 may also include a main memory 907, such as a random access memory (RAM), a cache, and / or other dynamic storage device, coupled to the bus 902 for storing information and instructions to be executed by the (one or more) processors 904. The main memory 907 may also be used to store temporary variables or other intermediate information during the execution of instructions to be executed by the (one or more) processors 904. When stored in a storage medium accessible to the (one or more) processors 904, such instructions can transform the computing device 900 into a special-purpose machine customized to perform the operations specified in the instructions. The main memory 907 may include non-volatile media and / or volatile media. Non-volatile media may include, for example, optical or magnetic disks. Volatile media may include dynamic memory. Common forms of media may include, for example, floppy disks, floppy disks, hard disks, solid-state drives, tapes or any other magnetic data storage media, CD-ROMs, any other optical data storage media, any physical media with hole patterns, RAM, DRAM, PROM and EPROM, FLASH-EPROM, NVRAM, any other memory chip or cartridge, or a networked version thereof.

[0080] The computing device 900 may implement the techniques described herein using custom hardwired logic, one or more ASICs or FPGAs, firmware and / or program logic, which in combination with the computing device may make the computing device 900 a special purpose machine or be programmed as a special purpose machine. According to one embodiment, the techniques herein are performed by the computing device 900 in response to the execution of one or more sequences of one or more instructions contained in the main memory 907 by the processor(s) 904. These instructions may be read into the main memory 907 from another storage medium such as a storage device 909. Execution of the sequence of instructions contained in the main memory 907 causes the processor(s) 904 to perform the process steps described herein. For example, the processes / methods disclosed herein may be implemented by computer program instructions stored in the main memory 907. When these instructions are executed by the processor(s) 904, they may perform the steps shown in the corresponding figures and described above. In alternative embodiments, hardwired circuits may be used instead of software instructions or in combination with software instructions.

[0081] The computing device 900 also includes a communication interface 910 coupled to the bus 902. The communication interface 910 can provide a bidirectional data communication coupling to one or more network links that are connected to one or more networks. As another example, the communication interface 910 can be a local area network (LAN) card to provide a data communication connection to a compatible LAN (or a WAN component to communicate with a WAN). Wireless links can also be implemented.

[0082] The execution of certain operations may be distributed among processors, not only residing within a single machine, but also deployed across multiple machines. In some example embodiments, the processor or the engine implemented by the processor may be located in a single geographic location (e.g., in a home environment, an office environment, or a server farm). In other example embodiments, the processor or the engine implemented by the processor may be distributed across multiple geographic locations.

[0083] The various processes, methods and algorithms described in the foregoing sections may be specifically implemented in code modules executed by one or more computer systems or computer processors including computer hardware, and fully or partially automated by them. The processes and algorithms may be implemented partially or fully in dedicated circuits.

[0084] When the functions disclosed herein are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. (All or part) of the specific technical solutions disclosed herein or aspects contributing to the current technology can be specifically implemented in the form of a software product. The software product can be stored in a storage medium, including multiple instructions that make a computing device (which can be a personal computer, server, network equipment, etc.) perform all or some steps of the method of an embodiment of the application. The storage medium may include a flash drive, a portable hard disk drive, a ROM, a RAM, a disk, an optical disk, another medium operable to store program code, or any combination thereof.

[0085] Certain embodiments also provide a system, including a processor and a non-transitory computer-readable storage medium storing instructions, the instructions being executable by the processor so that the system performs operations corresponding to the steps in any method of the above disclosed embodiments. Certain embodiments also provide a non-transitory computer-readable storage medium configured with instructions, the instructions being executable by one or more processors so that the one or more processors perform operations corresponding to the steps in any method of the above disclosed embodiments.

[0086] The embodiments disclosed herein may be implemented by a cloud platform, a server or a server group (hereinafter collectively referred to as a "service system") interacting with a client. The client may be a terminal device or a client registered by a user on the platform, wherein the terminal device may be a mobile terminal, a personal computer (PC), or any device on which a platform application may be installed.

[0087] The various features and processes described above can be used independently of each other, or can be combined in various ways. All possible combinations and sub-combinations are intended to fall within the scope of the present disclosure. In addition, certain method or process blocks may be omitted in some embodiments. The methods and processes described herein are also not limited to any particular order, and the blocks or states associated therewith may be performed in other appropriate orders. For example, the blocks or states described may be performed in a different order than that specifically disclosed, or multiple blocks or states may be combined in a single block or state. The example blocks or states may be performed serially, in parallel, or in some other manner. Blocks or states may be added to or removed from the disclosed example embodiments. The configuration of the exemplary systems and components described herein may be different from the described configuration. For example, compared to the disclosed example embodiments, elements may be added, removed, or rearranged.

[0088] The various operations of the exemplary methods described herein may be performed at least in part by an algorithm. The algorithm may be included in a program code or instruction stored in a memory (e.g., the non-transient computer-readable storage medium described above). Such an algorithm may include a machine learning algorithm. In some embodiments, the machine learning algorithm may not explicitly program a computer to perform a function, but may learn from a training sample to make a prediction model that performs the function.

[0089] The various operations of the exemplary methods described herein may be performed at least in part by one or more processors that are temporarily configured (e.g., by software) or permanently configured to perform the relevant operations. Whether temporarily or permanently configured, such a processor may constitute a processor-implemented engine that operates to perform one or more operations or functions described herein.

[0090] Similarly, the methods described herein may be implemented at least in part by a processor, wherein the specific one or more processors are examples of hardware. For example, at least some of the operations of the method may be performed by one or more processors or an engine implemented by the processor. Moreover, one or more processors may also be operated to support the execution of related operations in a "cloud computing" environment or as a "software as a service" (SaaS). For example, at least some operations may be performed by a group of computers (as an example of a machine including a processor), wherein these operations may be accessed via a network (e.g., the Internet) and via one or more appropriate interfaces (e.g., an application program interface (API)).

[0091] The execution of certain operations may be distributed among processors, not only residing within a single machine, but also deployed across multiple machines. In some example embodiments, the processor or the engine implemented by the processor may be located in a single geographic location (e.g., in a home environment, an office environment, or a server farm). In other example embodiments, the processor or the engine implemented by the processor may be distributed across multiple geographic locations.

[0092] Throughout the specification, multiple instances can implement the parts, operations or structures described as single instances. Although the individual operations of one or more methods are illustrated and described as separate operations, one or more separate operations can be performed simultaneously, and it is not required to perform the operations in the illustrated order. The structure and function presented as a separate component in the example configuration can be implemented as a combined structure or the parts. Similarly, the structure and function presented as a single component can be implemented as a separate component. These and other variations, modifications, additions and improvements fall within the scope of this paper theme.

[0093] As used herein, "or" is inclusive and not exclusive, unless otherwise expressly indicated or indicated by context. Therefore, herein, "A, B, or C" means "A, B, A and B, A and C, B and C, or A, B and C", unless otherwise expressly indicated or indicated by context. Moreover, "and" is both joint and individual, unless otherwise expressly indicated or indicated by context. Therefore, herein, "A and B" means "A and B, jointly or individually", unless otherwise expressly indicated or indicated by context. Moreover, multiple instances can be provided for resources, operations, or structures described as single instances in this article. In addition, the boundaries between various resources, operations, engines, and data stores are arbitrary to some extent, and specific operations are illustrated in the context of specific illustrative configurations. Other allocations of functions are conceivable and may fall within the scope of various embodiments of the present disclosure. Typically, structures and functions presented as separate resources in the example configuration may be implemented as combined structures or resources. Similarly, structures and functions presented as single resources may be implemented as separate resources. These and other changes, modifications, additions and improvements fall within the scope of the embodiments of the present disclosure as expressed by the appended claims.Accordingly, the specification and drawings are to be regarded in an illustrative rather than a restrictive sense.

[0094] The terms "comprises" or "includes" are used to indicate the presence of subsequently stated features, but do not preclude the addition of other features. Unless otherwise specifically stated, or otherwise understood in the context of use, conditional language, such as "can," "might," or "may," etc., is generally intended to convey that certain embodiments include certain features, elements, and / or steps, while other embodiments do not. Thus, such conditional language is generally not intended to imply that features, elements, and / or steps are in any way required for one or more embodiments, or that one or more embodiments must include logic for determining, with or without user input or prompting, whether such features, elements, and / or steps are included in any particular embodiment or whether to be performed in any particular embodiment.

[0095] Although an overview of the subject matter has been described with reference to specific example embodiments, various modifications and changes may be made to these embodiments without departing from the broader scope of the embodiments of the present disclosure. For convenience only, such embodiments of the subject matter may be referred to herein individually or collectively by the term "invention", without intending to voluntarily limit the scope of the present application to any single disclosure or concept when more than one disclosure or concept is actually disclosed.

[0096] The embodiments described herein are described in sufficient detail to enable those skilled in the art to practice the disclosed teachings. Other embodiments may be used and derived therefrom, such that structural and logical substitutions and changes may be made without departing from the scope of the present disclosure. Therefore, the detailed description should not be construed as limiting, and the scope of the various embodiments is limited only by the appended claims and the full scope of equivalents to which these claims are entitled.

Claims

1. A computer-implemented method comprising: Receiving a first input feature map (IFM) and one or more first filters at a first layer of a convolutional neural network (CNN) for convolution using an array of processing elements (PEs), wherein each PE in the array of PEs comprises a plurality of (Y1) multipliers and the array of PEs is arranged into a plurality of (Y2) rows and a plurality of (X) columns; determining a native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape comprises a first outer dimension, an inner dimension, and a second outer dimension, wherein the native tensor shape maps the first IFM and the one or more first filters into the PE array; receiving a second IFM and one or more second filters at a second layer of the CNN for convolution using the PE array; reshaping the native tensor shape based on the second IFM and the one or more second filters, wherein the shaping comprises upscaling the inner dimension and downscaling one of the first outer dimension and the second outer dimension, the upscaling and the downscaling being a factor of F; The one or more second filters and the second IFM are fed into the PE array for convolution according to the shaped native tensor, wherein: In response to the first outer dimension being scaled down, the convolution includes: aggregating outputs F rounds from the same row of PEs to obtain a partial sum, and In response to the second outer dimension being scaled down, the convolution includes: aggregating outputs from every F rows of PEs to obtain partial sums; and obtaining an output tensor of the convolution at the second layer of the CNN by aggregating a plurality of the partial sums, Wherein, Y1, Y2, X and F are all integers greater than one.

2. The method according to claim 1, wherein: The second layer of the CNN is subsequent to the first layer of the CNN, and the second IFM includes more input channels than the first IFM and a lower resolution than the first IFM.

3. The method according to claim 1, wherein: Each of the one or more second filters includes a plurality of channels of a 2-dimensional (2D) kernel, each 2D kernel having a dimension of one by one (1*1) or three by three (3*3).

4. The method according to claim 3, wherein: The feeding the one or more second filters into the PE array according to the shaped native tensor comprises: transforming the one or more second filters into a matrix according to the first outer dimension and the inner dimension of the reshaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a one-by-one dimension, each row of the matrix comprises weights for different input channels from the one or more second filters; and The weights in each row of the matrix are assigned to PEs in different columns so that the multiple input channels are processed simultaneously at one time.

5. The method according to claim 3, wherein: The feeding the one or more second filters into the PE array according to the shaped native tensor comprises: transforming the one or more second filters into a matrix according to the first outer dimension and the inner dimension of the shaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a dimension of three by three and including nine weights, the nine weights are placed in the same row of the matrix; and The nine weights from the same row of the matrix are assigned to PEs of different columns so that the weights from the same channel are processed simultaneously at one time.

6. The method according to claim 5, wherein: The feeding the IFM to the PE array according to the shaped native tensor comprises: transforming the IFM into a matrix according to the inner dimension and the second outer dimension of the reshaped native tensor; and The input values ​​of the IFM corresponding to the columns of the matrix are fed into the buffers of the PE rows.

7. The method according to claim 1, further comprising: dividing the channels of the one or more filters into a plurality of channel groups, each channel group including a fixed number of channels that is an integer greater than one; as well as Each of the plurality of channel groups is pruned such that a fixed percentage of weights within the respective channel group are non-zero.

8. The method according to claim 7, further comprising: determining a depth of a buffer associated with each PE in the PE array; In response to the depth of the buffer being greater than the fixed number, configuring the buffer as dedicated memory for each PE; as well as In response to the depth of the buffer being less than the fixed number, the buffer of the PE is combined with one or more buffers of a neighboring PE into a shared memory.

9. The method according to claim 8, wherein: The dedicated memory of each PE stores input values ​​that can be retrieved by the plurality (Y1) of multipliers within the PE.

10. The method according to claim 8, wherein: The shared memory stores input values ​​that can be retrieved by the plurality of (Y1) multipliers within the PE and the one or more adjacent PEs.

11. The method according to claim 1, wherein: Each row of PEs is coupled to a plurality of (Y1) adder trees respectively corresponding to the plurality of (Y1) multipliers in each PE, wherein each multiplier in each PE sends a multiplication output to a corresponding adder tree for aggregation.

12. The method according to claim 1, wherein: Each of the one or more second filters comprises a plurality of non-zero weights, and Feeding the one or more second filters into the PE array for convolution comprises: feeding each non-zero weight into the multiplier of the corresponding PE as an index-value pair including the non-zero weight and the corresponding index; and The convolution includes: Retrieving an input value from a buffer of the corresponding PE according to the index; and sending the retrieved value and the non-zero weight to the multiplier to obtain an output; and The output is sent to the corresponding adder tree to be aggregated with outputs generated by other multipliers of other PEs in the same row as the corresponding PE.

13. The method according to claim 1, wherein: The plurality of (Y1) multipliers in each PE processes data in parallel, and the PEs in the PE array process data in parallel.

14. A system comprising: one or more processors; and one or more non-transitory computer-readable memories coupled to the one or more processors and configured with instructions executable by the one or more processors to cause the system to perform operations comprising: Receiving a first input feature map (IFM) and one or more first filters at a first layer of a convolutional neural network (CNN) for convolution using an array of processing elements (PEs), wherein each PE in the array of PEs comprises a plurality of (Y1) multipliers and the array of PEs is arranged into a plurality of (Y2) rows and a plurality of (X) columns; determining a native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape comprises a first outer dimension, an inner dimension, and a second outer dimension, wherein the native tensor shape maps the first IFM and the one or more first filters into the PE array; receiving a second IFM and one or more second filters at a second layer of the CNN for convolution using the PE array; reshaping the native tensor shape based on the second IFM and the one or more second filters, wherein the shaping comprises upscaling the inner dimension and downscaling one of the first outer dimension and the second outer dimension, the upscaling and the downscaling being a factor of F; The one or more second filters and the second IFM are fed into the PE array for convolution according to the shaped native tensor, wherein: In response to the first outer dimension being scaled down, the convolution includes: aggregating outputs F rounds from the same row of PEs to obtain a partial sum, and In response to the second outer dimension being scaled down, the convolution includes: aggregating outputs from every F rows of PEs to obtain partial sums; and obtaining an output tensor of the convolution at the second layer of the CNN by aggregating a plurality of the partial sums, Wherein, Y1, Y2, X and F are all integers greater than one.

15. The system of claim 14, wherein: The second layer of the CNN is subsequent to the first layer of the CNN, and the second IFM includes more input channels than the first IFM and a lower resolution than the first IFM.

16. The system of claim 14, wherein: The operations also include: dividing the channels of the one or more filters into a plurality of channel groups, each channel group including a fixed number of channels that is an integer greater than one; and Each of the one or more filters is pruned such that only one channel in each of the plurality of channel groups includes a non-zero input value and the other channels in the respective channel groups include all zeros.

17. The system of claim 16, wherein: The operations also include: determining a depth of a buffer associated with each PE in the PE array; In response to the depth of the buffer being greater than the fixed number, configuring the buffer as dedicated memory for each PE; and In response to the depth of the buffer being less than the fixed number, the buffer of the PE is combined with one or more buffers of a neighboring PE into a shared memory.

18. The system of claim 14, wherein: Each of the one or more second filters includes a plurality of channels of a 2-dimensional (2D) kernel, each 2D kernel having a dimension of one by one (1*1) or three by three (3*3).

19. The system of claim 18, wherein: The feeding the one or more second filters into the PE array according to the shaped native tensor comprises: transforming the one or more second filters into a matrix according to the first outer dimension and the inner dimension of the reshaped native tensor, wherein, in response to each 2D kernel in the one or more second filters having a one-by-one dimension, each row of the matrix comprises weights for different input channels from the one or more second filters; and The weights in each row of the first matrix are allocated to PEs in different columns, so that the multiple input channels are processed simultaneously at one time.

20. A non-transitory computer-readable storage medium configured with instructions executable by one or more processors to cause the one or more processors to perform operations comprising: Receiving a first input feature map (IFM) and one or more first filters at a first layer of a convolutional neural network (CNN) for convolution using an array of processing elements (PEs), wherein each PE in the array of PEs comprises a plurality of (Y1) multipliers and the array of PEs is arranged into a plurality of (Y2) rows and a plurality of (X) columns; determining a native tensor shape based on the first IFM and the one or more first filters, wherein the native tensor shape comprises a first outer dimension, an inner dimension, and a second outer dimension, wherein the native tensor shape maps the first IFM and the one or more first filters into the PE array; receiving a second IFM and one or more second filters at a second layer of the CNN for convolution using the PE array; reshaping the native tensor shape based on the second IFM and the one or more second filters, wherein the shaping comprises upscaling the inner dimension and downscaling one of the first outer dimension and the second outer dimension, the upscaling and the downscaling being a factor of F; The one or more second filters and the second IFM are fed into the PE array for convolution according to the shaped native tensor, wherein: In response to the first outer dimension being scaled down, the convolution includes: aggregating outputs F rounds from the same row of PEs to obtain a partial sum, and In response to the second outer dimension being scaled down, the convolution includes: aggregating outputs from every F rows of PEs to obtain partial sums; and obtaining an output tensor of the convolution at the second layer of the CNN by aggregating a plurality of the partial sums, Wherein, Y1, Y2, X and F are all integers greater than one.

Citation Information

Cited By

  • Convolution calculation method, electronic equipment, storage medium and program product

    CN121233886A