《電子技術(shù)應(yīng)用》
您所在的位置:首頁 > 模拟设计 > 设计应用 > 一种基于FPGA的CNN硬件加速器实现
一种基于FPGA的CNN硬件加速器实现
电子技术应用
邱臻博
重庆邮电大学 光电工程学院, 重庆 400065
摘要: 提出了一种基于FPGA的通用CNN硬件加速器设计方案。针对计算量最大的卷积层,采用了输入通道并行、核内并行、输出通道并行三种加速方式,根据FPGA的片上资源,合理地设置相应并行度。在数据加载方面,采用相邻数据位宽合并传输,有效提高了加速器的实际传输带宽。基于行的数据流加载思想,设计了输入缓存模块。该缓存模块只需缓存两行数据即可开始卷积运算,有效地提前卷积运算的开始时间。在数据输入、数据运算、数据输出模块之间,利用流水线循环优化方式,极大地提高了硬件的计算性能。最后将该加速器应用于VGG16和Darknet-19网络,实验表明,计算性能分别达到34.30 GOPS和33.68 GOPS,DSP计算效率分别高达79.45%和78.01%。
中圖分類號:TP391 文獻(xiàn)標(biāo)志碼:A DOI: 10.16157/j.issn.0258-7998.234372
中文引用格式: 邱臻博. 一種基于FPGA的CNN硬件加速器實(shí)現(xiàn)[J]. 電子技術(shù)應(yīng)用,2023,49(12):20-25.
英文引用格式: Qiu Zhenbo. An FPGA-based implementation of CNN hardware accelerator[J]. Application of Electronic Technique,2023,49(12):20-25.
An FPGA-based implementation of CNN hardware accelerator
Qiu Zhenbo
College of Photoelectric Engineering, Chongqing University of Posts and Telecommunications, Chongqing 400065, China
Abstract: This paper proposes a general CNN hardware accelerator design scheme based on FPGA. For the most computationally intensive convolutional layer, three acceleration modes are adopted: input channel parallelism, intra-core parallelism, and output channel parallelism, and the corresponding parallelism degree is reasonably set according to the on-chip resources of FPGA. In terms of data loading, adjacent data bit width combined transmission is adopted, which effectively improves the actual transmission bandwidth of the accelerator. Based on the idea of row-based data flow loading, the input cache module is designed. The cache module only needs to cache two rows of data to start the convolution operation, effectively advancing the start time of the convolution operation. Between the data input, data operation, and data output modules, the pipeline cycle optimization method is used to greatly improve the computing performance of the hardware. Finally, the accelerator is applied to VGG16 and Darknet-19 networks, and experiments show that the computing performance reaches 34.30 GOPS and 33.68 GOPS, respectively, and the DSP computing efficiency is as high as 79.45% and 78.01%.
Key words : convolutional neural network acceleration;FPGA;row data loading;module division;pipeline structure

0 引言

隨著深度學(xué)習(xí)技術(shù)的飛速發(fā)展,神經(jīng)網(wǎng)絡(luò)模型在圖像識別、目標(biāo)檢測和圖像分割等領(lǐng)域取得了巨大技術(shù)進(jìn)步[1-2]。然而相比較傳統(tǒng)算法,神經(jīng)網(wǎng)絡(luò)在獲得高的性能同時(shí)也帶來了高計(jì)算復(fù)雜度的問題,使得基于專用硬件設(shè)備加速神經(jīng)網(wǎng)絡(luò)成為神經(jīng)網(wǎng)絡(luò)模型應(yīng)用領(lǐng)域關(guān)注的焦點(diǎn)。目前,神經(jīng)網(wǎng)絡(luò)模型硬件加速的主要方案有GPU、ASIC和FPGA三種方案。相比較GPU,F(xiàn)PGA具有成本功耗低的特點(diǎn);相比較ASIC,F(xiàn)PGA具有模型實(shí)現(xiàn)靈活、開發(fā)速度快、綜合成本低的特點(diǎn),特別適用于當(dāng)前神經(jīng)網(wǎng)絡(luò)在邊緣設(shè)備上部署的需求,因此基于FPGA的神經(jīng)網(wǎng)絡(luò)模型加速研究成為當(dāng)前神經(jīng)網(wǎng)絡(luò)領(lǐng)域研究的熱點(diǎn)[3-5]。

大多數(shù)神經(jīng)網(wǎng)絡(luò)模型中卷積層的運(yùn)算量占到了總計(jì)算量的90%以上,因此可以通過在FPGA中執(zhí)行卷積運(yùn)算來實(shí)現(xiàn)神經(jīng)網(wǎng)絡(luò)加速[6-7]。文獻(xiàn)[6]基于FPGA實(shí)現(xiàn)通用矩陣乘法加速器來實(shí)現(xiàn)神經(jīng)網(wǎng)絡(luò)加速,獲得了很好的加速性能。文獻(xiàn)[7]則提出了一種基于脈動陣結(jié)構(gòu)的矩陣乘法加速模塊,并用于神經(jīng)網(wǎng)絡(luò)加速,獲得了較好的性能提升。文獻(xiàn)[8-9]從卷積運(yùn)算的加速算法方面進(jìn)行研究,Liang Y[8]等人基于二維Winograd算法在FPGA上對CNN進(jìn)行了實(shí)現(xiàn),與常規(guī)的卷積計(jì)算單元相比,該實(shí)現(xiàn)中基于二維Winograd算法設(shè)計(jì)的卷積計(jì)算單元將乘法操作減少了56%。Tahmid Abtahi[10]等人使用快速傅里葉變換(Fast Fourier Transform,F(xiàn)FT)對ResNet-20模型中的卷積運(yùn)算進(jìn)行優(yōu)化,成功減少了單個(gè)卷積計(jì)算單元的DSP資源使用量。除卷積運(yùn)算加速外,相關(guān)研究團(tuán)隊(duì)對神經(jīng)網(wǎng)絡(luò)加速過程中的其他方面也展開深入研究[10-14]。文獻(xiàn)[10]提出了一種塊卷積方法,這是傳統(tǒng)卷積的一種內(nèi)存高效替代方法,將中間數(shù)據(jù)緩沖區(qū)從外部DRAM完全移動到片上存儲器,但隨著分塊層數(shù)的增加,精度會降低。文獻(xiàn)[11]提出一種相鄰層位寬合并和權(quán)重參數(shù)重排序的策略實(shí)現(xiàn)數(shù)據(jù)傳輸?shù)膬?yōu)化方法,增加數(shù)據(jù)傳輸并行度的同時(shí)節(jié)省了通道的使用。文獻(xiàn)[12-14]采取乒-乓處理結(jié)構(gòu),分別在輸入模塊、卷積運(yùn)算單元、輸出模塊方面提升了卷積運(yùn)算的速率。



本文詳細(xì)內(nèi)容請下載http://m.ihrv.cn/resource/share/2000005800


作者信息

邱臻博

(重慶郵電大學(xué) 光電工程學(xué)院, 重慶 400065)




weidian.jpg

此內(nèi)容為AET網(wǎng)站原創(chuàng),未經(jīng)授權(quán)禁止轉(zhuǎn)載。

相關(guān)內(nèi)容