FastCaps: A Design Methodology for Accelerating Capsule Network on Field Programmable Gate Arrays

T. P. Abdul Rahoof, Vivek Chaturvedi, Muhammad ShafiqueIJCNN 2023

Abstract

Capsule Networks (CapsNets) offer superior spatial hierarchy preservation compared to traditional Convolutional Neural Networks (CNNs) but suffer from high computational complexity and memory requirements. This paper introduces FastCaps, a design methodology tailored for deploying CapsNets on resource-constrained edge FPGAs. By integrating a novel Look-Ahead Kernel Pruning (LAKP) technique with hardware-optimized routing algorithms, FastCaps achieves up to a 270x speedup and over 99% model compression with minimal accuracy loss, enabling real-time inference on low-cost hardware.

Introduction

While CNNs are widely used in computer vision, their reliance on pooling layers makes them "translation invariant" rather than "equivariant," often losing critical spatial relationships between features. Capsule Networks address this by using vector-based "capsules" to preserve spatial hierarchies. However, CapsNets are notoriously difficult to accelerate due to their iterative dynamic routing algorithms and high Multiply-Accumulate (MAC) to memory ratios.

Existing acceleration efforts often focus solely on the routing mechanism, leaving other network layers unoptimized. Furthermore, fitting these models onto edge-level FPGAs—essential for applications in autonomous driving and mobile healthcare—remains a significant challenge due to power and area constraints.

Methodology

FastCaps addresses these challenges through a comprehensive two-stage optimization framework.

Overview of the FastCaps design methodology and novel contributions.

Look-Ahead Kernel Pruning (LAKP)

Unlike standard magnitude-based pruning that evaluates layers in isolation, LAKP employs a "look-ahead" strategy. It calculates a score for each kernel in layer $i$ by analyzing its impact on both the preceding ($i-1$) and succeeding ($i+1$) layers. This structured pruning approach removes entire kernels, maintaining regular memory access patterns that are highly efficient for FPGA architectures. A critical discovery was the "PrimaryCaps" bottleneck: pruning kernels in the layer immediately preceding the capsules significantly reduces the total number of capsules, leading to a dramatic reduction in routing parameters (up to 1280x).

Hardware-Optimized Routing

The dynamic routing algorithm's non-linear functions (e.g., exp(), div()) are computationally expensive. FastCaps optimizes these by:

  • Approximation: Using a 5-term Taylor series for exp(), reducing latency from 27 to 14 cycles.
  • Logarithmic Transformation: Converting division into subtraction ($a/b = e^{\log a - \log b}$).
  • Parallelism: Implementing loop reordering and parallel processing elements (PEs) to maximize throughput.
  • Quantization: Utilizing 16-bit fixed-point math, which provides significant speedups without substantial accuracy degradation.

Experimental Results

The methodology was evaluated on a Xilinx PYNQ-Z1 FPGA using the MNIST and Fashion-MNIST (F-MNIST) datasets. Baselines were established using VGG-19 and ResNet-18 on CIFAR-10 to validate the LAKP method's generalizability.

Performance comparison in terms of (a) energy efficiency and (b) throughput across different model versions.

Key performance metrics include:

  • Compression: Effective compression rates of 99.26% (MNIST) and 98.84% (F-MNIST).
  • Throughput: Inference speeds reached 1351 FPS for MNIST and 934 FPS for F-MNIST, a 270x improvement over the unoptimized baseline (5 FPS).
  • Energy Efficiency: Efficiency increased from 1.8 Frames Per Joule (FPJ) to 41.8 FPJ, making the system suitable for battery-powered edge deployment.

Conclusion

FastCaps demonstrates that with intelligent structured pruning and hardware-aware mathematical approximations, Capsule Networks can be made highly efficient for edge-level FPGAs. While currently tested on MNIST-scale data, future work will explore scaling these techniques to high-resolution datasets and even lower-bit quantization to further push the boundaries of edge AI.

Summary updated

BibTeX
@inproceedings{rahoof2023fastcaps,
  author = {T. P. Abdul Rahoof and Vivek Chaturvedi and Muhammad Shafique},
  title = {{FastCaps: A Design Methodology for Accelerating Capsule Network on Field Programmable Gate Arrays}},
  booktitle = {IJCNN},
  year = {2023},
  url = {https://openreview.net/forum?id=-KbbkAwU8g},
}
Figure