Convolution accelerator using in-memory computation
11562229 · 2023-01-24
Assignee
Inventors
Cpc classification
G06F17/16
PHYSICS
G06F17/15
PHYSICS
International classification
G06F17/15
PHYSICS
Abstract
A method for accelerating a convolution of a kernel matrix over an input matrix for computation of an output matrix using in-memory computation involves storing in different sets of cells, in an array of cells, respective combinations of elements of the kernel matrix or of multiple kernel matrices. To perform the convolution, a sequence of input vectors from an input matrix is applied to the array. Each of the input vectors is applied to the different sets of cells in parallel for computation during the same time interval. The outputs from each of the different sets of cells generated in response to each input vector are sensed to produce a set of data representing the contributions of that input vector to multiple elements of an output matrix. The sets of data generated across the input matrix are used to produce the output matrix.
Claims
1. A method for accelerating a convolution of a kernel matrix over an input matrix, comprising: storing combinations of elements of the kernel matrix in respective sets of cells in an array of cells; and applying elements of an input vector from the input matrix to the sets of cells storing the combinations of elements of the kernel matrix; sensing outputs responsive to the elements of the input vector from the sets of cells to produce data representing contributions of the input vector to multiple elements of an output matrix; applying input vectors from the input matrix in a sequence, including said first mentioned input vector, to the sets of cells storing the combinations of elements of the kernel matrix; for each input vector in the sequence, sensing outputs from the sets of cells to produce output data representing contributions to the output matrix; and combining the output data representing contributions to the output matrix for each of the input vectors in the sequence to produce the output matrix.
2. The method of claim 1, wherein the sets of cells are disposed in an array of cells including a plurality of columns of cells, and wherein each set of cells is composed of cells in a single column in the plurality of columns.
3. The method of claim 1, wherein the sets of cells comprise programmable resistance memory cells.
4. The method of claim 1, wherein the sets of cells comprise charge trapping memory cells.
5. The method of claim 1, wherein said sensing includes sensing a combined conductance of cells in each of the sets of cells in response to the input vector.
6. The method of claim 1, wherein said outputs represent, for each of the sets of cells, respective sums of products of the elements of the input vector and corresponding combinations of elements of the kernel matrix.
7. The method of claim 1, including providing the output data to digital logic, and combining the output data in the digital logic for each of the input vectors in the sequence to produce the output matrix.
8. The method of claim 1, wherein said convolution of a kernel matrix over an input matrix is a layer of a convolutional neural network.
9. A device for convolution of a kernel matrix over an input matrix, comprising: an array of memory cells storing combinations of elements of the kernel matrix in respective sets of cells in the array of cells; driver circuitry configured to apply elements of an input vector from the input matrix to the respective sets of cells; and sensing circuitry configured to sense output data from the respective sets of cells to produce data representing contributions of the input vector to multiple elements of an output matrix, wherein said output data represents, for the respective sets of cells, a sum of products of the elements of the input vector and the combinations of elements of the kernel matrix stored in the respective sets.
10. The device of claim 9, including logic coupled to the driver circuitry to apply a sequence of input vectors of the input matrix, including said first mentioned input vector, to the driver circuitry, and logic coupled to the sensing circuitry to combine the output data for the sequence of input vectors to produce elements of the output matrix.
11. The device of claim 9, wherein the array of memory cells comprises a plurality of columns, a set of cells of the respective sets of cells is composed of cells in a single column in the plurality of columns.
12. The device of claim 9, wherein the array of cells comprises programmable resistance memory cells.
13. The device of claim 9, wherein the array of cells comprises charge trapping memory cells.
14. The device of claim 9, wherein said sensing circuitry senses a combined conductance of cells in the respective sets of cells in response to the input vector.
15. The device of claim 9, wherein the array of memory cells is disposed on a first integrated circuit, and including logic disposed on circuitry outside the first integrated circuit to apply a sequence of input vectors of an input matrix to the driver circuitry, and to combine the sets of data for each of the input vectors in the sequence to produce the output matrix.
16. The device of claim 9, wherein said convolution of a kernel matrix over an input matrix is a layer of a convolutional neural network.
17. A device for convolution of a kernel matrix over an input matrix, comprising: an array of memory cells including a plurality of rows and a plurality of columns, storing combinations of elements of the kernel matrix in respective columns in the plurality of columns; driver circuitry configured to apply elements of an input vector from the input matrix to respective rows in the plurality of rows; sensing circuitry configured to sense output data from the respective columns to produce data representing contributions of said input vector to elements of an output matrix; logic coupled to the driver circuitry and the sensing circuitry to apply a sequence of input vectors of the input matrix, including said input vector, to the driver circuitry and produce output data representing contributions of input vectors in the sequence, including said input vector, to elements of the output matrix; and logic coupled to the sensing circuitry to combine the output data for the sequence of input vectors to produce elements of the output matrix, wherein said output data represents, for the respective columns, a sum of products of the elements of said input vector on the respective rows and the combinations of elements of the kernel matrix stored in the respective columns.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
DETAILED DESCRIPTION
(9) A detailed description of embodiments of the present invention is provided with reference to the
(10)
(11) In a convolution, the kernel is applied, usually in a scan pattern, to the input matrix in a sequence having a horizontal stride and a vertical stride. In each particular stride, the elements of the kernel are combined with a set of elements of the input matrix in a window at the location of the stride. The results of the computation for each stride can be used to compute a single output value (e.g. 20) in the output matrix 12, or can be used in many other ways depending on the convolution functions. In the illustrated example of
(12) For each stride of the input kernel, a different combination of input vectors is utilized as the window for the kernel scans through the input matrix, to produce the corresponding value in the output matrix. However, each of the input vectors can be utilized in multiple strides for computation of multiple output values. For example, if the kernel matrix is a 3×3×C matrix, it can be represented by 9 kernel vectors having a length of C elements each. For a horizontal stride of 1, and a vertical stride of 1, each of the input vectors can be utilized by each of the 9 kernel vectors in 9 different strides.
(13) In
(14) Thus, in a convolution, each input vector is combined with the kernel in multiple strides of the convolution, where each stride can be used to compute one element (typically) of the output matrix. In each stride of the convolution in which a given input vector is used, there is a set of elements of the kernel with which it is combined. For each stride, the set of elements of the kernel applied to the input vector is in a different location in the kernel.
(15) In a convolution accelerator as described herein, the multiple sets of elements in the kernel with which a particular input vector is combined, i.e. the sets for every stride in which it is used, are stored in different sets of cells (e.g. cells in different columns) of the array of cells. The outputs of the different sets of cells represent the contribution of the input vector to the output of a respective one of the multiple strides in which it is used in the convolution. The outputs of the different sets of cells can be sensed in parallel, and provided to logic circuitry which gathers and combines them to form the output matrix.
(16)
(17) In this arrangement, the cells in each column that are coupled to the set of first access lines include a set of memory cells which stores a combination of elements of the kernel matrix. For this example, the kernel matrix can be characterized as a set of vectors of length C (e.g. F1-FC of
(18) TABLE-US-00001 F.sup.1.sub.−1, −1 F.sup.1.sub.−1, 0 F.sup.1.sub.−1, 1 F.sup.1.sub.0, −1 F.sup.1.sub.0, 0 F.sup.1.sub.0, 1 F.sup.1.sub.1, −1 F.sup.1.sub.1, 0 F.sup.1.sub.1, 1
(19) Thus, the kernel matrix includes nine vectors. In a convolution of horizontal and vertical stride 1 over an input matrix, each vector of the input matrix can be combined with each of the 9 vectors for the purposes of computing different values in the output matrix. Some input vectors on the edges, for example, may be combined with different numbers of the vectors, depending on the particular convolution being computed.
(20) The array of cells in
(21) To perform an in-memory computation, driver circuitry applies an input vector X1:XC to the set of first access lines 111-118 in this example, assuming a depth C of 8. Sensing circuitry is coupled to the set of second access lines 101-109 to sense, for each of the multiple sets of cells on the different second access lines, a combination of the conductances of the memory cells in their corresponding set of cells.
(22) For example, a current on each of the second access lines represents an element-wise sum-of-products of the filter vector implemented by the weights stored in the memory cells in the column, and an input vector applied on the first access lines. This element-wise sum-of-products can be computed simultaneously utilizing 9 different sense circuits in parallel for each of the 9 filter vectors.
(23) For the purposes of example,
(24) Thus, for a window centered at coordinate 2,2 on the input matrix, the output on second access line 101 is a partial sum used for the computation of output element M33. The output on second access line 102 is a partial sum used for the computation of output element M32. The output on second access line 103 is a partial sum used for the computation of output element M31. The output on second access line 104 is a partial sum used for the computation of output element M23, and so on. The output on the second access line 109 is a partial sum used for the computation of output element M11. Thus, the outputs of the nine second access lines represent contributions of the input vector to the computations of nine different strides.
(25) For a next window centered at coordinate 2,3, as illustrated at 126, the output on second access line 101 is a partial sum used for the computation of output element M34. The output on second access line 102 is a partial sum used for the computation of output element M33. The output on second access line 103 is a partial sum used for the computation of output element M32. The output on second access line 104 is a partial sum used for the computation of output element M24, and so on. The output on the second access line 109 is a partial sum used for the computation of output element M12.
(26) To compute the value of an element of the output matrix, the partial sums from each of the input vectors that contribute to that value must be gathered and accumulated as the sequence of input vectors is applied to the array of cells used for the in-memory computation. This function of gathering and accumulating the partial sums can be executed using digital logic and scratchpad memory.
(27)
(28) The memory cells can be resistive RAMs, where resistances of the memory cells represent the elements of a kernel (e.g. weights in a filter) as discussed above. Each memory cell in the array stores a weight factor W.sub.nm corresponding to an element of a filter vector, and can be represented as storing weights W.sub.11, W.sub.12, W.sub.13, W.sub.21, W.sub.22, and W.sub.23 respectively.
(29) A set of first access lines (e.g., 481, 482) is coupled to the memory cells in respective rows of memory cells of the first type. A set of second access lines (e.g., 491, 492, and 493) is coupled to the memory cells in respective columns of the memory cells of the first type. The set of first access lines (e.g., 481, 482) is coupled to the row decoder/drivers 455 and the set of second access lines is coupled to the column decoder 456. Signals on the first access lines in the set of first access lines can represent inputs x1, x2 to the respective rows. In this example, the row decoder/drivers 455 asserts a signal input x1 on the first access line 481 and a signal input x2 on the first access line 482, which can represent elements of an input vector.
(30) The sensing circuit 454 is coupled to respective second access lines in the set of second access lines via the column decoder 456. Current (e.g., y1, y2, y3) sensed at a particular second access line (e.g., 491, 492, 493) in the set of second access lines can represent a sum-of-products of the inputs x1, x2 by respective weight factors Wnm.
(31) Thus, in this example, the set of cells on second access line 491 produces a combined current on the second access line in response to the input vector which, upon sensing, results in a digital value y.sub.1=x.sub.1*w.sub.11+x.sub.2*w.sub.21. The digital value output from line 492 is y.sub.2=x.sub.1*w.sub.12+x.sub.2*w.sub.22. The digital value output from line 493 is y.sub.3=x.sub.1*w.sub.13+x.sub.2*w.sub.23. The sum-of-products outputs y.sub.1, y.sub.2, y.sub.3 can be stored in the data buffer 458, in an output data path.
(32) The output data path is coupled to gather circuits 460, which can comprise a set of multiplexers controllable to align the outputs for a given input vector in multiple groups for combination with the output from other input vectors in the computation of multiple output values. The multiple groups can be applied to a set of accumulator 461 to compute the output matrix values. The output matrix values can then be applied to memory 462.
(33)
(34) In this arrangement, the cells in each column that are coupled to the set of first access lines include a set of memory cells which stores a combination of elements of the multiple kernel matrices. For this example, the kernel matrix for FILTER 1, as shown in
(35) TABLE-US-00002 F.sup.1.sub.−1, −1 F.sup.1.sub.−1, 0 F.sup.1.sub.−1, 1 F.sup.1.sub.0, −1 F.sup.1.sub.0, 0 F.sup.1.sub.0, 1 F.sup.1.sub.1, −1 F.sup.1.sub.1, 0 F.sup.1.sub.1, 1
(36) The kernel matrix for FILTER M can be characterized as a set of vectors of length C (e.g. F1-FC of
(37) TABLE-US-00003 F.sup.M.sub.−1, −1 F.sup.M.sub.−1, 0 F.sup.M.sub.−1, 1 F.sup.M.sub.0, −1 F.sup.M.sub.0, 0 F.sup.M.sub.0, 1 F.sup.M.sub.1, −1 F.sup.M.sub.1, 0 F.sup.M.sub.1, 1
(38) Thus, each of the M kernel matrices includes nine vectors. In a convolution of horizontal and vertical stride 1 over an input matrix, each vector of the input matrix can be combined with each of the 9 vectors in each of the M kernels (9*M combinations) for the purposes of computing different values in the output matrix. Some input vectors on the edges for example may be combined with different numbers of the vectors, depending on the particular convolution being computed.
(39) The array of cells in
(40) To perform an in-memory computation, driver circuitry applies an input vector X1:XC to the set of first access lines 521-528, in this example, assuming a depth C of 8. Sensing circuitry is coupled to the set of second access lines 501-509 and to the set of second access lines 511-519 to sense, for each of the multiple sets of cells on the different second access lines, a combination of the conductances of the memory cells in their corresponding set of cells.
(41) As mentioned above, the sensed outputs can be provided to digital logic to gather and accumulate the outputs to compute the elements of the output matrix.
(42) In some embodiments, the array of cells can be expanded to store the kernel data for a plurality of convolutions, such as convolutions for multiple layers of a CNN.
(43)
(44) In this example, the in-memory computation unit 601 which comprises an array of memory cells, is manufactured on the same integrated circuit as the logic circuits (Gather and accumulate unit 602 and local memory 603) used to manipulate the outputs. Host 610 and large-scale memory 620 can be implemented off of the integrated circuit 600.
(45) In some embodiments, all these components can be implemented on a single integrated circuit, or single multichip package.
(46)
(47) In this embodiment, an in-memory computation unit 701 is implemented on a first integrated circuit 700. The first integrated circuit 700 has digital outputs from the sense amplifiers for example applied to a second integrated circuit 710. The second integrated circuit 710 comprises logic circuitry for manipulating the outputs, including the gather and accumulate unit 702 and local memory 703 in this example. Likewise, a host 705 and large-scale memory 706 may be implemented on a third integrated circuit 720. The integrated circuit 710 and 720 can be manufactured using fabrication facilities optimized for implementation of logic circuits. The integrated circuit 700 on the other hand can be manufactured using fabrication facilities optimize for the type of memory array utilized.
(48)
(49) Using this process, an input matrix can be applied only once to the in-memory computation unit. This can eliminate the requirement to repeatedly read and write vectors from the input matrix for the purposes of computation of different strides of the convolution. As result, the system can operate with lower cost, and lower bandwidth data paths for movement of the input matrix and output matrix among the computational resources.
(50) In embodiments in which the convolutions are implemented as layers of a CNN, for example, this cycle can be repeated using a single in-memory computation unit in which multiple kernels or sets of kernels are arranged in a large-scale array of cells, for the multiple layers of the CNN. Once an output vector is computed as a result of a first layer of the CNN, the algorithm can loop to providing the input matrix to another layer of the CNN. Alternatively, the output matrix produced as a result of the in-memory computation unit can be configured as an input matrix for a next layer of the CNN.
(51) As a result of utilizing the in-memory computation configured as described herein, a system for executing convolutions is provided that can significantly reduce the amount of data movement required. This can increase the speed of operation, reduce the power required to execute the operation, and decrease the bandwidth requirement for movement of data during the convolution.
(52) While the present invention is disclosed by reference to the preferred embodiments and examples detailed above, it is to be understood that these examples are intended in an illustrative rather than in a limiting sense. It is contemplated that modifications and combinations will readily occur to those skilled in the art, which modifications and combinations will be within the spirit of the invention and the scope of the following claims.