Fastwave: Accelerating Autoregressive Convolutional Neural Networks on FPGA
Total Page:16
File Type:pdf, Size:1020Kb
FastWave: Accelerating Autoregressive Convolutional Neural Networks on FPGA Shehzeen Hussain∗, Mojan Javaheripi∗, Paarth Neekharay, Ryan Kastnery and Farinaz Koushanfar∗ ∗UC San Diego Department of Electrical and Computer Engineering yUC San Diego Department of Computer Science Email: [email protected], [email protected] Abstract—Autoregressive convolutional neural networks the inference still remains sequential and CNN based models (CNNs) have been widely exploited for sequence generation are usually very deep. However, to overcome this problem, tasks such as audio synthesis, language modeling and neural Fast-Wavenet [11] exploits the temporal dependencies by machine translation. WaveNet is a deep autoregressive CNN composed of several stacked layers of dilated convolution that caching redundant computations using fixed-length convolu- is used for sequence generation. While WaveNet produces tional queues and thus makes the generation time linear in state-of-the art audio generation results, the naive inference length of the sequence. Such efforts have made it feasible implementation is quite slow; it takes a few minutes to generate to use autoregressive CNNs for practical sequence generation just one second of audio on a high-end GPU. In this work, we applications, as an alternative to RNN-based models. develop the first accelerator platform FastWave for autoregressive convolutional neural networks, and address the associated design While the Fast-Wavenet algorithm provides a speed-up in challenges. We design the Fast-Wavenet inference model in audio generation over na¨ıve Wavenet implementation, the Vivado HLS and perform a wide range of optimizations generation time is still high, even on a high-end GPU. It including fixed-point implementation, array partitioning and takes 120 seconds to generate 1 second of audio using Fast- pipelining. Our model uses a fully parameterized parallel Wavenet implementation on a NVIDIA TITAN Xp GPU. Prior architecture for fast matrix-vector multiplication that enables per-layer customized latency fine-tuning for further throughput works have shown FPGAs to be successful in accelerating the improvement. Our experiments comparatively assess the trade- inference of pre-trained neural networks by providing custom off between throughput and resource utilization for various data paths to achieve high parallelism. A vast amount of optimizations. Our best WaveNet design on the Xilinx XCVU13P such research focuses on accelerating neural networks in the FPGA that uses only on-chip memory, achieves 66× faster image domain [12], [13], speech recognition [14], [15] and generation speed compared to CPU implementation and 11× faster generation speed than GPU implementation. language modelling [16]. To the best of our knowledge, similar efforts have not been made for accelerating neural networks I. INTRODUCTION for speech/audio synthesis. Autoregressive convolutional models achieve state-of-the- We aim to accelerate audio synthesis using the autoregres- art results in audio [1]–[4] and language domains [5], [6] with sive CNN model - WaveNet on FPGA. The primary challenges respect to both estimating the data distribution and generating in deploying auto-regressive CNN inference on FPGA are high-quality samples. Wavenet [1] is an example of autoregres- designing modules for dilated convolutional layers, buffers for sive convolutional network, used for modelling audio for appli- storing redundant computations using convolutional queues, cations such as text-to-speech (TTS) synthesis and music gen- and dealing with the large depth of these networks which eration. WaveNet has been rated by human listeners to provide is necessary to maintain high audio quality. In this work, substantially more natural sounding audio when compared to we address these challenges of deploying large autoregressive the best existing parametric and concatenative systems in TTS convolutional models on FPGAs and perform a wide range applications for both English and Mandarin [1]. Popular cloud of application and architectural optimizations. Furthermore, based TTS synthesis systems such as Google Now and Google we comprehensively analyze and compare the performance Assistant, that produce natural sounding speech, are built on of Fast-Wavenet implementation on FPGA with the CPU and WaveNet architecture [4], [7]. Alongside achieving state-of- GPU counterparts. the art results in the audio domain, convolutional models Summary of Contributions: are prominent for natural language modeling tasks like text • Creation of the first accelerator platform for autoregres- generation and machine translation [5]. sive convolutional neural networks. We deploy the fast Generally, both autoregressive convolutional neural net- inference model Fast-Wavenet [11] on Xilinx XCVU13P works (CNNs) and Recurrent Neural Networks (RNNs) [8] FPGA which achieves 11 times faster generation speed are widely popular for sequence modelling tasks. The main than a high-end GPU and 66 times faster generation speed advantage of CNN based models is that they can achieve than a high-end CPU. higher parallelism during training and can capture longer time- • Development of reconfigurable basic blocks pertinent to dependencies as compared to RNN based models [9], [10]. autoregressive convolutional networks i.e., dilated causal However, this comes at a cost of slower inference, since convolutional layers, convolutional queues, and fully con- nected layer. Our operations are powered by a fully- learnable parameters of Wavenet model. During inference, customizable matrix-multiplication engine that uses two next-sample audio (xt) generation is performed by sampling levels of parallelism controlled by tunable parameters. from the conditional probability distribution given all of the • Creation of an end-to-end framework that accesses only previous samples, P (xtjxt−1; :::; x1; x0; λ). on-chip memory thereby ensuring high throughput and One possible method for modeling the probability den- avoiding any latency caused by communication with off- sity is via a stack of causal convolutional layers as de- chip memory. picted in Figure 1(a). The input passes through this stack • Exploration of the design space using different architec- of convolutional layers and gated activation functions and tural and application optimizations, as well as comparing finally through a softmax layer to get the posterior proba- the performance and resource usage. We present extensive bility P (xtjxt−1; :::; x1; x0). The downside of this approach evaluation of throughput and power efficiency for our is that in order to model long temporal dependencies from fully optimized and baseline designs. samples far in the past, the causal convolutional network II. BACKGROUND requires either many layers or large filters to increase the receptive field. In general, the receptive field is calculated as In this section, we provide a background on autoregressive # of layers + filter + 1 which gives a receptive field convolutional neural networks. We choose WaveNet as an size of 5 in the architecture shown in Figure 1(a). To address this ideal representation of such models, and describe its overall problem, WaveNet leverages dilated convolutions [20], [21] generative architecture. We first elaborate on the 1D convo- which deliver higher receptive fields without significant in- lution operation as it is the core computation performed in crease in computational cost of the model. Dilated convolution the WaveNet model. Next, we explain WaveNet and its more is equivalent to performing convolutions with dilated filters efficient inference algorithm called Fast-Wavenet. where the size of the filter is expanded by filling the empty A. 1D Convolution positions with zeros. In practice, this is achieved by performing The 1D convolution operation is performed by sliding a one a convolution where the filter skips input values with a certain dimensional kernel over a 1D input signal. Each output value step. at position i is produced by calculating the dot product of the Fig 1(b) illustrates a network with dilated causal convolu- kernel and the overlapping values of the input signal, starting tions for dilation values of 1, 2, 4, and 8. Here, the input from position i. More formally, for an input vector a of length nodes are shown with color blue and the output is shown n and a kernel k of length m, the 1D convolution is calculated with orange. Each edge in the graph correspond to a 1- as follows: dimensional convolution (See section II-A), more generally m (a ∗ k) = σ k × a m (1) i j=1 j i−j+ 2 a matrix multiplication. Due to the binary tree structure of the network, the time complexity of computing output at where i is an arbitrary index in the output vector, which has each time-step is O(2L) where L is the number of layers a total length of n − m + 1. The subscripts denote the indices in the network, which gets highly undesirable as L increases. of the kernel/input vectors. Similarly, the total memory required to store the inputs, output, B. WaveNet and Autoregressive CNNs and the intermediate layer features is O(2L). Autoregressive Neural Networks are popularly used for sequence generation tasks which rely on ancestral sampling i.e. the predictive distribution for each sample in the sequence is conditioned on all previous ones. While RNNs are popular autoregressive models, they do not exhibit high receptive field making them unsuitable for modeling sequences with long- term dependencies like audio [9]. In contrast, autoregressive CNN based models