Optimize DNN Accelerators with Dataflow
Optimize DNN Accelerators with Dataflow
THE AUTHORS DEMONSTRATE THE KEY ROLE DATAFLOWS PLAY IN OPTIMIZING ENERGY
EFFICIENCY FOR DEEP NEURAL NETWORK (DNN) ACCELERATORS. THEY INTRODUCE BOTH A
Technology
Joel Emer ...... Recent breakthroughs in deep
neural networks (DNNs) are leading to an
use high parallelism to achieve high process-
ing throughput. However, this processing
industrial revolution based on AI. The super- also requires a significant amount of data
Nvidia and Massachusetts ior accuracy of DNNs, however, comes at movement: each MAC performs three reads
the cost of high computational complexity. and one write of data access. Because moving
Institute of Technology General-purpose processors no longer deliver data can consume more energy than the
sufficient processing throughput and energy computation itself,1 optimizing data move-
Vivienne Sze efficiency for DNNs. As a result, demands ment becomes key to achieving high energy
for dedicated DNN accelerators are increas- efficiency.
Massachusetts Institute of ing in order to support the rapidly growing Data movement can be optimized by
use of AI. exploiting data reuse in a multilevel storage
Technology The processing of a DNN mainly com- hierarchy. By maximizing the reuse of data in
prises multiply-and-accumulate (MAC) oper- the lower-energy-cost storage levels (such as
ations (see Figure 1). Most of these MACs are local scratchpads), thus reducing data accesses
performed in the DNN’s convolutional to the higher-energy-cost levels (such as
layers, in which multichannel filters are con- DRAM), the overall data movement energy
volved with multichannel input feature maps consumption is minimized.
(ifmaps, such as images). This generates par- In fact, DNNs present many data reuse
tial sums (psums) that are further accumu- opportunities. First, there are three types
lated into multichannel output feature maps of input data reuse: filter reuse, wherein
(ofmaps). Because the MAC operations have each filter weight is reused across multiple
few data dependencies, DNN accelerators can ifmaps; ifmap reuse, wherein each ifmap
.......................................................
MAY/JUNE 2017 13
..............................................................................................................................................................................................
TOP PICKS
14 IEEE MICRO
Evaluating Energy Consumption
Finding the optimal mapping requires evalu- CPU iFIFO/oFIFO PE array
Accelerator chip
ation of the energy consumption for various GPU
mapping options. In this article, we evaluate Off-chip
energy consumption based on a spatial archi- DRAM
tecture,2 because many of the previous Global
buffer
designs can be thought of as instances of such
an architecture. The spatial architecture (see
Figure 3) consists of an array of PEs and a iFIFO/oFIFO PE array
multilevel storage hierarchy. The PE array (zoom in)
provides high parallelism for high through-
put, whereas the storage hierarchy can be RF RF RF
pFIFO
pFIFO
pFIFO
used to exploit data reuse in a four-level setup
(in decreasing energy-cost order): DRAM,
global buffer, network-on-chip (NoC, for
inter-PE communication), and register file
(RF) in the PE as local scratchpads.
Figure 3. Spatial array architecture comprises an array of processing
In this architecture, we assume all data
elements (PEs) and a multilevel storage hierarchy, including the off-chip
types can be stored and accessed at any level
DRAM, global buffer, network-on-chip (NoC), and register file (RF) in the PE.
of the storage hierarchy. Input data for the
The off-chip DRAM, global buffer, and PEs in the array can communicate
MAC operations—that is, filter weights and
with each other directly through the input and output FIFOs (the iFIFO and
ifmap pixels—are moved from the most
oFIFO). Within each PE, the PE FIFO (pFIFO) controls the traffic going in and
expensive level (DRAM) to the lower-cost
out of the arithmetic logic unit (ALU), including from the RF or other storage
levels. Ultimately, they are usually delivered
levels.
from the least expensive level (RF) to the
arithmetic logic unit (ALU) for computation.
The results from the ALU—that is, psums—
generally move in the opposite direction. Normalized energy cost
The orchestration of this movement is deter-
mined by the mappings for a specific DNN Computation 1 MAC at ALU 1× (Reference)
shape and size under the mapping rule con- RF (0.5 to 1.0 Kbytes) 1×
straints of a specific dataflow architecture.
Given a specific mapping, the system NoC (1 to 2 mm) 2×
Data access
energy consumption is estimated by account- Global buffer
6×
(>100 Kbytes)
ing for the number of times each data value
DRAM 200×
from all data types (ifmaps, filters, psums) is
reused at each level of the four-level memory
hierarchy, and weighing it with the energy Figure 4. Normalized energy cost relative to the computation of one MAC
cost of accessing that specific storage level. operation at ALU. Numbers are extracted from a commercial 65-nm
Figure 4 shows the normalized energy con- process.
sumption of accessing data from each storage
level relative to the computation of a MAC at each PE can hold only one ifmap pixel at a
the ALU. We extracted these numbers from a time. The mapping first reads an ifmap pixel
commercial 65-nm process and used them in from DRAM to the global buffer, then from
our final experiments. the global buffer to the RF of each PE
Figure 5 uses a toy example to show how a through the NoC, and reuses it from the RF
mapping determines the data reuse at each for four MACs consecutively in each PE. The
storage level, and thus the energy consump- mapping then switches to MACs that use
tion, in a three-PE setup. In this example, we other ifmap pixels, so the original one in the
have the following assumptions: each ifmap RF is replaced by new ones, due to limited
pixel is used by 24 MACs, all ifmap pixels capacity. Therefore, the original ifmap pixel
can fit into the global buffer, and the RF of must be fetched from the global buffer again
.............................................................
MAY/JUNE 2017 15
..............................................................................................................................................................................................
TOP PICKS
pFIFO
pFIFO
pFIFO
Global flow keeps filter weights stationary in
buffer each PE’s RF by enforcing the follow-
ing mapping rule: all MACs that use
Memory level
Buffer level the same filter weight must be
NoC level mapped on the same PE for process-
ing serially. This maximizes the con-
RF level volutional and filter reuse of weights
Ifmap pixel in the RF, thus minimizing the
data movement Processing other data . . .
energy consumption of accessing
weights (for example, work by Srimat
Chakradhar and colleagues6 and
time
Vinayak Gokhale and colleagues7).
Figure 6a shows the data movement
of a common WS dataflow imple-
Figure 5. Example of how a mapping determines data reuse at each storage mentation. While each weight stays
level. This example shows the data movement of one ifmap pixel going in the RF of each PE, the ifmap pixels
through the storage hierarchy. Each arrow means moving data between are broadcast to all PEs, and the gen-
specific levels (or to an ALU for computation). erated psums are then accumulated
spatially across PEs.
The Output-Stationary (OS) data-
when the mapping switches back to the
MACs that use it. In this case, the same flow keeps psums stationary by accu-
ifmap pixel is reused at the DRAM, global mulating them locally in the RF. The
buffer, NoC, and RF for 1, 2, 6, and 24 mapping rule is that all MACs that
times, respectively. The corresponding nor- generate psums for the same ofmap
malized energy consumption of moving this pixel must be mapped on the same
ifmap pixel is obtained by weighing these PE serially. This maximizes psum
numbers with the normalized energy num- reuse in the RF, thus minimizing
bers in Figure 4 and then adding them energy consumption of psum move-
together (that is, 1 200 þ 2 6 þ 6 2 ment (for example, work by Zidong
þ 24 1 ¼ 248). For other data types, the Du and colleagues,8 Suyog Gupta
same approach can be applied. and colleagues,9 and Maurice Pee-
This analysis framework can be used not men and colleagues10). The data
only to find the optimal mapping for a spe- movement of a common OS dataflow
cific dataflow, but also to evaluate and com- implementation is to broadcast filter
pare the energy consumption of different weights while passing ifmap pixels
dataflows. In the next section, we will spatially across the PE array (see
describe various existing dataflows. Figure 6b).
Unlike the previous two dataflows,
which keep a certain data type sta-
A Taxonomy of Existing DNN Dataflows tionary, the No-Local-Reuse (NLR)
Numerous previous efforts have proposed dataflow keeps no data stationary
solutions for DNN acceleration. These locally so it can trade the RF off for a
designs reflect a variety of trade-offs between larger global buffer. This is to mini-
performance and implementation complex- mize DRAM access energy consump-
ity. Despite their differences in low-level tion by storing more data on-chip
implementation details, we find that many of (for example, work by Tianshi Chen
them can be described as embodying a set of and colleagues11 and Chen Zhang
rules—that is, a dataflow—that defines the and colleagues12). The corresponding
............................................................
16 IEEE MICRO
mapping rule is that at each process-
ing cycle, all parallel MACs must Ifmap pixel (l) Filter weight (W) Psum (P)
come from a unique pair of filter and Weight-Stationary (WS) dataflow
channel. The data movement of the
Global buffer
NLR dataflow is to single-cast weights,
P8 I8 P0
multicast ifmap pixels, and spatially
accumulate psums across the PE array
(see Figure 6c). W0 P7 W1 P6 W2 P5 W3 P4 W4 P3 W5 P2 W6 P1 W7 PE
MAY/JUNE 2017 17
..............................................................................................................................................................................................
TOP PICKS
Dataflow Comparison
Figure 8. Patterns of how row primitives from the same 2D plane are In this section, we quantitatively compare the
mapped onto the PE array in the RS dataflow. energy efficiency of different DNN dataflows
in a spatial architecture, including those from
the taxonomy and the proposed RS dataflow.
further accumulated across PEs We use AlexNet5 as the benchmarking DNN
vertically. because it is one of the most popular DNNs
2. Another spatial mapping option available, and it comprises five convolutional
arises when the size of the PE array is (CONV) layers and three fully connected
large, and the pattern shown in (FC) layers with a wide variety of shapes and
Figure 8 can be spatially duplicated sizes, which can more thoroughly evaluate
across the PE array for various 2D the optimal mappings from each dataflow.
convolutions. This not only increases In order to have a fair comparison, we
utilization of PEs, but also further apply the following two constraints for all
exploits filter, ifmap, and psum reuse dataflows. First, the size of the PE array is
opportunities in the NoC. fixed at 256 for constant processing through-
3. One temporal mapping option arises put across dataflows. Second, the total hard-
when row primitives from different ware area is also fixed. For example, because
2D planes can be concatenated or the NLR dataflow does not use an RF, it can
interleaved on the same PE. As Figure allocate more area for the global buffer. The
9 shows, primitives with different corresponding hardware resource parameters
ifmaps, filters, and channels have filter are based on the RS dataflow implementation
reuse, ifmap reuse, and psum reuse in Eyeriss, a DNN accelerator chip fabricated
opportunities, respectively. By concat- in 65-nm CMOS.4 By applying these con-
enating or interleaving their computa- straints, we fix the total cost to implement
tion together in a PE, it virtually the microarchitecture of each dataflow.
............................................................
18 IEEE MICRO
Filter 1 Ifmap 1 Psum 1
Channel 1 Row 1 ∗ Row 1 = Row 1 Filter 1 Ifmap 1 and 2 Psum 1 and 2
Figure 9. Row primitives from different 2D planes can be combined by concatenating or interleaving their computation on the
same PE to further exploit data reuse at the RF level. (a) Two-row primitives reuse the same filter row for different ifmap
rows. (b) Two-row primitives reuse the same ifmap row for different filter rows. (c) Two-row primitives from different
channels further accumulate psum rows.
Therefore, the differences in energy efficiency DRAM alone does not dictate energy effi-
are solely from the dataflows. ciency, and optimizing the energy consump-
Figures 10a and 10b show the comparison tion for only a certain data type does not lead
of energy efficiency between dataflows in the to the best system energy efficiency. Overall,
CONV layers of AlexNet with an ifmap batch the RS dataflow is 1.4 to 2.5 times more
size of 16. Figure 10a gives the breakdown in energy efficient than other dataflows in the
terms of storage levels and ALU, and Figure CONV layers of AlexNet.
10b gives the breakdown in terms of data Figure 11 shows the same experiment
types. First, the ALU energy consumption is results as in Figure 10b, except that it is for
only a small fraction of the total energy con- the FC layers of AlexNet. Compared to the
sumption, which proves the importance of CONV layers, the FC layers have no convo-
data movement optimization. Second, even lutional reuse and use much more filter
though NLR has the lowest energy consump- weights. Still, the RS dataflow is at least 1.3
tion in DRAM, its total energy consumption times more energy efficient than the other
is still high, because most of the data accesses dataflows, which proves that the capability to
come from the global buffer, which are more optimize data movement for all data types is
expensive than those from the NoC or RF. the key to achieving the highest overall
Third, although WS and OS dataflows clearly energy efficiency. Note that the FC layers
optimize the energy consumption of accessing account for less than 20 percent of the total
weights and psums, respectively, they sacrifice energy consumption in AlexNet. In recent
the energy consumption of moving other data DNNs, the number of FC layers have also
types, and therefore do not achieve the lowest been greatly reduced, making their energy
overall energy consumption. This shows that consumption even less significant.
.............................................................
MAY/JUNE 2017 19
..............................................................................................................................................................................................
TOP PICKS
2.0 2.0
Normalized energy/MAC
Normalized energy/MAC
1.5 RF 1.5
NoC psums
1.0 Buffer 1.0 weights
DRAM pixels
0.5 ALU 0.5
0 0
WS OSA OSB OSC NLR RS WS OSA OSB OSC NLR RS
(a) DNN dataflows (b) DNN dataflows
Figure 10. Comparison of energy efficiency between different dataflows in the convolutional (CONV) layers of AlexNet.5 (a)
Breakdown in terms of storage levels and ALU versus (b) data types. OSA, OSB, and OSC are three variants of the OS dataflow
that are commonly seen in different implementations.3
2.0
tions are how to choose a combination of
1.5
psums
dataflows that maximally benefit the search
weights
for optimal mappings, and how to support
1.0 these dataflows with the minimum amount of
pixels
hardware implementation overhead.
0.5
This article has also pointed out how the
0
concept of DNN dataflows and the mapping
WS OSA OSB OSC NLR RS of a DNN computation onto a dataflow can be
DNN dataflows viewed as analogous to a general-purpose pro-
cessor’s architecture and compiling onto that
Figure 11. Comparison of energy efficiency between different dataflows in architecture. We hope this will open up space
the fully connected (FC) layers of AlexNet. for computer architects to approach the design
of DNN accelerators by applying the knowl-
edge and techniques from a well-established
20 IEEE MICRO
generated mappings. This is an endeavor we 11. T. Chen et al., “DianNao: A Small-Footprint
will leave for future work. MICRO High-Throughput Accelerator for Ubiquitous
Machine-Learning,” Proc. 19th Int’l Conf.
.................................................................... Architectural Support for Programming Lan-
References guages and Operating Systems (ASPLOS
1. M. Horowitz, “Computing’s Energy Prob- 14), 2014, pp. 269–284.
lem (And What We Can Do About It),” Proc. 12. C. Zhang et al., “Optimizing FPGA-based
IEEE Int’l Solid-State Circuits Conf. (ISSCC Accelerator Design for Deep Convolutional
14), 2014, pp. 10–14. Neural Networks,” Proc. ACM/SIGDA Int’l
2. A. Parashar et al., “Triggered Instructions: A Symp. Field-Programmable Gate Arrays
Control Paradigm for Spatially-Programmed (FPGA 15), 2015, pp. 161–170.
Architectures,” Proc. 40th Ann. Int’l Symp.
Computer Architecture (ISCA 13), 2013, pp. Yu-Hsin Chen is a PhD student in the
142–153. Department of Electrical Engineering and
3. Y.-H. Chen, J. Emer, and V. Sze, “Eyeriss: A Computer Science at the Massachusetts
Spatial Architecture for Energy-Efficient Data- Institute of Technology. His research inter-
flow for Convolutional Neural Networks,” Proc. ests include energy-efficient multimedia sys-
ACM/IEEE 43rd Ann. Int’l Symp. Computer tems, deep learning architectures, and com-
Architecture (ISCA 16), 2016, pp. 367–379. puter vision. Chen received an MS in
electrical engineering and computer science
4. Y.-H. Chen et al., “Eyeriss: An Energy-
from the Massachusetts Institute of Tech-
Efficient Reconfigurable Accelerator for
nology. He is a student member of IEEE.
Deep Convolutional Neural Networks,”
Contact him at yhchen@[Link].
Proc. IEEE Int’l Solid-States Circuits Conf.
(ISSCC 16), 2016, pp. 262–263. Joel Emer is a senior distinguished research
5. A. Krizhevsky, I. Sutskever, and G.E. Hinton, scientist at Nvidia and a professor of electrical
“ImageNet Classification with Deep Convo- engineering and computer science at the Mas-
lutional Neural Networks,” Proc. 25th Int’l sachusetts Institute of Technology. His research
Conf. Neural Information Processing Sys- interests include spatial and parallel architec-
tems (NIPS 12), 2012, pp. 1097–1105. tures, performance modeling, reliability analy-
6. S. Chakradhar et al., “A Dynamically Config-
sis, and memory hierarchies. Emer received a
urable Coprocessor for Convolutional Neural
PhD in electrical engineering from the Uni-
Networks,” Proc. 37th Ann. Int’l Symp.
versity of Illinois. He is a Fellow of IEEE.
Computer Architecture (ISCA 10), 2010, pp.
Contact him at jsemer@[Link].
247–257.
Vivienne Sze is an assistant professor in the
7. V. Gokhale et al., “A 240 G-ops/s Mobile Department of Electrical Engineering and
Coprocessor for Deep Neural Networks,” Computer Science at the Massachusetts
Proc. IEEE Conf. Computer Vision and Pat- Institute of Technology. Her research inter-
tern Recognition Workshops (CVPRW 14), ests include energy-aware signal processing
2014, pp. 696–701. algorithms and low-power architecture and
8. Z. Du et al., “ShiDianNao: Shifting Vision system design for multimedia applications,
Processing Closer to the Sensor,” Proc. such as machine learning, computer vision,
ACM/IEEE 42nd Ann. Int’l Symp. Computer and video coding. Sze received a PhD in elec-
Architecture (ISCA 15), 2015, pp. 92–104. trical engineering from the Massachusetts
9. S. Gupta et al., “Deep Learning with Limited
Institute of Technology. She is a senior mem-
Numerical Precision,” Proc. 32nd Int’l Conf.
ber of IEEE. Contact her at sze@[Link].
Machine Learning, vol. 37, 2015, pp.
1737–1746.
10. M. Peemen et al., “Memory-Centric Accelera-
tor Design for Convolutional Neural Networks,” Read your subscriptions through
Proc. IEEE 31st Int’l Conf. Computer Design the myCS publications portal at
[Link]
(ICCD 13), 2013, pp. 13–19.
.............................................................
MAY/JUNE 2017 21