Power-Optimized Field-Programmable Gate Array Implementation of Neural Activation Functions Using Continued Fractions for AI/ML Workloads

Chanakya Hingu, Xingang Fu, Taofiki Saliyu, Rui Hu, Ramkrishna MishanElectronics 2024

TL;DR

This paper presents a novel approach to implementing the computationally intensive tanh activation function on FPGAs for AI/ML workloads. By using continued fraction approximations, the authors achieve significant reductions in resource usage, power consumption, and latency compared to traditional methods, making it ideal for energy-constrained edge devices.

What Problem Does This Paper Address?

Artificial intelligence (AI) and machine learning (ML) are increasingly deployed on edge devices, which often have limited power and computational resources. A key bottleneck in implementing neural networks on hardware like FPGAs is the efficient computation of activation functions, such as the hyperbolic tangent (tanh). Traditional methods for calculating tanh are computationally expensive, requiring significant hardware resources and power. This paper addresses the challenge of optimizing the hardware implementation of the tanh function for FPGAs to enable energy-efficient and high-performance AI/ML applications in resource-constrained environments.

Methods

The authors propose and implement five different VHDL-based models for approximating the tanh function on an Intel Cyclone V FPGA. These models include:

  • Model 1: Exponential-based: A direct implementation of the tanh function using exponential calculations, serving as a baseline.
  • Models 2 & 3: Continued Fraction Approximations: These models utilize Lambert's continued fraction and a modified continued fraction approach, respectively, to avoid direct exponential calculations.
  • Models 4 & 5: Polynomial-Based Rational Approximations: These models represent tanh(x) as a ratio of polynomials, further simplifying the computation by avoiding exponentials and relying on multiplications and additions.

The implementations were developed using VHDL and synthesized using Intel's Quartus Prime EDA tool. The performance of each model was evaluated based on resource utilization (ALMs, ALUTs, DSP blocks), power consumption, clock latency, and accuracy against MATLAB's double-precision outputs. The most optimized model (Model 4) was then integrated into a recurrent neural network (RNN) for a solar inverter application to demonstrate its real-world performance.

Datasets

Not discussed in the paper. The evaluation relies on comparing FPGA outputs against MATLAB's 64-bit floating-point results for specific input values (e.g., x=2 and x=3.5).

Key Insights and Ideas

  • Continued Fractions are Key: The core innovation is the successful application of continued fraction and rational polynomial approximations for tanh on FPGAs. This approach elegantly sidesteps the high computational cost of exponential functions.
  • Model 4: The Sweet Spot: The polynomial-based rational approximation (Model 4) emerges as the most balanced solution, offering excellent accuracy with significantly lower latency, power consumption, and resource usage compared to other models.
  • FPGA Constraints Drive Design: The choice of the DE1-SoC FPGA, a cost-effective and resource-constrained platform, forces a focus on efficiency, making the results highly relevant for practical edge AI deployments.
  • Trade-offs are Explicit: The paper clearly illustrates the inherent trade-offs between accuracy, power, latency, and resource utilization, providing valuable guidance for designers choosing an activation function implementation.
  • Real-World Validation: Integrating the optimized model into an RNN for a solar inverter application demonstrates its practical applicability and confirms its efficiency in a more complex system.

Key Results

  • Resource Efficiency: Model 4 (polynomial-based) achieved the lowest latency (24 cycles) and moderate resource usage (2803 ALMs, 18 DSP blocks). Model 1 (exponential) was the most resource-efficient in terms of ALMs (1078) and DSP blocks (19) but had higher latency.
  • Power Optimization: Model 4 was the most power-efficient, consuming only 423 mW. Models 1, 2, and 5 also showed good power efficiency (424-470 mW), while Model 3 was the most power-hungry (712 mW).
  • Accuracy: Models 1, 4, and 5 demonstrated high accuracy, closely matching MATLAB's double-precision outputs with a maximum deviation of 0.0000000116. Models 2 and 3 had slightly higher deviations but were still acceptable for many applications.
  • RNN Integration: The optimized Model 4, when integrated into an RNN for a solar inverter, showed a reduction in power consumption from 590 mW (exponential tanh) to 536 mW (polynomial tanh) while maintaining identical accuracy. It also reduced DSP block usage by approximately 16%.

Limitations and Future Work

  • Limited Input Range: The accuracy analysis was performed for specific input values (x=2 and x=3.5). A more comprehensive analysis across a wider range of inputs would provide a more complete picture of model performance.
  • Specific FPGA Platform: The study is focused on the Intel Cyclone V DE1-SoC FPGA. While the principles are generalizable, performance might vary on different FPGA architectures.
  • Future Work: The authors suggest further research into optimizing these models for even greater efficiency and exploring their application in more complex AI/ML architectures and diverse hardware platforms. They also highlight the potential for further improvements by exploring different continued fraction and polynomial approximations.

Summary updated

BibTeX
@inproceedings{hingu2024power,
  author = {Chanakya Hingu and Xingang Fu and Taofiki Saliyu and Rui Hu and Ramkrishna Mishan},
  title = {{Power-Optimized Field-Programmable Gate Array Implementation of Neural Activation Functions Using Continued Fractions for AI/ML Workloads}},
  booktitle = {Electronics},
  year = {2024},
  doi = {10.3390/electronics13245026},
}
Figure