[论文解读] Compiling Deep Learning Models for Custom Hardware Accelerators
本文提出了一种用于Snowflake的编译器,这是一种基于FPGA的定制深度学习加速器,能够从Torch7模型描述中自动生成高效的机器指令。通过采用模型解析、工作负载分解、针对内存带宽优化的循环重排以及通信负载均衡,该编译器实现了与手工优化代码相当的性能,并在5W功耗下以250 MHz频率实现了AlexNet(93.6 fps)和ResNet18(21.4 fps)的高效推理。
Convolutional neural networks (CNNs) are the core of most state-of-the-art deep learning algorithms specialized for object detection and classification. CNNs are both computationally complex and embarrassingly parallel. Two properties that leave room for potential software and hardware optimizations for embedded systems. Given a programmable hardware accelerator with a CNN oriented custom instructions set, the compiler's task is to exploit the hardware's full potential, while abiding with the hardware constraints and maintaining generality to run different CNN models with varying workload properties. Snowflake is an efficient and scalable hardware accelerator implemented on programmable logic devices. It implements a control pipeline for a custom instruction set. The goal of this paper is to present Snowflake's compiler that generates machine level instructions from Torch7 model description files. The main software design points explored in this work are: model structure parsing, CNN workload breakdown, loop rearrangement for memory bandwidth optimizations and memory access balancing. The performance achieved by compiler generated instructions matches against hand optimized code for convolution layers. Generated instructions also efficiently execute AlexNet and ResNet18 inference on Snowflake. Snowflake with $256$ processing units was synthesized on Xilinx's Zynq XC7Z045 FPGA. At $250$ MHz, AlexNet achieved in $93.6$ frames/s and $1.2$ GB/s of off-chip memory bandwidth, and $21.4$ frames/s and $2.2$ GB/s for ResNet18. Total on-chip power is $5$ W.
研究动机与目标
- 实现将多样化CNN模型高效编译到具有自定义指令集的可编程、低功耗FPGA加速器(Snowflake)上。
- 自动化从高级Torch7模型描述生成机器级指令,减少人工工作并避免手写汇编代码的错误。
- 通过智能循环重排(Mloop与Kloop)和跨多个内存单元的负载均衡,优化内存带宽使用。
- 在保持对不同CNN架构通用性的同时,最大化硬件利用率和性能。
提出的方法
- 从Torch7的JSON-like模型定义文件中解析模型结构,提取层类型、维度和连接关系。
- 将CNN工作负载分解为计算操作和数据移动操作,重点关注卷积层及其内存访问模式。
- 根据带宽约束选择循环重排策略(Mloop:重复映射加载;Kloop:重复内核加载),以最小化数据移动。
- 通过通信负载均衡,将内存加载/存储指令均匀分配到四个加载/存储单元,防止瓶颈并提升带宽利用率。
- 编译器使用性能模型指导数据重用和指令调度决策,最小化空闲周期并最大化与计算的重叠。
- 生成的指令通过与手工优化代码对比验证,并在Snowflake FPGA上对真实模型(AlexNet、ResNet18、ResNet50)进行基准测试。
实验结果
研究问题
- RQ1如何高效地将多样化且复杂的CNN模型映射到具有RISC基础自定义指令集的定制硬件加速器上?
- RQ2对于不同的卷积层配置,何种循环排序策略(Mloop与Kloop)能最小化内存带宽压力?
- RQ3在多个内存单元之间进行通信负载均衡,能在多大程度上提升整体加速器利用率和吞吐量?
- RQ4完全自动化的编译器能否在卷积层上实现与手工优化汇编代码相当的性能?
主要发现
- 编译器生成的卷积层指令性能与手工优化汇编代码相差仅0.1%,证明了代码生成的高效率。
- 在250 MHz下,Snowflake实现了93.6帧每秒的AlexNet推理性能,对应1.2 GB/s的片外内存带宽。
- 对于ResNet18,系统实现了21.4帧每秒的性能,内存带宽为2.2 GB/s,表明其可扩展至更深的网络。
- 通信负载均衡显著降低了内存瓶颈导致的性能下降,在5%不平衡时实现1.658倍加速,在114%不平衡时实现1.297倍加速。
- 编译器成功实现了ResNet50的推理,每帧耗时218.61 ms,证实了其在不同模型架构间的通用性。
- 识别出内存带宽限制和冷缓存未命中是主要瓶颈,尤其在全连接层中更为明显,提示未来存在优化空间。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。