+ All Categories
Home > Documents > Memory-Optimal Direct Convolutions for Maximizing...

Memory-Optimal Direct Convolutions for Maximizing...

Date post: 30-Apr-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
10
Memory-Optimal Direct Convolutions for Maximizing Classification Accuracy in Embedded Applications Albert Gural 1 Boris Murmann 1 Abstract In the age of Internet of Things (IoT), embed- ded devices ranging from ARM Cortex M0s with hundreds of KB of RAM to Arduinos with 2KB RAM are expected to perform increasingly so- phisticated classification tasks, such as voice and gesture recognition, activity tracking, and biomet- ric security. While convolutional neural networks (CNNs), together with spectrogram preprocessing, are a natural solution to many of these classifica- tion tasks, storage of the network’s activations often exceeds the hard memory constraints of em- bedded platforms. This paper presents memory- optimal direct convolutions as a way to push clas- sification accuracy as high as possible given strict hardware memory constraints at the expense of extra compute. We therefore explore the oppo- site end of the compute-memory trade-off curve from standard approaches that minimize latency. We validate the memory-optimal CNN technique with an Arduino implementation of the 10-class MNIST classification task, fitting the network specification, weights, and activations entirely within 2KB SRAM and achieving a state-of-the- art classification accuracy for small-scale embed- ded systems of 99.15%. 1. Introduction Moving machine learning inference from the cloud to energy-efficient edge devices is a research topic of grow- ing interest. Running machine learning models locally may help mitigate privacy concerns associated with a user’s raw sensor data and can enable truly autonomous operation by eliminating the need for a data connection. In this applica- tion paradigm, often assimilated with the Internet of Things 1 Department of Electrical Engineering, Stanford Univer- sity, Stanford, USA. Correspondence to: Albert Gural <agu- [email protected]>, Boris Murmann <[email protected]>. Proceedings of the 36 th International Conference on Machine Learning, Long Beach, California, PMLR 97, 2019. Copyright 2019 by the author(s). (IoT), the machine learning model is trained on a server and subsequently deployed across a large number of edge devices. Consequently, these platforms must have sufficient local memory to store the weights, biases, activations and configuration parameters associated with typical machine learning algorithms. However, low-cost IoT hardware is severely resource constrained (often just 2-16KB of mem- ory), which stands at odds with the memory-hungry nature of top-performing algorithms, such as deep CNNs. To address this issue, recent work has looked at memory- efficient alternatives to CNNs and has asked the question: Given a (small) fixed memory budget, what is the maximum classification accuracy that one can achieve? In this quest, Gupta et al. (2017) advocated k-Nearest Neighbor (KNN) models to utilize a memory size as low as 2KB (Arduino UNO platform). Similarly, Kumar et al. (2017) proposed a sparse tree-based algorithm, building on the assumption that a CNN can not run on a device with KB-size memory. However, with the departure from CNNs, which are known to achieve state-of-the-performance, there is an inherent sacrifice in classification accuracy that is difficult to recoup by engineering a new algorithm. For example, the 2KB tree- based approach of Kumar et al. (2017) is limited to 94.38% accuracy on a two-class MNIST-2 dataset (Jose et al., 2013). This paper presents strategies for implementing CNNs under strict memory resource constraints. While the described techniques are generally applicable, we illustrate their utility through the implementation of a 2KB, four-layer CNN for image classification, thus imposing similar constraints as in Kumar et al. (2017). We show that despite this extreme resource scarcity, a test accuracy of 99.15% is achievable for the original MNIST-10 dataset from LeCun et al. (1998). The main contributions of this work are: (1) identification of a method for memory-optimal direct convolution along with a proof of its optimality and (2) an example implementation of MNIST-10 classification on a 2KB Arduino platform. The latter should be viewed as an illustrative case study on the asymptotic limits of memory size reduction. As such, it is not necessarily practical or optimized for other performance aspects such as throughput and compute energy. Figure 1 gives a taste of the results of our approach. Code and supplemental material are available here.
Transcript
Page 1: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions for MaximizingClassification Accuracy in Embedded Applications

Albert Gural 1 Boris Murmann 1

AbstractIn the age of Internet of Things (IoT), embed-ded devices ranging from ARM Cortex M0s withhundreds of KB of RAM to Arduinos with 2KBRAM are expected to perform increasingly so-phisticated classification tasks, such as voice andgesture recognition, activity tracking, and biomet-ric security. While convolutional neural networks(CNNs), together with spectrogram preprocessing,are a natural solution to many of these classifica-tion tasks, storage of the network’s activationsoften exceeds the hard memory constraints of em-bedded platforms. This paper presents memory-optimal direct convolutions as a way to push clas-sification accuracy as high as possible given stricthardware memory constraints at the expense ofextra compute. We therefore explore the oppo-site end of the compute-memory trade-off curvefrom standard approaches that minimize latency.We validate the memory-optimal CNN techniquewith an Arduino implementation of the 10-classMNIST classification task, fitting the networkspecification, weights, and activations entirelywithin 2KB SRAM and achieving a state-of-the-art classification accuracy for small-scale embed-ded systems of 99.15%.

1. IntroductionMoving machine learning inference from the cloud toenergy-efficient edge devices is a research topic of grow-ing interest. Running machine learning models locally mayhelp mitigate privacy concerns associated with a user’s rawsensor data and can enable truly autonomous operation byeliminating the need for a data connection. In this applica-tion paradigm, often assimilated with the Internet of Things

1Department of Electrical Engineering, Stanford Univer-sity, Stanford, USA. Correspondence to: Albert Gural <[email protected]>, Boris Murmann <[email protected]>.

Proceedings of the 36 th International Conference on MachineLearning, Long Beach, California, PMLR 97, 2019. Copyright2019 by the author(s).

(IoT), the machine learning model is trained on a serverand subsequently deployed across a large number of edgedevices. Consequently, these platforms must have sufficientlocal memory to store the weights, biases, activations andconfiguration parameters associated with typical machinelearning algorithms. However, low-cost IoT hardware isseverely resource constrained (often just 2-16KB of mem-ory), which stands at odds with the memory-hungry natureof top-performing algorithms, such as deep CNNs.

To address this issue, recent work has looked at memory-efficient alternatives to CNNs and has asked the question:Given a (small) fixed memory budget, what is the maximumclassification accuracy that one can achieve? In this quest,Gupta et al. (2017) advocated k-Nearest Neighbor (KNN)models to utilize a memory size as low as 2KB (ArduinoUNO platform). Similarly, Kumar et al. (2017) proposeda sparse tree-based algorithm, building on the assumptionthat a CNN can not run on a device with KB-size memory.However, with the departure from CNNs, which are knownto achieve state-of-the-performance, there is an inherentsacrifice in classification accuracy that is difficult to recoupby engineering a new algorithm. For example, the 2KB tree-based approach of Kumar et al. (2017) is limited to 94.38%accuracy on a two-class MNIST-2 dataset (Jose et al., 2013).

