Skip to main content
QUICK REVIEW

[Paper Review] Compiling Deep Learning Models for Custom Hardware Accelerators

Andre Xian Ming Chang, Aliasger Zaidy|arXiv (Cornell University)|Aug 1, 2017
Advanced Neural Network ApplicationsComputer Science18 references10 citations
TL;DR

This paper presents a compiler for Snowflake, a custom FPGA-based deep learning accelerator, that automatically generates efficient machine instructions from Torch7 model descriptions. By employing model parsing, workload decomposition, loop rearrangement for memory bandwidth optimization, and communication load balancing, the compiler achieves performance matching hand-optimized code and enables efficient inference of AlexNet (93.6 fps) and ResNet18 (21.4 fps) at 250 MHz with 5W power consumption.

ABSTRACT

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.

Motivation & Objective

  • To enable efficient compilation of diverse CNN models onto a programmable, low-power FPGA-based accelerator (Snowflake) with custom instruction set.
  • To automate the generation of machine-level instructions from high-level Torch7 model descriptions, reducing manual effort and error-prone assembly coding.
  • To optimize memory bandwidth usage through intelligent loop rearrangement (Mloop vs. Kloop) and load balancing across multiple memory units.
  • To maintain generality across different CNN architectures while maximizing hardware utilization and performance.

Proposed method

  • Model structure is parsed from Torch7 JSON-like model definition files to extract layer types, dimensions, and connectivity.
  • CNN workloads are decomposed into compute and data movement operations, with a focus on convolutional layers and their memory access patterns.
  • Loop rearrangement strategies (Mloop: repeated map loading; Kloop: repeated kernel loading) are selected based on bandwidth constraints to minimize data movement.
  • Communication load balancing distributes memory load instructions evenly across four load/store units to prevent bottlenecks and improve bandwidth utilization.
  • The compiler uses a performance model to guide decisions on data reuse and instruction scheduling, minimizing idle cycles and maximizing overlap with computation.
  • Generated instructions are validated against hand-optimized code and benchmarked on Snowflake FPGA with real models (AlexNet, ResNet18, ResNet50).

Experimental results

Research questions

  • RQ1How can a compiler efficiently map diverse, complex CNN models to a custom hardware accelerator with a RISC-based custom instruction set?
  • RQ2What loop ordering strategy (Mloop vs. Kloop) minimizes memory bandwidth pressure for different convolutional layer configurations?
  • RQ3To what extent can communication load balancing across multiple memory units improve overall accelerator utilization and throughput?
  • RQ4Can a fully automated compiler achieve performance comparable to hand-optimized assembly code for convolutional layers?

Key findings

  • The compiler-generated instructions for convolution layers achieve performance within 0.1% of hand-optimized assembly code, demonstrating high code generation efficiency.
  • At 250 MHz, Snowflake achieved 93.6 frames per second for AlexNet inference with 1.2 GB/s off-chip memory bandwidth.
  • For ResNet18, the system achieved 21.4 frames per second with 2.2 GB/s memory bandwidth, demonstrating scalability to deeper networks.
  • Communication load balancing reduced performance degradation due to memory bottlenecks, with speedup of 1.658x at 5% imbalance and 1.297x at 114% imbalance.
  • The compiler successfully executed ResNet50 inference at 218.61 ms per frame, confirming its generality across model architectures.
  • Memory bandwidth limitations and cold cache misses were identified as key bottlenecks, especially for fully connected layers, suggesting future optimization opportunities.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.