# Configurable Hardware Core for IoT Object Detection
## 4 Running Tiny-YOLOv3 in the Accelerator
### CNN Acceleration  
The first eight layers of the network can be executed in convolutional+maxpool layer pairs. To minimize data transfers, each IFM tile is read from the main memory once, and the corresponding OFM tile is computed for all kernels. With this strategy, all the kernels are loaded from memory for the same set of IFM tiles. Most configurations stay the same across the complete convolutional and maxpool layers execution. The common configurations are set at the start of the function. Note that all the dataflow phases are configured. The variable configurations are mostly related to updating the data pointers for reading and writing data to/from main memory. The limitations of the on-chip memory buffers require the use of tiling for the IFMs. Figure 5 presents a diagram of the tiling strategy used for the application. Figure 4: Data storage formats. Figure 5: Data tiling diagram. The tiling implemented divides the IFM into blocks of four rows, \(Tile\_W+2\), columns and C channels. The two extra columns per tile are used as padding to maintain the pattern for convolution on the tile edges. The padded columns are not represented in Figure 5 for readability purposes. Since there are nRows memories to store IFM tiles, the same amount of IFM tiles are transferred from the main memory. With the data in ZXY format, each DMA burst reads C \(\times(Tile\_W+2)\) contiguous values. Each IFM tile starts two rows after the start of the previous tile. After each DMA burst, the shift configuration updates the pointer to the main memory from the end of the tile row to the start of the next tile row. The memory for IFM tiles operates whenever possible in a ping-pong fashion: the half of the OFM memory used to write data from the main memory toggles between two consecutive datapath phase executions. The memory for weights is read in sequence. The kernels are read \(2\times Tile\_W\) times, one per each convolution done over an IFM tile. After each convolution, the internal AGU points back to the initial address. The starting address both for reading weights and biases memories is updated according to each set of kernels being used for convolution. The IFM tile configurations for the _Compute_ phase are constant since the accelerator only operates over one set of IFM tiles at a time. The internal AGU that controls the memory accesses is configured to generate a five-loop pattern. The inner-most loop iterates over the values in the same row across all channels for a total of \(ker\_side\times\) C/nMACs. Like the memories for weights, the memories for IFM values output nMACs values in the same word. The execution of these two loops performs a single convolution. The third and fourth loops generate the pattern for the \(2\times 2\) maxpool. The third loop offsets the address to perform the convolution in the next column (C/nMACs addresses added). The fourth loop offsets the address to start in the next row (adding \((Tile\_W+2)\times\) C/nMACs to the address) and one column to the left (subtracting \(2\times\) C/nMACs). The fifth loop generates the pattern to move across the \(Tile\_W/2\) output \(2\times 2\) squares of the IFM tile by adding offsetting the address two columns (\(2\times\)C/nMACs) to the left. The custom core takes \(ker\_side\times\)\(ker\_side\times\) C/nMACs iterations for each convolution, for a total of \(2\times Tile\_W\) convolutions per IFM tile. The convolution result and bias values are shifted to comply with the DFP quantization. The remaining convolutional layers of Tiny-YOLOv3 are accelerated in isolation (only the convolutional layer) or combined with a YOLO or upsample layer. Figure 6 presents the tiling format for the remaining convolutional layers. After layer 8, the IFMs are either \(26\times 26\) or \(13\times 13\) and therefore \(Tile\_W=\) W.  
The main difference in configurations happens for the memories of the IFM tiles in the memory read phase. The convolutional layers 16 and 23 are paired and executed with the YOLO layers 17 and 24, respectively, in the same datapath configuration.