This paper presents strategies for implementing CNNs understrict memory resource constraints. While the describedtechniques are generally applicable, we illustrate their utilitythrough the implementation of a 2KB, four-layer CNN forimage classification, thus imposing similar constraints asin Kumar et al. (2017). We show that despite this extremeresource scarcity, a test accuracy of 99.15% is achievablefor the original MNIST-10 dataset from LeCun et al. (1998).

The main contributions of this work are: (1) identification ofa method for memory-optimal direct convolution along witha proof of its optimality and (2) an example implementationof MNIST-10 classification on a 2KB Arduino platform.The latter should be viewed as an illustrative case studyon the asymptotic limits of memory size reduction. Assuch, it is not necessarily practical or optimized for otherperformance aspects such as throughput and compute energy.Figure 1 gives a taste of the results of our approach. Codeand supplemental material are available here.

Page 2: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

0 100 200 300 400 500 600 700Activation Memory (B)

Conv

olut

ion

Stra

tegy

Naive

Replace

Transpose

Herringbone

760.0 B

467.5 B

437.5 B

434.5 B

396s

396s

457s

819s Theoretical Limit

Figure 1. Activation memory versus convolution strategy for thestrategies of Section 3.4 applied to our network. Inference timeis also given for each strategy applied to all convolution layers.Herringbone is the only method that does not corrupt the data.

2. Related WorkThere is a large body of literature dealing with resource-efficient machine learning inference. Here, we review asubset of contributions that focus on similar KB-level mem-ory footprints as considered in our work, as well as a fewmethods for efficient convolution computation.

There are a few examples of ML techniques targetting KB-size devices. Gupta et al. (2017) presents ProtoNN, a k-Nearest Neighbor model optimized for small-memory foot-print by storing a judicious selection of training data. A2KB version of ProtoNN achieves 93.25% on MNIST-2.Kumar et al. (2017) presents Bonsai, tree-based algorithmutilizing sparse projections from the input data into a lower-dimensional space. A 2KB version of Bonsai achieves94.38% on MNIST-2. Kusupati et al. (2018) presents Fast-GRNN, a sequential model making use of residual networkconnections and low rank matrices. A 6KB version of Fast-GRNN achieves 98.20% on MNIST-10.

Unlike previous approaches to ML for tiny embedded de-vices, our work focuses on CNNs. There exists a largebody of work on optimizing CNNs. There are algorithmicspeedups, such as the Fast Fourier Transform (FFT) (Vasi-lache et al., 2014) and Winograd Transform (Lavin & Gray,2016), which convert convolutions into point-multiplies.There are also hardware/software speedups, such as un-rolling convolutions into matrix multiplies (Chellapilla et al.,2006; Chetlur et al., 2014) to make use of gemm libraries.

However, while there is an abundance of research into CNNspeedup optimization, memory optimization research ismore sparse. Motivated by CNN unrolling, Cho & Brand(2017) propose a partial unrolling of input features thatwastes much less memory in duplications while still takingadvantage of BLAS gemm speedups. However, as Zhanget al. (2018) points out, even this partial unrolling usesadditional memory beyond direct convolution approaches.Instead, Zhang et al. (2018) propose using direct convolu-tions for “zero-memory overhead” and demonstrate that bycarefully reordering the for-loops, one can exceed gemm

speed. However, it is important to understand that this is“zero-memory overhead” beyond the memory required tostore input and output activations. In this paper we showthat one can in fact do even better by overwriting stale inputactivations to store new output activations.

3. Memory-Optimal ConvolutionsWe start by restricting our attention to 2D convolutions withodd square kernels, valid padding, and stride of 1. Thiscovers the most common use case for convolutional layersin memory-constrained applications. The valid paddinghelps reduce activation storage and the other restrictions arecommonly found in popular CNN architectures (Krizhevskyet al., 2012; Simonyan & Zisserman, 2014). Extensionsto this restricted case are considered in the supplementarymaterial.

The general observation that direct convolutions can be per-formed in a more memory-efficient manner compared tothe “naive” approach of maintaining a separate area of mem-ory for convolution outputs stems from the observation thatconvolutions are local operations, so pixels in input featuremaps are computational dependencies of only a small num-ber of output features. Therefore, after an input pixel hassatisfied all of its dependencies, its memory can be deletedand used to store output feature pixels. In the restrictedsetting described above, two major cases are important foranalysis: same/decreasing channel depth, analyzed in Sec-tion 3.3 and increasing channel depth, in 3.4.

We additionally note that some of the analyses in the follow-ing sections are motivated by an understanding of memorylayout. For the following analyses, activations are stored inmemory in height, width, channel order, as shown at the topof Figure 2.

3.1. Notation

In this section, we will consider a convolution layer takingan hin×win×fin input feature map to an hout×wout×foutoutput feature map. The convolution kernel size is kh × kw(kh = kw = k for the restricted case). The padding andstride restrictions imply hout = hin− (kh− 1) and wout =win−(kw−1). For convenience, assume hout ≥ wout in thefollowing sections (a transpose as described in Section 4.1can be used if this is not the case).

We refer to input/output feature maps interchangeably withinput/output images. A pixel of a feature map is given byits row and column coordinates and includes all channelsat that location in the feature map. An output pixel is “pro-cessed” or “computed” (opposite “unprocessed”) if it hasbeen evaluated and stored in memory. We say an input pixelis “stale” (opposite “live”) if, during the direct convolutioncalculation, it is no longer a dependency of some unpro-

Page 3: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

3

… …

… …

𝑓𝑓𝑜𝑜𝑜𝑜𝑜𝑜 ≤ 𝑓𝑓𝑖𝑖𝑖𝑖

𝑓𝑓𝑜𝑜𝑜𝑜𝑜𝑜 > 𝑓𝑓𝑖𝑖𝑖𝑖

input pixel output pixel stale pixel kernel

0 3 6 9

1 2

4 5

10 11

features

height

width

Figure 2. Arrangement of pixels in memory (top) and consider-ations for where to place output activations based on how fincompares to fout.

cessed output pixel. We use the term “debt” or “cost” torefer to the accrued additional memory requirements on topof the memory required to store just the input feature map.The opposite of “debt” is “payout” or “payback,” which isthe memory freed when input pixels become stale.

3.2. Assumptions for Memory Optimality

Memory optimality will be proven for lossless direct con-volutions in which all input features are loaded in memory(not streamed1). We assume that an input pixel does notbecome stale until all its dependent output pixels have beenwritten to memory. This is in contrast to algorithms likethe Winograd (Lavin & Gray, 2016) and FFT transformsthat generate intermediate results that have sufficient in-formation to recover the output pixels, therefore allowinginput pixels to be deleted2. In our analyses, we only countmemory used to store activations (ignoring O(1) additionalmemory for, eg, loop variables).

3.3. Case: Same or Decreasing Channel Depth

Consider processing output pixels in row-major order. Thetop-left input pixel only has a single output pixel dependentbecause of valid-padding. Therefore, as soon as the top-leftoutput pixel is processed, the input pixel can be deleted.Since fout ≤ fin, the output pixel can be stored in thememory that the now-stale input pixel used to occupy. Asimilar argument holds as additional pixels are processedsince there will always be a top-left corner pixel after eachinput pixel removal.

Overall, an additional fout memory is required over the

1An interesting alternative to the methods of this paper is tocompute sub-feature maps of multiple convolution layers at a timein a pipeline fashion.

2Our lossless assumption and basic information theory impliesthat these methods can not improve on required memory.

memory used to store the input activations. The middlerow of Figure 2 shows how fout extra memory is initiallyrequired, but afterwards, the stale input is sufficient to storeoutput activations. While it is intuitive that this approachachieves optimal memory use, it is nonetheless instructive toanalyze, since this builds intuition necessary for Section 3.4.

Claim 1. The row-major traversal strategy is memory-optimal for direct convolution with same or decreasingchannel depth and restrictions described in Section 3.

Proof. For any method of computing the direct convolution,there will be some point in the procedure when exactlyone output pixel has been processed. At any point priorto this computation, all hin · win · fin activations muststay in memory, since computation dependencies are onlyremoved when all channels of an output pixel are computed.The memory required to store the channels of the outputpixel is fout. So no matter what method is used for directconvolution, an absolute minimum of hin ·win · fin + foutmemory must be available. Since the proposed algorithmachieves this lower bound, it is optimal.

3.4. Case: Increasing Channel Depth

When fout > fin, additional memory is required, sinceoutput pixels will not fit in the vacancy of the input pixelsas described in Section 3.3 and as seen in the bottom ofFigure 2. Three approaches to dealing with this issue arepresented here. In Section 3.4.1 a “replace” strategy thatfollows the row-major approach of Section 3.3 is described.In Section 3.4.2, a different computation order for outputpixels is described and proven to be memory-optimal. InSection 3.4.3, a less computationally-intensive algorithmthat is nonetheless near memory-optimal is described. Algo-rithmic implementation details are described in Section 4.

3.4.1. REPLACE STRATEGY

In the replace strategy, output pixels are computed inrow-major order. To analyze the memory requirementsof this strategy, we keep track of the memory debt ac-crued at each step. For example, to compute the firstoutput pixel, we accrue a debt of fout then delete theinput pixel, which pays back fin memory. For a givenrow, the sequence of debts and paybacks are L =[fout,−fin, fout,−fin, . . . , fout,−k ·fin], where there arewout copies of fout. Note the last pixel is unique and paysback k · fin. Thus, each row accrues debt D(wout) =wout(fout − fin)− (k − 1)fin, but the peak debt within arow is D(wout) + kfin. The total peak debt is:

Drp = (hout − 1)D(wout) +D(wout) + kfin

= hout (wout(fout − fin)− (k − 1)fin) + kfin(1)

Page 4: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

This replace method is not memory optimal. Note that aftereach output pixel of the bottom row is computed, k−1 inputpixels become stale, but this memory is not convenientlylaid out in memory and can not be directly used. Thisobservation motivates the “herringbone” strategy in the nextsection, which we prove to be memory-optimal.

3.4.2. HERRINGBONE STRATEGY

Intuitively, accrued debt can be minimized by prioritizingthe collection of large payouts near the edges of the im-age. In the replace strategy, the edges are only encounteredafter processing wout output pixels. However, after a suffi-cient number of rows have been processed, edges could bereached faster by processing a column of pixels rather thananother row of pixels.

4

25 cost; 20 free 30 cost; 32 free 55 cost; 60 free

0 1 2 3 4 5 6 7 8 15 16 17 18 19 20 21 9 22 28 29 30 31 32 33

10 23 34 39 40 41 42 43 11 24 35 44 48 49 50 51 12 25 36 45 52 55 56 57 13 26 37 46 53 58 60 61 14 27 38 47 54 59 62 63

Herringbone tile Order of Convolutions

Figure 3. Motivating concept for herringbone (top) and order ofpixel traversal (bottom left) with colors indicating rows andcolumns that are processed sequentially. The name comes fromthe herringbone tile (bottom right, image of floor tile from HomeDepot R©) which has the same row-column alternations.

The herringbone strategy proceeds iteratively on rowsor columns of the output feature map, greedily takingwhichever will accumulate the least debt. The result is analternating compute procedure of row-column-row-column,which resembles the herringbone tile pattern as seen in Fig-ure 3. Using this strategy, the amount of debt accrued foreach row and column decreases as the algorithm progresseson later iterations.

To analyze the memory use of this strategy, we employ thesame debt function D(x) = x(fout − fin) − (k − 1)finas in Section 3.4.1, giving the total debt accrued when pro-cessing a row or column of x output pixels. Followingthe herringbone method, the sequence of debts (positive ornegative) will be LD = [D(wout), D(hout − 1), D(wout −1), D(hout − 2), . . . , D(1), D(1)] for a square output fea-

ture map. If hout > wout, LD will contain hout −wout + 1copies of D(wout) at the beginning of the list. Therefore,the peak debt is:

Dhb = maxi

i∑j=1

LD(j) + kfin

where the additional kfin is due to the input memoryrequired to generate the last output pixel and the maxiis required since LD may eventually become negative.One interpretation of

∑ij=1 LD(j) is that it is simply

noutfout − ninfin where nout is the number of output pix-els that have been computed and nin is the number of stale(non-dependency) input pixels after processing those out-put pixels, provided we have just finished one of the rowsor columns. We can see this formula only depends on thenumber of processed input and output pixels.

Since LD is monotonically non-increasing, we can find themaximum prefix sum by finding when D(x) ≤ 0 ⇒ x ≤(k − 1)fin/(fout − fin) = x∗. This means that the worstcase memory will happen when the remaining output pixelsform a square of side length bx∗c. Therefore:

Dhb = noutfout − ninfin + kfin

= (houtwout − bx∗c2)fout− (hinwin − (bx∗c+ k − 1)2 − k)fin (2)

Claim 2. The herringbone strategy is memory-optimal fordirect convolution with increasing channel depth and re-strictions described in Section 3.

Proof. For any method of computing the direct convolution,there will be some point in the procedure when ncrit =(houtwout − bx∗c2) output pixels have been processed andno others have been processed. Just prior to this point,there are nunproc = bx∗c2 + 1 unprocessed output pixelsand therefore at least nlive = (bx∗c + k − 1)2 + k inputpixels are not stale by Lemma 3.1. Therefore, the minimumpossible memory deficit just before processing ncrit outputpixels is:

Dmin = noutfout + ninfin

= (houtwout − bx∗c2)fout − (hinwin − nlive)fin= Dhb

No matter what method is used for direct convolution, aminimum of Dmin = Dhb additional memory is required.Since the proposed algorithm achieves this lower bound, itis optimal.

Page 5: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

Lemma 3.1. The minimum number of input pixel depen-dencies for n2 + 1 output pixels and odd kernel size k is(n+ k − 1)2 + k.

Proof. Let B(p) be a function giving the input pixel depen-dencies for pixel p and B(P ) =

⋃p∈P

B(p). B(P ) gives

the set of pixels within Chebyshev distance (k − 1)/2 ofany pixel in P . We are interested in finding |B(S∗)|, whereS∗ = argminS |B(S)|, subject to |S| = n2 + 1.

Define a pixel p ∈ S at location (xp, yp) to be a “top-left cor-ner pixel” if pixel (xp, yp−1) ∈ S and (xp+1, yp) ∈ S andno pixels in S besides p have coordinates (x, y) satisfyingboth x ≤ xp and y ≥ yp. Define “top-right,” “bottom-left,”and “bottom-right” corner pixels analogously and say thatp is a “corner pixel” if it is any one of these four types ofcorner pixels (refer to Figure 4a for an illustration). Noticethat if p is a corner pixel in S, then |B(S−p)| = |B(S)|−1,since |B(p)−B(S)| = |B(p)− (B(p1)

⋃B(p2)) | = 1.

We assume that an optimal S∗ is connected and orthogonallyconvex3 (Fink & Wood, 1996). Suppose the tight boundingrectangle R of S∗ has dimensions r × c, rc ≥ n2 + 1. Wecan repeatedly remove corner pixels of this rectangle untilrc− (n2 + 1) corner pixels are removed to restore S∗ fromR. This can be seen by noting that S∗ has pixels on eachof the four edges of R, since R is tight, and S∗ must havea staircase boundary between adjacent pairs of these edgepixels (Nicholl et al., 1983). It is easy to see that these fourstaircases can be produced by repeated corner pixel removal,as seen in Figure 4b. Therefore,

B(S∗) = B(R)− (#removed corner pixels)

= (r + k − 1)(c+ k − 1)− (rc− (n2 + 1))

= n2 + (k − 1)2 + 1 + (k − 1)(r + c)

However, r+c ≥ r+(n2+1)/r ≥ 2√n2 + 1 > 2n. Since

r and c are integers, r + c ≥ 2n+ 1. Then,

B(S∗) ≥ n2 + (k − 1)2 + 1 + (k − 1)(2n+ 1)

= (n+ k − 1)2 + k

Optimality of the herringbone method requires a memory-efficient way to access the stale inputs. This is problematicwhen computing a column of pixels, as pointed out in Sec-tion 3.4.1. Two approaches can be used to solve this prob-lem: shifting and transposing, as summarized in Figure 5.

The first approach is to shift input pixels in memory everytime a later input pixel becomes stale to fill in the stale spot

3A proof of this fact is not too insightful and is provided in thesupplementary material.

9

𝑝𝑝 𝑝𝑝1 𝑝𝑝2

𝑏𝑏

7

27 26 24 25 21 22 23

16 15 18 17 20 19

33 32 31 30 29 28

1 2 3 11 10 4 5 6 14

9 8 13 12

𝐵𝐵 𝑆𝑆

𝐵𝐵 𝑝𝑝

𝐵𝐵 𝑝𝑝1

𝐵𝐵 𝑝𝑝2

a) 𝐵𝐵 𝑆𝑆 − 𝑝𝑝 = 𝐵𝐵 𝑆𝑆 − 1

𝑆𝑆∗ 𝑅𝑅

b) Remove corners from 𝑅𝑅 to get 𝑆𝑆∗

Figure 4. Example of a corner pixel p with k = 5 (a) and exampleof a sequence of corner pixel removals to get from R to S∗ (b).

8

Shift method: for columns, shift previous non-stale pixels to fill stale pixel

Transpose method: process a row, transpose, process a row, transpose, …

Figure 5. Shifting to claim fragmented stale pixels (top) and usingtransposes to never have fragmented stale pixels (bottom).

and open free memory at the front of the input activations.This algorithm takes O(houtwouthinwinfin).

The second approach is to perform an in-place transposewhen switching between row and column processing45.Because transposes only need to be performed betweenentire rows and columns, the computational complexityis reduced to O((hout + wout)Ttranspose(hin, win, fin)).In Section 4.1, an in-place transpose with complexityO(hinwin(c + fin)) is presented. Empirically, we findthat c is usually less than 5 for problem sizes of interest.

Both approaches leave the output in herringbone order. Sec-tion 4.2 discusses an efficient solution to return the featuremap to row-major order.

3.4.3. SINGLE TRANSPOSE STRATEGY

While the herringbone method is memory-optimal, it is com-putationally expensive because of the required memory ma-nipulations. We now demonstrate that a single well-placedtranspose can yield most (or sometimes all) of the memorybenefits, while significantly reducing computational load.The single transpose method uses standard row-major or-

4A transpose is equivalent to switching between row-major tocolumn-major storage in memory.

5The convolution kernel must be transposed as well.

Page 6: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

der for several rows as given in (4), then transposes theremaining input activations and processes the remainingrows (former columns) to completion.

Let r be the number of rows remaining after hout − rrows have already been processed (each processed rowadding wout(fout − fin) − (k − 1)fin debt, as analyzedin Section 3.4.1). Two cases need to be analyzed sepa-rately: either the remaining columns do not add debt, ifr(fout − fin) − (k − 1)fin ≤ 0, or they do. An anal-ysis similar to that of Section 3.4.2 shows that the op-timal row on which to perform the transpose is r∗1 =b(k − 1)fin/(fout − fin)c for case 1, or r∗2 = r∗1 + 1 forcase 2. The total debt is elegantly expressed in terms of theoptimal debt Dhb.

Dst = Dhb +min(woutα, (k − 1)fin)− r∗1α (3)

where α = (k − 1)fin mod (fout − fin). The first term inthe min function is from case 1 (r = r∗1) and the second isfrom case 2 (r = r∗1 + 1). This makes it clear that:

r∗ =

{r∗1 woutα ≤ (k − 1)fin

r∗1 + 1 else(4)

From (3), it can be seen that the single transpose methodis optimal when wout = r∗1 , (k − 1)fin = r∗1α, or α = 0.This last condition holds when (k − 1)fin divides fout −fin. Compared to the herringbone computation complexityof O((hout + wout)Ttranspose(hin, win, fin)), the singletranspose method is O(Ttranspose(r∗, win, fin)), a factorof approximately (hout + wout)hin/r

∗ times faster.

Figure 10 shows that over a range of randomly generatednetwork architectures, the herringbone method (blue dot)and the transpose method (red dot) have nearly identicalmemory requirements.

4. Implementation DetailsIn the herringbone strategy described in Section 3.4.2, theproof of optimality ignored memory requirements of per-forming transposes. Here, we present a memory-efficientin-place transpose. Using insights gained from this in-placetranspose, an inverse herringbone transform is also proposed,to allow efficient “unwrapping” of the output feature mapthat results from processing in herringbone order.

4.1. Memory-Efficient Transpose

The basic technique for in-place memory manipulations isto decompose the desired memory permutation (such as atranspose) into disjoint cycles, then rotate elements in each

of these cycles. To make this algorithm memory efficient, ituses a light-weight successor function mapping each mem-ory location i to another location j, indicating the memoryat location j should be moved to i. Recursive application ofthe successor function thus generates a cycle and the wholecycle can be rotated with one auxiliary memory cell formatrix element storage6.

All cycles can be rotated by iterating over all elements inmemory, to find starting positions, and only rotating cyclesthat have not yet been visited. Traditionally, extra memoryis used to keep track of the visited cycles (Windley, 1959;Laflin & Brebner, 1970). An alternative zero-memory-costway to ensure unique cycles is to only perform the rotationif the starting position is the minimum element in its cycle.This can be verified by running through the cycle oncewithout any data movement (Morini, 2017).

Finally we address how to compute the successor function.In Laflin & Brebner (1970); Morini (2017), it is given as:

f(i;h,w) = (i mod h) · w + bi/hc (5)

where i is the location in memory and h× w are the imagedimensions. To derive this result, we must determine whatindex j contains the memory needed at index i. Viewed fromthe transpose perspective, i = r ·h+ c is located at (c, r) =(i mod h, bi/hc). From the untransposed perspective, thisis (r, c) = (bi/hc, i mod h), which results in an index j =r · w + c = f(i;h,w), as in (5). Figure 6 illustrates thistechnique with a small example.

5

0 1 2 3 4 5 6 7 8 9 10 11

0 4 8 1 5 9 2 6 10 3 7 11

0 1 2 3 4 5 6 7 8 9 10 11

0 4 8 1 5 9 2 6 10 3 7 11

For each start: Check if start > any other element in its cycle If not, rotate elements in the cycle

Successor: 𝑗𝑗 = 𝑖𝑖 mod 𝐻𝐻 ⋅ 𝑊𝑊 + 𝑖𝑖/𝐻𝐻

mem layout A

mem layout B

Figure 6. Example for transposing a 3× 4 array in-place.

4.2. Memory-Efficient Inverse Herringbone

To invert the herringbone pattern of output pixels, we notethat we are simply trying to perform a particular permutationon the memory elements and therefore we can use an in-place permutation again, except with a different successorfunction. The herringbone pattern is only interesting for thew × w square at the end of the output activations, so werestrict our attention to this case.

6Or zero, if using the XOR swap trick.

Page 7: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

As before, we consider a “next” element with some un-permuted index whose memory needs to be moved to the“current” element (r, c) with some permuted index. The per-muted case is simply row-major form, so i = r · w + c andtherefore r = bi/wc and c = i mod w. For the unpermutedcase, refer to Figure 3. The indices of a given “shell” can bereferenced to the index w2 − n2, where n is the side-lengthof the square contained within the shell. Then, behavior canbe split between the upper and lower triangular regions forthe two halves of the shell: c ≥ r and c < r. When c ≥ r,the index is j = w2 − (w − r)2 + c− r. When c < r, theindex is j = w2 − (w− c− 1)2 − (w− c− 1) + r− c− 1.Simplifying, we get:

f(i;w) =

{r(2w − r − 1) + c c ≥ rc(2w − c− 2) + w + r − 1 else

(6)

5. Case StudyWe verify the feasibility of the herringbone method witha case study implementing an MNIST classifier on an Ar-duino, followed by a discussion of results.

5.1. MNIST on Arduino

11

Arduino

Program SRAM

serial comm.

Serialized CNN+ Input Images

Output Classes

SRAM (2048B)

NN workspace (1960B)

NN serialization (1525B)

NN activations (435B)

Append computed activations to end

Grow stale activations from front

28 × 28 × 1 17610

Avg

Po

ol2x2

Co

nv 3x3

Co

nv 3x3

Co

nv 3x3

Ma

xPo

ol2x2

Den

se

Flatten

611c1c0150318141b1532a27304888b8bc8e67062038e88784217b578e0efd047480558181f06fe8114475add415fe81d527ec42a3ead2c862d28f

eb482fc6d4e7edd1aea57f685f7d8948f6841c6b33258fc5711cd0707446d404138fb231989e9b70981b0183cc38412578774407764ea141cf9b18

a2e08e2e64de7562bf6d28b7df6eb38509483f11e91a3d001ca7db26e09d6088f7589c72715f1e7cf4c9d71f5685849580b016f2150e217812fb5d

60d6f5cf46420917c4a4797cd83fd2871a087f0183112871fa8784600ce27f8d1f8ed31c302ee7bbf07ea57ec7f8073e7e479577318389b88df838

1783282cef87d8e0838ff827f78cc1478e5be8d78bd8a79e86ed8742a1698872180d4c635470d03c1762e37c0da766287f8718e8c6889a89b88d0c

02080e4ddfa3f73ba3a4267c0fd14e7f825042c259f1e85798cf58f188583ca788442c828608e78488f608df88a888488580875380774bf08edc8e

7a908e8e72bd72e4218e74e448f39f1fd315c72948ece4f5eae8049d89fff871b722d83ac60e38d788791838867845a783f87287aec2df8082e7d1

8c80e41788cb8eafc2ab3f2872854ef1028cd717c078c1de2a2f708d58b648872fc331834ebca48772d1583f21d67871ec85b8074ee7dd83888b61

c78dfd70df88227788a8817b837887881f78b3801c837b77d88fce824478d08e79e07dc1e0877e8745d06d89d3738c548fdc88858318d1d7e72185

5d47630dc1889d788a458f378b7c9147ca788ff8093cfe88574877b8142707388cf898787a7c71383a8fae08974c0078fc756f88d7628e288dd18f

0d88330f8b76213289a2c08880d7273271f27e87d8e7b77a8f80b9888ffa88811877f0b867f1b4f04bd48f87f88e96418778877881888772f74400

4a4b87574db264736063827118387031d32ddc312808f7c87f8f75073837887757a7848c8a1a77e88e84f7768668c278881cd770d3663f3f7c8703

be8e423cf14f8683f87b63418370286340f327d86cdee423ec0422473b8c50307e37c9817e805557b54106788c741f788d07c1d17217e7ae8d623f

e24ff48ed87f323081303e40421633c84143d76f882577472e8e3f1f2175088678a85271e493f67d8f4668708fe7728d788782f387773788274288

d870d2e48ceb7753f3144f8e524385508f1777c2e88fdcbe21318893f78ae677877d8178e83f8537255f1382b88312323154313d450652b7c87418

073c187e888b437878888e8fb88782783c52d2b88de2771023820746e561125c08313237488e4282608346e21d42231d3444a2ef23321887600f51

e687a1fcf48c8cdbe887157300df41ffd0f1df827f8f1104e3f2157e1f643f8beee7b80155e435011151001c1e12ee1f4223ece1f342ee1c27fb0e

f8f5e2221e031751032e611f1c1480b448b5775155b5842c804538d708773f24308788d0078fb10240def3117e05227d09648373133d572e55a11d

0402467e01677017212083874782c6f68578f7774853085712187404ee8114d24f38222a02278287f2a4487661787f188b787888288880cc87c708

72d77417778bf39c87861747857ef3342d625e071814718270ef7613083c5618437be61412c2eb234c4d4e0ec13c7d0a1822637f853473b302e30e

d20e00af2e2511f4c3d0c44231213473f1c1095252032041110125182f3cb4e30333d07aebdb9ed47748758df4dd7b53e52e40f21ee343df10f4bd

e0271582f7e18c4d2432fb62b7186357f787f06f2788171f101cf7858e5e8487083283b8ed6a77e2d2884843d3d983e6dede578ef8b7a8e78608f1

8788f887c82e28d07768683571c5d1722a18645f717532667582482c7f78890c887878882188e332a7c73d8fd7c1852418328797c7f81587880157

5f7278272e381bb17ed1bd4e4848754e7e72230313811e705d7c8d478f38488878da7e5b82b075e5816665012826c781f7ece383c80335202e373f

20250d323c003f5e68086738787135d2c22f817af8ee80db08787f81818b4853872837f78d7377e12857b781d78f83880e607832e2e72f32173044

8f4d3f5c38876768137c77e7e158ff9708df8e88237d7287b788385787c88387f8dc77817b67878427f8080d1a47f1aca2e0

Net

wo

rk T

op

olo

gy

Wei

gh

ts a

nd

Bia

ses

Stack (88B)

Figure 7. Overview of implemented Arduino system and our CNNarchitecture. SRAM is split into the network serialization, networkactivations, and program stack. New layers are built at the frontof activations memory (light blue arrow), while current layers aremade stale at the back (green arrow).

Figure 7 shows an overview of the hardware setup. A singleArduino based on the ATmega328P chip is employed forthe classification task. Network parameters and imagesare streamed in through serial communications, then theArduino runs its CNN and returns the output class via serial.

A network architecture search is performed to find the bestquantized network by validation performance. Figure 8shows a random sample of these networks and their floatversus quantized performance. After this search, hand tun-ing is used to optimize the architecture to the one shown inFigure 7. The network is trained in Keras/TensorFlow with

Table 1. Results Summary.

RESULT VALUE

MEMORY 434.5 B (ACT) / 1512.5 B (WTS)TOTAL, SERIALIZED 1960 BPROGRAM SIZE 6514 BINFERENCE TIME 684 MS (NOT OPTIMIZED)ACCURACY 99.11% (DEV) / 99.15% (TEST)

Adam (Abadi et al., 2015; Chollet et al., 2015; Kingma &Ba, 2014) for 50 epochs in floating point and 200 epochswith 4-bit quantized training using the straight-through esti-mator and ALT training (Courbariaux et al., 2016; Jain et al.,2019). Additional techniques used to maximize classifica-tion accuracy can be found in the supplemental material.

The CNN is then implemented in hardware. Verificationis performed both for intermediate activations in a singletest image and for the 16-bit output logits for all 10,000test images to ensure a 100% match. A summary of theresults is provided in Table 2. In Figure 1, the benefits ofnon-naive methods are made clear. For our network, thesingle transpose method only costs an additional 3B beyondherringbone. However, when including peak stack usage weonly have 2B spare, necessitating the use of herringbone.

5.2. Discussion

One might wonder whether the techniques described in thispaper are practically useful. We claim that first, the replacemethod described in Sections 3.3 and 3.4.1 is a generallyuseful technique that can be applied to any convolutionallayer. Second, the herringbone and single-transpose tech-niques from Sections 3.4.2 and 3.4.3 are useful for 2D or 3Dvalid-padded CNNs in which (a) channel depth increases,(b) kernel size is greater than 1, and (c) kernel size is not toosmall compared to feature map width and height. Figure 8shows that the models near the Pareto frontier tend to haveincreasing channel depth and 3 × 3 kernels, satisfying (a)and (b). Meanwhile, our limitation to small devices virtu-ally guarantees that (c) holds. More directly, the bottomleft plot of Figure 8 shows that models at the Pareto frontierare disproportionately likely to benefit from the herringbonemethod.

Figure 10 shows the error versus activation memory require-ment across the different convolution computation strategiesdiscussed in Section 3.4. The difference between the naivemethod and all other methods is substantial and can be qual-itatively seen to affect performance. One way to get a morequantitative sense of the expected impact of a decrease inmemory efficiency is to look at the slope of the Pareto fron-tier of this curve. Below 1KB, the validation error appearsto rise 10x for every 10x decrease in activation memory(cyan line). In other words, there is a constant (memory

Page 8: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Floating Point - Quantized Accuracy CorrespondenceFP32Int4

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion Depthwise Separable Convolutions

0.0

0.2

0.4

0.6

0.8

1.0

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion Increasing Channel Depth

0.0

0.2

0.4

0.6

0.8

1.0

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion 3x3 Kernels

0.0

0.2

0.4

0.6

0.8

1.0

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Percent Herringbone Activation Memory Improvement

0

2

4

6

8

10

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion Fully-Connected Layers

0.0

0.2

0.4

0.6

0.8

1.0

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion 1x1 Kernels

0.0

0.2

0.4

0.6

0.8

1.0

103 104 105

Weights + Activations Memory (Bytes)10−2

10−1

Valid

atio

n Er

ror

Proportion 5x5 Kernels

0.0

0.2

0.4

0.6

0.8

1.0

Figure 8. Pareto curves for 1000 randomly selected architectures examining the impact of different architecture features. Models aretrained for 5 epochs with floating point weights/activations (red dots), then 5 epochs with quantized weights/activations (blue dots).

100 101 102 103 104 105

Memory Footprint (KB)

10−2

10−1

Test

Erro

r

This Work

MNIST-10 CNNMNIST-10 BonsaiMNIST-10 GBDTMNIST-10 kNNMNIST-10 RBF-SVMMNIST-10 NeuralNetMNIST-10 ProtoNNMNIST-10 SNCMNIST-10 BNCMNIST-10 RNNMNIST-10 FastRNNMNIST-10 FastRNN-LSQMNIST-10 FastGRNN

MNIST-10 SpectralRNNMNIST-10 EURNNMNIST-10 oRNNMNIST-10 FactoredRNNMNIST-10 UGRNNMNIST-10 GRUMNIST-10 LSTMMNIST-2 BonsaiOptMNIST-2 BonsaiMNIST-2 LinearMNIST-2 LDKLMNIST-2 NeuralNet PrunedMNIST-2 Cloud GBDT

MNIST-2 BonsaiMNIST-2 GBDTMNIST-2 kNNMNIST-2 RBF-SVMMNIST-2 NeuralNetMNIST-2 ProtoNNMNIST-2 ProtoNNMNIST-2 ProtoNN (Opt)MNIST-2 SNCMNIST-2 BNCMNIST-2 LDKL-L1MNIST-2 NN-PruningMNIST-2 Logistic-L1

Figure 9. Comparison of our 2KB CNN classifier to results fromKumar et al. (2017); Gupta et al. (2017); Kusupati et al. (2018).

× error) product in this regime. Since the naive methodhas roughly twice the memory use of herringbone (see Fig-ure 1), it may be expected to have twice the error for a givenmemory constraint. The improvements between the replacemethod and herringbone are more modest, but appear tobe more pronounced for higher-achieving models. So, theycould still be predicted to affect performance on average by≈ 10% relative error.

A Pareto frontier can also be seen in Figure 8. Of partic-ular interest is the existence of a soft knee around 2KB,where extra memory has diminishing returns. This couldexplain why we achieved such a high accuracy comparedto related work in Figure 9 — 2KB is close to the cliff ofaccuracy degradation, meaning even small memory-use non-optimalities can have a large impact. In contrast to our work,the related works typically take a more balanced approach tothe memory-compute trade-off. For the 2KB environment,we may surmise MNIST is an approximate lower bound onproblem complexity where our methods would boost accu-racy. However, even for simpler classification problems, ourmethods could still free memory for other processes.

6. ConclusionIn this paper, we analyzed the minimum memory requiredto run CNN inference so that we could maximize classifica-

103

Activations Memory (Bytes)10−2

10−1Va

lidat

ion

Erro

r

NaiveReplaceTransposeHerringbone

Figure 10. Comparing activation weight storage (4-bit) betweenfour different convolution strategies as described in Section 3across a range of randomly-generated network architectures. Thedotted cyan line gives a rough position for the Pareto frontier.

tion accuracy on memory-constrained devices. For a givenconvolution layer, when channel depth increases, we sawthat the herringbone method was optimal and showed thatit can be implemented with in-place memory permutations.We used this optimality to show that a single well-placedtranspose was nearly or exactly optimal and additionallybenefited from a significant reduction in computational com-plexity.

We then demonstrated these techniques on an Arduinofor MNIST classification and achieved a test accuracy of99.15%, which is state-of-the-art for models with compa-rable memory constraints. This demonstrates the effective-ness of CNN classification even on small embedded de-vices. While our focus application was narrow, the replacetechnique applies to all CNNs and the herringbone/single-transpose techniques apply to many CNNs. MNIST classifi-cation in itself may not be all that attractive, but CNNs inconjunction with spectrograms of time-series sensor datacould enable a suite of KB-level smart device applications.

Page 9: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

AcknowledgementsWe thank Daniel Bankman, Alex Chen, Elaina Chai, DanVillamizar, Lita Yang, Ernest So, Bryan He, Peter Cuy,Saketh Are, Scott Wu, Hoa Gural, and Kenneth Gural forhelpful comments and advice. Albert Gural is supportedby a National Science Foundation Graduate Research Fel-lowship and by Analog Devices via the Stanford SystemXFellow Mentor Advisor (FMA) program.

ReferencesAbadi, M., Agarwal, A., Barham, P., Brevdo, E., Chen, Z.,

Citro, C., Corrado, G. S., Davis, A., Dean, J., Devin, M.,Ghemawat, S., Goodfellow, I., Harp, A., Irving, G., Is-ard, M., Jia, Y., Jozefowicz, R., Kaiser, L., Kudlur, M.,Levenberg, J., Mane, D., Monga, R., Moore, S., Mur-ray, D., Olah, C., Schuster, M., Shlens, J., Steiner, B.,Sutskever, I., Talwar, K., Tucker, P., Vanhoucke, V., Va-sudevan, V., Viegas, F., Vinyals, O., Warden, P., Watten-berg, M., Wicke, M., Yu, Y., and Zheng, X. TensorFlow:Large-scale machine learning on heterogeneous systems,2015. URL http://tensorflow.org/. Softwareavailable from tensorflow.org.

Allen, J. Short term spectral analysis, synthesis, and modifi-cation by discrete fourier transform. IEEE Transactionson Acoustics, Speech, and Signal Processing, 25(3):235–238, 1977.

Chellapilla, K., Puri, S., and Simard, P. High performanceconvolutional neural networks for document processing.In Tenth International Workshop on Frontiers in Hand-writing Recognition. Suvisoft, 2006.

Chetlur, S., Woolley, C., Vandermersch, P., Cohen, J.,Tran, J., Catanzaro, B., and Shelhamer, E. cudnn:Efficient primitives for deep learning. arXiv preprintarXiv:1410.0759, 2014.

Cho, M. and Brand, D. Mec: memory-efficient convolutionfor deep neural network. In Proceedings of the 34thInternational Conference on Machine Learning-Volume70, pp. 815–824. JMLR. org, 2017.

Chollet, F. et al. Keras. https://github.com/fchollet/keras, 2015.

Cooley, J. W. and Tukey, J. W. An algorithm for the machinecalculation of complex fourier series. Mathematics ofcomputation, 19(90):297–301, 1965.

Courbariaux, M., Hubara, I., Soudry, D., El-Yaniv, R., andBengio, Y. Binarized neural networks: Training deepneural networks with weights and activations constrainedto+ 1 or-1. arXiv preprint arXiv:1602.02830, 2016.

Fayek, H. M. Speech processing for machinelearning: Filter banks, mel-frequency cepstralcoefficients (mfccs) and what’s in-between.https://haythamfayek.com/2016/04/21/speech-processing-for-machine-learning.html, 2016. Accessed: 2019-01-10.

Fink, E. and Wood, D. Fundamentals of restricted-orientation convexity. Information Sciences, 92(1):175 – 196, 1996. ISSN 0020-0255. doi:https://doi.org/10.1016/0020-0255(96)00056-4. URLhttp://www.sciencedirect.com/science/article/pii/0020025596000564.

Gupta, C., Suggala, A. S., Goyal, A., Simhadri, H. V., Paran-jape, B., Kumar, A., Goyal, S., Udupa, R., Varma, M.,and Jain, P. Protonn: compressed and accurate knn forresource-scarce devices. In International Conference onMachine Learning, pp. 1331–1340, 2017.

Hasan, M. R., Jamil, M., Rahman, M., et al. Speaker identi-fication using mel frequency cepstral coefficients. varia-tions, 1(4), 2004a.

Hasan, M. R., Jamil, M., Rahman, M., et al. Speaker identi-fication using mel frequency cepstral coefficients. varia-tions, 1(4), 2004b.

He, K., Zhang, X., Ren, S., and Sun, J. Deep residual learn-ing for image recognition. CoRR, abs/1512.03385, 2015.URL http://arxiv.org/abs/1512.03385.

Hershey, S., Chaudhuri, S., Ellis, D. P. W., Gemmeke,J. F., Jansen, A., Moore, R. C., Plakal, M., Platt, D.,Saurous, R. A., Seybold, B., Slaney, M., Weiss, R. J.,and Wilson, K. W. CNN architectures for large-scaleaudio classification. CoRR, abs/1609.09430, 2016. URLhttp://arxiv.org/abs/1609.09430.

Howard, A. G., Zhu, M., Chen, B., Kalenichenko, D., Wang,W., Weyand, T., Andreetto, M., and Adam, H. Mobilenets:Efficient convolutional neural networks for mobile visionapplications. CoRR, abs/1704.04861, 2017. URL http://arxiv.org/abs/1704.04861.

Jain, S. R., Gural, A., Wu, M., and Dick, C. Trained uniformquantization for accurate and efficient neural networkinference on fixed-point hardware, 2019.

Jose, C., Goyal, P., Aggrwal, P., and Varma, M. Local deepkernel learning for efficient non-linear svm prediction. InInternational conference on machine learning, pp. 486–494, 2013.

Kingma, D. P. and Ba, J. Adam: A method for stochasticoptimization. arXiv preprint arXiv:1412.6980, 2014.

Page 10: Memory-Optimal Direct Convolutions for Maximizing ...proceedings.mlr.press/v97/gural19a/gural19a.pdf · (CNNs), together with spectrogram preprocessing, are a natural solution to

Memory-Optimal Direct Convolutions

Krizhevsky, A., Sutskever, I., and Hinton, G. E. Imagenetclassification with deep convolutional neural networks.In Advances in neural information processing systems,pp. 1097–1105, 2012.

Kumar, A., Goyal, S., and Varma, M. Resource-efficientmachine learning in 2 kb ram for the internet of things.In International Conference on Machine Learning, pp.1935–1944, 2017.

Kusupati, A., Singh, M., Bhatia, K., Kumar, A., Jain, P.,and Varma, M. Fastgrnn: A fast, accurate, stable andtiny kilobyte sized gated recurrent neural network. InAdvances in Neural Information Processing Systems, pp.9031–9042, 2018.

Laflin, S. and Brebner, M. A. Algorithm 380: In-situtransposition of a rectangular matrix [f1]. Commun.ACM, 13(5):324–326, May 1970. ISSN 0001-0782.doi: 10.1145/362349.362368. URL http://doi.acm.org/10.1145/362349.362368.

Lavin, A. and Gray, S. Fast algorithms for convolutionalneural networks. In Proceedings of the IEEE Conferenceon Computer Vision and Pattern Recognition, pp. 4013–4021, 2016.

LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-based learning applied to document recognition. Proceed-ings of the IEEE, 86(11):2278–2324, 1998.

Morini, M. Transpose a matrix without a buffer-ing one. Software Engineering, May 2017.URL https://softwareengineering.stackexchange.com/a/271722. Version:2017-05-23.

Nicholl, T. M., Lee, D.-T., Liao, Y.-Z., and Wong, C.-K. Onthe xy convex hull of a set of xy polygons. BIT NumericalMathematics, 23(4):456–471, 1983.

Saxe, A. M., McClelland, J. L., and Ganguli, S. Exactsolutions to the nonlinear dynamics of learning in deeplinear neural networks. CoRR, abs/1312.6120, 2013. URLhttp://arxiv.org/abs/1312.6120.

Simard, P. Y., Steinkraus, D., and Platt, J. C. Best prac-tices for convolutional neural networks applied to visualdocument analysis. In null, pp. 958. IEEE, 2003.

Simonyan, K. and Zisserman, A. Very deep convolu-tional networks for large-scale image recognition. CoRR,abs/1409.1556, 2014. URL http://arxiv.org/abs/1409.1556.

Vasilache, N., Johnson, J., Mathieu, M., Chintala, S., Pi-antino, S., and LeCun, Y. Fast convolutional nets withfbfft: A gpu performance evaluation. arXiv preprintarXiv:1412.7580, 2014.

Warden, P. Speech commands: A dataset for limited-vocabulary speech recognition. CoRR, abs/1804.03209,2018. URL http://arxiv.org/abs/1804.03209.

Windley, P. F. Transposing matrices in a digital com-puter. The Computer Journal, 2(1):47–48, 1959. doi:10.1093/comjnl/2.1.47. URL http://dx.doi.org/10.1093/comjnl/2.1.47.

Zhang, J., Franchetti, F., and Low, T. M. High perfor-mance zero-memory overhead direct convolutions. arXivpreprint arXiv:1809.10170, 2018.


Recommended