text:
\section{Introduction}

Convolutional Neural Networks (CNNs) act as the central tenet behind the rapid development in computer vision tasks such as classification, detection, segmentation, image synthesis, among others. As performance boosts, so do model size, computation, and latency. With millions, sometimes billions of parameters (\textit{e}.\textit{g}., GPT-3~\cite{brown2020language}), modern neural networks face increasing challenges upon ubiquitous deployment, that mostly faces stringent constraints such as energy and latency~\cite{chamnet,molchanov2016pruning,molchanov2019importance,shen2022prune}. In certain cases like autonomous driving, a breach of real-time constraint not only undermines user experience, but also imposes critical safety concerns. Even for cloud service, speeding up the inference directly translates into higher throughput, allowing more clients and users to benefit from the service.

One effective and efficient method to reduce model complexity is network pruning. The primary goal of pruning is to remove the parameters, along with their computation, that are deemed least important for inference~\cite{alvarez2016learning, han2015deep,liu2018rethinking,molchanov2019importance}. Compatible with other compression streams of work such as quantization~\cite{cai2020zeroq,wang2020apq,zhu2016trained}, dynamic inference~\cite{leroux2018iamnn,xia2021fully,yin2022vit}, and distillation~\cite{hinton2015distilling,mullapudi2019online,yin2020dreaming}, pruning enables a flexible tuning of model complexity towards varying constraints, while requiring much less design efforts by neural architecture search~\cite{tan2019mnasnet,vahdat2020unas,wu2019fbnet} and architecture re-designs~\cite{howard2017mobilenets,ma2018shufflenet,tan2019efficientnet}. Thus, in this work, we study pruning, in particular structured pruning that reduces channels to benefit off-the-shelf platforms, \textit{e}.\textit{g}., GPUs.

\begin{figure*}[t]
    \centering
    \includegraphics[scale=0.4]{figures/pipeline.png}
    \vspace{-2mm}
    \caption{
    The proposed hardware-aware latency pruning (HALP) paradigm. Considering both performance and latency contributions, HALP formulates global structural pruning as a global resource allocation problem (Section~\ref{sec:objective}), solvable using our augmented Knapsack algorithm (Section~\ref{sec:solver}). Pruned architectures surpass prior work across varying latency constraints given changing network architectures for both classification and detection tasks (Section~\ref{experiments}).}
    \vspace{-2mm}
    \label{fig:pipeline}
\end{figure*}

As the pruning literature develops, the pruning criteria also evolve to better reflect final efficiency. The early phase of the field focuses on maximum parameter removal in seek for minimum representations of the pretrained model. This leads to a flourish of approaches that rank neurons effectively to measure their importance~\cite{molchanov2016pruning,Wang2020grasp}. As each neuron/filter possesses intrinsically different computation, following works explore proxy to enhance redundancy removal, FLOPs being one of the most widely adopted metrics~\cite{li2020eagleeye,wu2020constraint,yu2019autoslim} to reflect how many multiplication and addition computes needed for the model. However, for models with very similar FLOPs, their latency can vary significantly~\cite{tan2019mnasnet}.
Recently, more and more works start directly working on reducing latency~\cite{chen2018constraint,yang2018netadapt,shen2022prune}. However, not much was done in the field of GPU friendly pruning methods due to non-trivial latency-architecture trade-off.
For example, as recently observed in~\cite{radu2019performance}, GPU usually imposes staircase-shaped latency patterns for convolutional operators with varying channels, which inevitably occur per varying pruning rate, see the latency surface in Fig.~\ref{fig:pipeline}.
This imposes a constraint that pruning needs to be done in groups to achieve latency improvement. Moreover, getting the exact look-up table of layers under different pruning configurations will benefit maximizing performance while minimizing latency.

\begin{figure}[t]
  \begin{center}
    \includegraphics[width=0.9\textwidth]{figures/resnet50_compare_titan.pdf}
  \end{center}
  \vspace{-4mm}
  \caption{Pruning ResNet50 on the ImageNet dataset. The proposed HALP surpasses state-of-the-art structured pruning methods over accuracy, latency, and FLOPs metrics. Target hardware is NVIDIA Titan V GPU. \textbf{Top-left} is better.}
  \label{fig:resnet50_compare_titan}
\end{figure}

Pruning different layers in the deep neural network will result in different accuracy-latency trade-off. Typically, removing channels from the latter layers has smaller impact on accuracy and smaller impact on latency versus removing channels from the early layers. We ask the question, if it is better to remove \textit{more} neurons from latter layer or \textit{less} from early layer to achieve the same accuracy-latency trade-off. By nature, the problem is combinatorial and requires the appropriate solution.

In this paper, we propose hardware-aware latency pruning (HALP) that formulates pruning as a resource allocation optimization problem to maximize the accuracy while maintaining a latency budget on the targeting device. The overall workflow is shown in Fig.~\ref{fig:pipeline}. For latency estimate per pruned architecture, we pre-analyze the operator-level latency values by creating a look-up table for every layer of the model on the target hardware. Then we introduce an additional score for each neuron group to reflect and encourage latency reduction. To this end, we first rank the neurons according to their importance estimates, and then dynamically adjust their latency contributions.
With neurons re-calibrated towards the hardware-aware latency curve, we now select remaining neurons to maximize the gradient-based importance estimates for accuracy, within the total latency constraint.
This makes the entire neuron ranking solvable under the knapsack paradigm. To enforce the neuron selection order in a layer to be from the most important to the least, we have enhanced the knapsack solver so that the calculated latency contributions of the remaining neurons would hold.
HALP surpasses prior art in pruning efficacy, see Fig.~\ref{fig:resnet50_compare_titan} and the more detailed analysis in Section~\ref{experiments}.
Our main contributions are summarized as follows:
\begin{itemize}[topsep=1pt,itemsep=1pt,partopsep=0pt, parsep=0pt,leftmargin=\labelwidth]
    \item We propose a latency-driven structured pruning algorithm that exploits hardware latency traits to yield direct inference speedups.
    \item We orient the pruning process around a quick yet highly effective knapsack scheme that seeks for a combination of remaining neuron groups to maximize importance while constraining to the target latency.
    \item We introduce a group size adjustment scheme for knapsack solver amid varying latency contributions across layers, hence allowing full exploitation of the latency landscape of the underlying hardware.
    \item We compare to prior art when pruning ResNet, MobileNet, VGG architectures on ImageNet, CIFAR10, PASCAL VOC and demonstrate that our method yields consistent latency and accuracy improvements over state-of-the-art methods.
    Our ImageNet pruning results present a viable $1.6\times$ to $1.9\times$ speedup while preserving very similar original accuracy of the ResNets.
\end{itemize}

\section{Related work}

\textbf{Pruning methods}. Depending on when to perform pruning, current methods can generally be divided into three groups~\cite{frankle2018the}: i) prune pretrained models~\cite{han2015deep,luo2017thinet,li2016pruning, he2018amc,molchanov2016pruning,molchanov2019importance,gale2019state}, ii) prune at initialization~\cite{frankle2018lottery,lee2018snip,de2020force}, and iii) prune during training~\cite{alvarez2016learning,gao2019vacl,lym2019prunetrain}. Despite notable progresses in the later two streams, pruning pretrained models remains as the most popular paradigm, with structural sparsity favored by off-the-shelf inference platforms such as GPU.

To improve inference efficiency, many early pruning methods trim down the neural network aiming to achieve a high channel pruning ratio while maintaining an acceptable accuracy. The estimation of neuron importance has been widely studied in literature~\cite{hu2016network,luo2017thinet,molchanov2016pruning}. For example, ~\cite{molchanov2019importance} proposes to use Taylor expansion to measure the importance of neurons and prunes a desired number of least-ranked neurons. However, a channel pruning ratio does not directly translate into computation reduction ratio, amid the fact that a neuron at different location leads to different computations.

There are recent methods that focus primarily on reducing FLOPs. Some of them take FLOPs into consideration when calculating the neuron importance to encourage penalizing neurons that induce high computations~\cite{wu2020constraint}. An alternative line of work propose to select the best pruned network from a set of candidates~\cite{li2020eagleeye,yang2018netadapt}. However, it would take a long time for candidate selection due to the large amount of candidates. In addition, these methods use FLOPs as a proxy of latency, which is usually inaccurate as networks with similar FLOPs might have significantly different latencies~\cite{tan2019mnasnet}.

\textbf{Latency-aware compression.} Emerging compression techniques shift attention to directly cut down on latency. One popular stream is Neural Architecture Search (NAS) methods~\cite{chamnet,dong2018dpp,tan2019mnasnet,wu2019fbnet} that adaptively adjusts the architecture of the network for a given latency requirement. They incorporate the platform constraints into the optimization process in both the architecture and parameter space to jointly optimize the model size and accuracy. Despite remarkable insights, NAS methods remain computationally expensive in general compared to their pruning counterparts.

Latency-oriented pruning has also gained a growing amount of attention. ~\cite{chen2018constraint} presents a framework for network compression under operational constraints, using Bayesian optimization to iteratively obtain compression hyperparameters that satisfy the constraints. Along the same line, NetAdapt~\cite{yang2018netadapt} iteratively prunes neurons across layers under the guidance of the empirical latency measurements on the targeting platform. While these methods push the frontier of latency constrained pruning, the hardware-incurred latency surface in fact offers much more potential under our enhanced pruning policy - as we show later, large rooms for improvements remain unexploited and realizable.

\section{Method}

In this section, we first formulate the pruning process as an optimization process, before diving deep into the importance estimation for accuracy and latency. Then, we elaborate on how to solve the optimization via knapsack regime, augmented by dynamic grouping of neurons. We finalize the method by combining these key steps under one realm of HALP.

\subsection{Objective Function}
\label{sec:objective}
Consider a neural network that consists of $L$ layers performing linear operations on their inputs, together with non-linear activation layers and potentially pooling layers. Suppose there are $N_{l}$ neurons (output channels) in the $l_{\text{th}}$ layer and each neuron is encoded by parameters $\textbf{W}_l^n\in \mathbb{R}^{C_l^{in}\times K_l \times K_l}$, where $C^{in}$ is the number of input channels and $K$ is the kernel size. By putting all the neurons across the network together, we get the neuron parameter set $\textbf{W}= \{\{\textbf{W}_l^n\}_{n=1}^{N_l}\}_{l=1}^L$, where $N=\sum_{l=1}^L N_l$ is the total number of neurons in the network.

Given a training set $\mathcal{D}=\{(x_i, y_i)\}_{i=1}^M$, the problem of network pruning with a given constraint $C$ can be generally formulated as the following optimization problem:
\begin{equation}
\small
    \argmin_{\hat{\textbf{W}}}\mathcal{L}(\hat{\textbf{W}}, \mathcal{D})
    \quad \text{s.t.} \quad \Phi\left(f(\hat{\textbf{W}}, x_i)\right) \leq {C}
\end{equation}
\noindent
where $\hat{\textbf{W}} \subset \textbf{W}$ is the remaining parameters after pruning and $\mathcal{L}$ is the loss of the task. $f(\cdot)$ encodes the network function, and $\Phi(\cdot)$ maps the network to the constraint $C$, such as latency, FLOPs, or memory. We primarily focus on latency in this work while the method easily scales to other constraints.

The key to solving the aforementioned problem relies on identifying the portion of the network that satisfies the constraint while incurring minimum performance disruption:
\begin{equation}
\label{problem_formulatets}
\small
    \begin{split}
    \argmax_{p_1, \cdots, p_l}\sum_{l=1}^L I_l(p_l),
    \ \text{s.t.} \
    \sum_{l=1}^{L} T_l(p_{l-1}, p_l) \leq C, \ \forall l \ \ 0\leq p_l \leq N_l
    \end{split}
\end{equation}
\noindent
where $p_l$ denotes the number of kept neurons at layer $l$, $I_l(p_l)$ signals the maximum importance to the final accuracy with $p_l$ neurons, and $T_l(p_{l-1}, p_l)$ checks on the associated latency contribution of layer $l$ with $p_{l-1}$ input channels and $p_l$ output channels. $p_0$ denotes a fixed input channel number for the first convolutional block, \textit{e}.\textit{g}., $3$ for RGB images.
We next elaborate on $I(\cdot)$ and $T(\cdot)$ in detail.

\textbf{Importance score.} To get the importance score of a layer to final accuracy, namely $I_l(p_l)$ in Eq.~\ref{problem_formulatets}, we take it as the accumulated score from individual neurons $\sum_{j=1}^{p_l}\mathcal{I}_l^j$. We first approximate the importance of neurons using the Taylor expansion of the loss change~\cite{molchanov2019importance}.
Specifically, we prune on batch normalization layers and the importance of the $n$-th neuron in the $l$-th layer is calculated as
\begin{equation}
\label{importance_calc}
    \mathcal{I}_l^n = \left|g_{\gamma_l^n}\gamma_l^n+g_{\beta_l^n}\beta_l^n \right|,
\end{equation}
where $g$ denotes the gradient of the weight, $\gamma_l^n$ and $\beta_l^n$ are the corresponding weight and bias from the batch normalization layer, respectively. Unlike a squared loss in~\cite{molchanov2019importance}, we use absolute difference as we observe slight improvements.

In order to maximize the total importance, we keep the most important neurons at a higher priority.
To this end, we rank the neurons in the $l_{th}$ layer according to their importance score in a descending order and denote the importance score of the $j_{th}$-ranked neuron as $\mathcal{I}_l^j$, thus we have
\begin{equation}
\label{layer_importance}
\small
    I_l(p_l) = \sum_{j=1}^{p_l}\mathcal{I}_l^j,
    \quad
    0 \leq p_l \leq N_l, \
    \mathcal{I}_l^1 \geq \dots \geq \mathcal{I}_l^{N_l}.
\end{equation}
\textbf{Latency contribution.} We empirically obtain the layer latency $T_l(p_{l-1}, p_l)$ in Eq.~\ref{problem_formulatets} by pre-building a layer-wise look-up table with pre-measured latencies. This layer latency corresponds to the aggregation of the neuron latency contribution of each neuron in the layer, $c_l^j$:
\begin{equation}
\label{layer_latency}
\small
    \quad T_l(p_{l-1}, p_l) = \sum_{j=1}^{p_l}c_l^j,
    \quad
    0 \leq p_l \leq N_l. \
\end{equation}
The latency contribution of the $j$-th neuron in the $l$-th layer can also be computed using the entries in the look up table as:
\begin{equation}
\label{latency_calculate}
\small
    c_l^j = T_l{(p_{l-1}, j)} - T_l{(p_{l-1}, j-1)}, \quad 1 \leq j \leq p_l.
\end{equation}

In practice, we first rank globally neurons by importance and then consider their latency contribution. Thus, we can draw the following properties. If we remove the least important neuron in layer $l$, then the number of neurons will change from $p_l$ to $p_l-1$, leading to a latency reduction $c_l^{p_l}$ as this neuron's latency contribution score.
We assign the potential latency reduction to neurons in the layer by the importance order. The most important neuron in that layer would always have a latency contribution $c_l^1$.
At this stage, finding the right combination of neurons to keep imposes a combinatorial problem, and in the next section we tackle it via reward maximization considering latency and accuracy traits.

\subsection{Augmented Knapsack Solver}
\label{sec:solver}
Given both importance and latency estimates, we now aim at solving Eq.~\ref{problem_formulatets}. By plugging back in the layer importance Eq.~\ref{layer_importance} and layer latency Eq.~\ref{layer_latency}, we come to
\begin{equation}
\small
    \label{modified_optimization}
    \max\sum_{l=1}^L\sum_{j=1}^{p_l} \mathcal{I}_l^j,
    \quad \text{s.t.} \quad
    \sum_{l=1}^{L}\sum_{j=1}^{p_l} c_l^j \leq C, \quad 0\leq p_l \leq N_l, \quad
    \mathcal{I}_l^1 \geq \mathcal{I}_l^2 \geq \dots \mathcal{I}_l^{N_l}.
\end{equation}
\noindent
This simplifies the overall pruning process into a knapsack problem only with additional preceding constraints. The preceding enforcement originates from the fact that for a neuron with rank $j$ in the $l_{th}$ layer, the neuron latency contribution only holds when all the neurons with rank $r=1,\dots,j-1$ are kept in the $l_{th}$ layer and the rest of the neurons with rank $r = j+1, j+2, \cdots, N_l$ are removed. Yet the problem is solvable by specifying each item with a list of preceding items that need to be selected before its inclusion.

We augment the knapsack solver to consider the reordered neurons with descending importance score so that all the preceding neurons will be processed before it. A description of the pseudo code of the augmented knapsack solver is provided in Algo.~\ref{modified-knapsack-solution} (a detailed explanation is provided in Appendix~\ref{algo_explain}). The augmented solver is required to make sure that the latency cost is correct.
\begin{algorithm}[!t]
     \tiny
    \caption{Augmented Knapsack Solver}
    \label{modified-knapsack-solution}
    \textbf{Input:} Importance score $\{\mathcal{I}_l \in \mathbb{R}^{N_l}\}_{l=1}^L$ where $\mathcal{I}_l$ is sorted descendingly; Neuron latency contribution $\{c_l\in \mathbb{R}^{N_l} \}_{l=1}^L$; Latency constraint $C$.
    \begin{algorithmic}[1]
        \State $\text{maxV} \in \mathbb{R}^{(C+1)}$, $\text{keep} \in \mathbb{R}^{L\times (C+1)}$ \Comment{maxV[$c$]: max importance under constraint $c$; keep[$l$, $c$]: \# neurons to keep in layer $l$ to achieve maxI[$c$]}
        \For{$l = 1, \dots, L$}
        \For{$j = 1, \dots, N_l$}
            \For{$c = 1, \dots, C$}
                \State $v_{\text{keep}} = \mathcal{I}_l^j + \text{maxV}[c - c_l^j]$, \ $v_{\text{prune}} = \text{maxV}[c]$ \Comment{total importance can achieve under constraint $c$ with object $n$ being kept or not}
                \If{$v_{\text{keep}} > v_{\text{prune}}$ \textbf{and} $\text{keep}[l, c-c_l^j] == j-1$} \Comment{check if it leads to higher score and if more important neurons in layer are kept}
                    \State $\text{keep}[l, c] = j$, \ $\text{update\_maxV}[c]=v_{\text{keep}}$
                \Else
                    \State $\text{keep}[l, c] = \text{keep}[l, c-1]$, \ $\text{update\_maxV}[c]=v_{\text{prune}}$
                \EndIf
            \EndFor
            \State $\text{maxV} \leftarrow \text{update\_maxV}$
        \EndFor
        \EndFor \\

        \State $\text{keep\_n} = \O$ to save the kept neurons in model

        \For{$l = L, \dots, 1$}  \Comment{retrieve the set of kept neurons}
            \State $p_l = \text{keep}[l, C]$
            \State $\text{keep\_n}
            \leftarrow \text{keep\_n} \cup \{p_l \ \text{top ranked neurons in layer} \ l\}$
            \State $C
            \leftarrow C - \sum_{j=1}^{p_l}c_l^j$
        \EndFor
    \end{algorithmic}
    \textbf{Output:} Kept important neurons ($\text{keep\_n}$).
\end{algorithm}

\subsection{Neuron Grouping}
\label{neuron-grouping}
Considering each neuron individually results in burdensome computation during pruning. We next explore grouping neurons so that a number of them can be jointly considered and removed enabling faster pruning~\cite{yin2020dreaming}. Neuron grouping helps exploit hardware-incurred channel granularity guided by the latency, speeds up knapsack solving of Eq.~\ref{modified_optimization}, and yields structures that maximize the GPU utilization, keeping as many parameters as possible under the similar latency. In addition, neuron grouping simplifies the knapsack problem that scales linearly with the number of candidates under consideration (see Line $3$ of Alg.~\ref{modified-knapsack-solution}), thus speedups the solver as we'll discuss later.

We refer to the difference of neuron counts between two latency cliffs of the staircase-patterned latency as the latency step size.
In our method, we group $s$ channels in a layer as an entirety, where the value of $s$ is equal to the latency step size. The neurons are grouped by the order of importance. Then we aggregate the importance score and latency contribution for the grouped entity.
For skip connections in ResNet and group convolutions in MobileNet, we not only group neurons within a layer, we also group the neurons sharing the same channel index from the connected layers~\cite{ding2019centripetal, luo2020neural}. For cross-layer grouping, as the latency step size for different layers might be different, we use the largest group size among the layers.
Latency-aware grouping enables additional performance benefits when compared to a heuristic universal grouping, as we will later show in the experiments.

\subsection{Final HALP Regime}
With all aforementioned steps, we formulate the final HALP as follows. The pruning process takes a trained network as input and prunes it iteratively to satisfy the requirement of a given latency budget $C$. We perform one pruning every $r$ minibatches and repeat it $k$ pruning steps in total. In particular, we set $k$ milestones gradually decreasing the total latency to reach the goal via exponential scheduler~\cite{de2020force}, with $C^1 > C^2 > \cdots > C^k$, $C^k=C$. The algorithm gradually trims down neurons using steps below:
\begin{itemize}[topsep=1pt,itemsep=1pt,partopsep=0pt, parsep=0pt,leftmargin=\labelwidth]
    \item \textbf{Step 1}. For each minibatch, we get the gradients of the weights and update the weights as during the normal training. We also calculate each neuron's importance score as Eq.~\ref{importance_calc}.
    \item \textbf{Step 2}. Over multiple minibatches we calculate the average importance score for each neuron  and rank them accordingly. Then we count the number of neurons remaining in each layer and dynamically adjust the latency contribution as in Eq.~\ref{latency_calculate}.
    \item \textbf{Step 3}. We group neurons as described in Sec.~\ref{neuron-grouping} and calculate group's importance and latency reduction. Then we get the nearest preceding group for each layer.
    \item \textbf{Step 4}. We execute the Algo.~\ref{modified-knapsack-solution} to select the neurons being remained with current latency milestone. Repeat starting from the Step 1 until $k$ milestones are reached.
\end{itemize}
Once pruning finishes we fine-tune the network to recover accuracy.

\section{Experiments}
\label{experiments}
We demonstrate the efficacy and feasibility of the proposed HALP method in this section. We use ImageNet ILSVRC2021~\cite{imagenet} for classification. We first study five architectures (ResNet50, ResNet101, VGG16 and MobileNet-V1/V2) on different platforms and compare our pruning results with the state-of-the-art methods on classification task. All the main results are obtained with our latency-aware grouping. We then study the impact of grouping size $s$ on the pruned top-1 accuracy and the inference time to show the effectiveness of our grouping scheme. Finally, we further show the generalization ability of our algorithm by testing with object detection task. We introduce the details of experimental setting in appendix Sec.~\ref{exp_setting} and provide pruning results on CIFAR10~\cite{krizhevsky2009learning} in appendix Sec.~\ref{cifar_results}. We apply HALP targeting latency reduction on multiple platforms to show the scalability of our method: NVIDIA TITAN V GPU, Jetson TX2, Jetson Xavier and Intel CPU. All the latencies are measured with batched images to take advantage of computation capacities. We include experimental results for batch size $1$ inference in the appendix, which also show the efficacy of our algorithm.

\subsection{Results on ImageNet}
\label{main_result}
\begin{table*}[!t]
    \centering
    \caption{ImageNet structural pruning results. We compare HALP for ResNet50 with two different dense baselines (left), ResNet101 and VGG16 (right up), MobileNet-V1 and MobileNet-V2  (right bottom) pruning experiments, with detailed comparison to state-of-the-art pruning methods over varying performance metrics. More comparisons and CIFAR10 experiments can be found in Appendix~\ref{cifar_results}.}
    \label{tab:latency-ware-result-compare}
    \vspace{-2mm}
    \begin{minipage}[t]{.5\textwidth}
        \centering
        \resizebox{1.\columnwidth}{!}{
            \begin{tabular}{lccccc}
            \toprule
            \multirow{2}{*}{\textsc{Method}} & \textsc{FLOPs} & \textsc{Top1} & \textsc{Top5} &  \textsc{FPS} & \multirow{2}{*}{\textsc{Speedup}}\\
             & (\textsc{G}) & (\%) & (\%) & (\textsc{im/s}) &\\
            \midrule
            \midrule
            \multicolumn{6}{c}{\textbf{\textsc{ResNet50}}}\\
             \textsc{No pruning} & $4.1$ & $76.2$ & $92.87$ & $1019$ & $1\times$ \\
            \midrule
             \textsc{ThiNet}-$70$~\cite{luo2017thinet} & $2.9$ & $75.8$ & $90.67$ & - & - \\
             \textsc{AutoSlim}~\cite{yu2019autoslim} & $3.0$ & $76.0$ & - &  $1215$ & $1.14\times$ \\
             \textsc{MetaPruning}~\cite{liu2019metapruning} & $3.0$ & $76.2$ & - & - & - \\
             \textsc{GReg}-1~\cite{wang2021neural} & $2.7$ & $76.3$ & - & $1171$ & $1.15\times$ \\
             \textbf{\textsc{HALP-$80\%$ (Ours)}} & $3.1$ & $\mathbf{77.2}$ & $\mathbf{93.47}$ & $\mathbf{1256}$ & $\mathbf{1.23\times}$ \\

            \midrule
             $0.75 \times$ \textsc{ResNet50}~\cite{he2015deep} & $2.3$ & $74.8$ & - & $1467$ & $1.44\times$ \\
             \textsc{ThiNet-50}~\cite{luo2017thinet} & $2.1$ & $74.7$ & $90.02$ & - & - \\
             \textsc{AutoSlim}~\cite{yu2019autoslim} & $2.0$ & $75.6$ & - & $1592$ & $1.56\times$  \\
             \textsc{MetaPruning}~\cite{liu2019metapruning} & $2.0$ & $75.4$ & - & $1604$ & $1.58\times$ \\
             \textsc{GBN}~\cite{you2019gate} & $2.4$ & $76.2$ & $92.83$ & - & - \\
             \textsc{CAIE}~\cite{wu2020constraint} & $2.2$ & $75.6$ & - & - & - \\
             \textsc{LEGR}~\cite{chin2020towards} & $2.4$ & $75.6$ & $92.70$ & - & -\\
             \textsc{GReg}-2~\cite{wang2021neural} & $1.8$ & $75.4$ & - & $1414$ & $1.39\times$ \\
             \textsc{CHIP}~\cite{sui2021chip} & $2.1$ & $76.2$ & $92.91$ & - & - \\
             \textsc{CHIP}~\cite{sui2021chip} & $2.2$ & $76.4$ & $93.05$ & $1345$ & $1.32\times$\\
             \textbf{\textsc{HALP-$55\%$ (Ours)}} & $2.0$ & $\mathbf{76.5}$ & $\mathbf{93.05}$ & $\mathbf{1630}$ & $\mathbf{1.60\times}$ \\

            \midrule
             $0.50 \times$ \textsc{ResNet50}~\cite{he2015deep} & $1.1$ & $72.0$ & - & $2498$ & $2.45\times$ \\
             \textsc{ThiNet}-$30$~\cite{luo2017thinet} & $1.2$ & $72.1$ & $88.30$ & - & - \\
             \textsc{AutoSlim}~\cite{yu2019autoslim} & $1.0$ & $74.0$ & - & $2390$ & $2.45\times$ \\
             \textsc{MetaPruning}~\cite{liu2019metapruning} & $1.0$ & $73.4$ & - & $2381$ & $2.34\times$ \\
             \textsc{CAIE}~\cite{wu2020constraint} & $1.3$ & $73.9$ & - & - & - \\
             \textsc{GReg}-2~\cite{wang2021neural} & $1.3$ & $73.9$ & - & $1514$ & $1.49\times$ \\
             \textsc{CHIP}~\cite{sui2021chip} & $1.0$ & $73.3$ & $91.48$ & $2369$ & $2.32\times$ \\
             \textbf{\textsc{HALP-$30\%$ (Ours)}} & $1.0$ & $\mathbf{74.3}$ & $\mathbf{91.81}$ & $\mathbf{2755}$ & $\mathbf{2.70\times}$ \\

             \midrule
             \midrule
             \multicolumn{6}{c}{\textbf{\textsc{ResNet50 - EagleEye~\cite{li2020eagleeye} baseline}}}\\
             \textsc{No pruning} & $4.1$ & $77.2$ & $93.70$ & $1019$ & $1\times$ \\
            \midrule
             \textsc{EagleEye-3G}~\cite{li2020eagleeye} & $3.0$ & $77.1$ & $93.37$ & $1165$ & $1.14\times$ \\
             \textbf{\textsc{HALP-$80\%$ (Ours)}} & $3.0$ & $\mathbf{77.5}$ & $\mathbf{93.60}$ & $\mathbf{1203}$ & $\mathbf{1.18}\times$ \\
             \midrule
             \textsc{EagleEye-2G}~\cite{li2020eagleeye} & $2.1$ & $76.4$ & $92.89$ & $1471$ & $1.44\times$  \\
             \textsc{\textbf{HALP-$55\%$ (Ours)}} & $2.1$ & $\mathbf{76.6}$ & $\mathbf{93.16}$ & $\mathbf{1672}$ & $\mathbf{1.64\times}$ \\
             \midrule
             \textsc{EagleEye-1G~\cite{li2020eagleeye}} & $1.0$ & $74.2$ & $91.77$ & $2429$ & $2.38\times$ \\
             \textbf{\textsc{HALP-$30\%$ (Ours)}} & $1.2$ & $\mathbf{74.5}$ & $\mathbf{91.87}$ & $\mathbf{2597}$ & $\mathbf{2.55\times}$ \\
            \bottomrule
        \end{tabular}
        }
    \end{minipage}
    \begin{minipage}[t]{.48\textwidth}
        \centering
        \resizebox{.92\columnwidth}{!}{
            \begin{tabular}{lccccc}
                \toprule
                \multirow{2}{*}{\textsc{Method}} & \textsc{FLOPs} & \textsc{Top1} &  \textsc{FPS} & \multirow{2}{*}{\textsc{Speedup}}\\
                 & (\textsc{G}) & (\%) & (\textsc{im/s}) &\\
                \midrule
                \midrule
                \multicolumn{5}{c}{\textbf{\textsc{ResNet101}}}\\
                \textsc{No pruning} & $7.8$ & $77.4$ & $620$ & $1\times$ \\
                 \midrule
                 \textsc{Taylor}-$75\%$~\cite{molchanov2019importance} & $4.7$ & $77.4$ & $750$ & $1.21\times$\\
                 \textbf{\textsc{HALP-$60\%$ (Ours)}} & $4.3$ & $\mathbf{78.3}$ & $847$ & $1.37\times$ \\
                 \textbf{\textsc{HALP-$50\%$ (Ours)}} & $\mathbf{3.6}$ & $77.8$ & $\mathbf{994}$ & $\mathbf{1.60\times}$ \\
                 \midrule
                 \textsc{Taylor}-$55\%$~\cite{molchanov2019importance} & $2.9$ & $76.0$ & $908$ & $1.47\times$ \\
                 \textbf{\textsc{HALP-$40\%$ (Ours)}} & $2.7$ & $\mathbf{77.2}$ & $1180$ & $1.90\times$ \\
                 \textbf{\textsc{HALP-$30\%$ (Ours)}} & $\mathbf{2.0}$ & $76.5$ & $\mathbf{1521}$ & $\mathbf{2.45\times}$ \\
                 \midrule
                \midrule
                \multicolumn{5}{c}{\textbf{\textsc{VGG-16}}}\\
                 \textsc{No pruning} & $15.5$ & $71.6$ & $766$ & $1\times$ \\
                 \midrule
                 \textsc{FBS}-$3\times$~\cite{gao2018dynamic} & $5.1$ & $71.2$ & - & -\\
                 \textbf{\textsc{HALP-$30\%$ (Ours)}} & $\mathbf{4.6}$ & $\mathbf{72.3}$ & $1498$ & $2.42\times$ \\
                 \midrule
                 \textsc{FBS}-$5\times$~\cite{gao2018dynamic} & $3.0$ & $70.5$ & - & - \\
                 \textbf{\textsc{HALP-$20\%$ (Ours)}} & $\mathbf{2.8}$ & $\mathbf{70.8}$ & $1958$ & $5.49\times$ \\
                \bottomrule
                \toprule
                \multirow{2}{*}{\textsc{Method}} & \textsc{FLOPs} & \textsc{Top1} & \textsc{FPS} & \multirow{2}{*}{\textsc{Speedup}}\\
                 & (\textsc{M}) & (\%) & (\textsc{im/s}) &\\
                \midrule
                \midrule
                \multicolumn{5}{c}{\textbf{\textsc{MobileNet-V1}}}\\
                 \textsc{No pruning} & $569$ & $72.6$ & $3415$ & $1\times$ \\
                \midrule
                 \textsc{MetaPruning}~\cite{liu2019metapruning} & $142$ & $66.1$ & $7050$ & $2.06\times$ \\
                 \textsc{AutoSlim}~\cite{yu2019autoslim} & $150$ & $67.9$ & $7743$ & $2.27\times$\\
                 \textbf{\textsc{HALP-$42\%$ (Ours)}} & $171$ & $\mathbf{68.3}$ & $\mathbf{7940}$ & $\mathbf{2.32\times}$ \\
                 \midrule
                 $0.75 \times$ \textsc{MobileNetV1} & $325$ & $68.4$ & $4678$ & $1.37\times$ \\
                 \textsc{AMC}~\cite{he2018amc} & $285$ & $70.5$ & $4857$ & $1.42\times$ \\
                 \textsc{NetAdapt}~\cite{yang2018netadapt} & $284$ & $69.1$ & - & - \\
                 \textsc{MetaPruning}~\cite{liu2019metapruning} & $316$ & $70.9$ & $4838$ & $1.42\times$ \\
                 \textsc{EagleEye}~\cite{li2020eagleeye} & $284$ & $70.9$ & $5020$ & $1.47\times$ \\
                 \textsc{GDP}~\cite{guo2021gdp} & $287$ & $71.3$ & - & - &\\
                 \textbf{\textsc{HALP-$60\%$ (Ours)}} & $297$ & $\mathbf{71.3}$ & $\mathbf{5754}$ & $\mathbf{1.68\times}$ \\
                 \midrule
                \midrule
                \multicolumn{5}{c}{\textbf{\textsc{MobileNet-V2}}}\\
                \textsc{No pruning} & $301$ & $72.1$ & $3080$ & $1\times$ \\
                \midrule
                \textbf{\textsc{HALP-$60\%$ (Ours)}} & $183$ & $70.4$ & $5668$ & $1.84\times$ \\
                \midrule
                \textbf{\textsc{HALP-$75\%$ (Ours)}} & $249$ & $72.2$ & $4110$ & $1.33\times$ \\
                \bottomrule
            \end{tabular}
        }
    \end{minipage}
\end{table*}

\textbf{ResNets.} We start by pruning ResNet50 and ResNet101 and compare our results with state-of-the-art methods in Tab.~\ref{tab:latency-ware-result-compare} on TITAN V. In order to have a fair comparison of the latency, for all the other methods, we recreate pruned networks according to the pruned structures they published and measure the latency.
Those methods showing `-' in the table do not have pruned structures published so we are unable to measure the latency.
For our method, by setting the percentage of latency to remain after pruning to be $X$, we get the final pruned model and refer to it as HALP-$X\%$. We report FPS (frames per second) in the table and calculate the speedup of a pruned network as the ratio of FPS between pruned and unpruned models.

From the results comparison in Table.~\ref{tab:latency-ware-result-compare} we can find that for pruned networks with similar FLOPs using different methods, our method achieves the highest accuracy and also the fastest inference speed. This also shows that FLOPs do not correspond $1$:$1$ to the latency.
Among these methods for ResNet50 comparison, EagleEye~\cite{li2020eagleeye} yields the closest accuracy to ours, but the speedup is lower than ours.
In Table.~\ref{tab:latency-ware-result-compare}, for the pruned ResNet50 network with 3G FLOPs remaining, our method achieves a $.4\%$ higher top1 accuracy and slightly ($.04\times$) faster inference. It is expected that the advantage of our method for accelerating the inference is more obvious when it comes to a more compact pruned network, which is $14\%$ (or $.20\times$) additionally faster for a 2G-FLOPs network while increasing accuracy by $.2\%$, and $.17\times$ faster with $.3\%$ higher accuracy compared to EagleEye-1G.
We analyze the pruned network structure in detail in the supplementary material (Appendix Sec.~\ref{detailed-structure}). We plot the results comparison in Fig.~\ref{fig:resnet50_compare_titan}, where we also add the results of training our pruned network with a teacher model RegNetY-16GF (top1 $82.9\%$)~\cite{radosavovic2020designing}. With knowledge distillation, our model is $2.70\times$ faster than the original model at $1\%$ accuracy drop.

\textbf{Scalability to other networks.} We next experiment with three other models: VGG ~\cite{simonyan2014very}, MobileNetV1~\cite{howard2017mobilenets} and MobileNetV2~\cite{sandler2018mobilenetv2}. Same as pruning on ResNets, in Tab.~\ref{tab:latency-ware-result-compare}, we perform pruning with different latency constraints and compare with prior art. As shown, among these methods, the proposed HALP performs significantly better with higher accuracy and larger inference speedup.

\begin{figure*}[t]
  \begin{center}
    \includegraphics[width=\textwidth]{figures/resnet50_compare_other_platform}
  \end{center}
  \vspace{-4mm}
  \caption{Pruning ResNet50 on the ImageNet dataset with NVIDIA Jetson TX2 (left), Intel CPU Xeon E5 (middle) and NVIDIA Xavier (right). The latency on Jetson TX2 and CPU is measured using PyTorch; on Xavier is measured using TensorRT FP32. Top-left is better.}
  \vspace{-2mm}
  \label{fig:resnet50_compare_jetson_and_cpu}
\end{figure*}
\textbf{Scalability to other platforms.} Our approach is not limited to a single platform.
In this section, we conduct the same ResNet50 experiments on three new platforms: NVIDIA Jetson TX2, NVIDIA Xavier, and Intel CPU Xeon E5, and compare the results in Fig.\ref{fig:resnet50_compare_jetson_and_cpu}. As shown, our approach consistently outperforms the other methods with more speedup and higher accuracy,
as HALP leverages the latency characteristics of the platform to achieve a better accuracy-efficiency trade-off.
Specifically, on these platforms, HALP yields up to relative $1.27\times$ speedup with slightly increment in top-1 accuracy compared to EagleEye~\cite{li2020eagleeye}, and $1.72\times$ faster than the original model.
From these results, we can conclude that our method generalizes well to different platforms.

\subsection{HALP Acceleration on GPUs with TensorRT}
\label{tensorrt-acceleration}
\begin{table}[t]
    \centering
    \caption{HALP acceleration of ResNet50 on GPUs with TensorRT (version 7.2.1.6)}
    \label{tab:acceleration_on_gpu}
    \resizebox{0.75\columnwidth}{!}{
    \begin{tabular}{ccccccc}
        \toprule
        \multirow{2}{*}{\textsc{Model}} & \multirow{2}{*}{\textsc{Acc Drop}} & \multicolumn{2}{c}{\textsc{TITAN V GPU}} & \multicolumn{3}{c}{\textsc{RTX3080 GPU}} \\
        \cmidrule(lr){3-4}\cmidrule{5-7}
        & & \textsc{FP32} & \textsc{FP16} & \textsc{FP32} & \textsc{FP16} & \textsc{INT8 (Acc Drop)}\\
        \midrule
        \textsc{EagleEye-3G} & $-0.90\%$ & $1.14\times$ & $4.26\times$ & $1.06\times$ & $3.09\times$ & $6.31\times$ ($-0.84\%$)\\
        \textbf{\textsc{HALP-$80\%$ (Ours)}} & $-1.25\%$ & $\mathbf{1.24\times}$ & $\mathbf{4.70\times}$ & $\mathbf{1.18\times}$ & $\mathbf{3.32\times}$ & $\mathbf{6.40\times}$ ($-1.02\%$) \\
        \textsc{EagleEye-2G} & $-0.18\%$ & $1.54\times$ & $5.10\times$ & $1.35\times$ & $3.68\times$ & $7.46\times$ ($0.27\%$)\\
        \textbf{\textsc{HALP-$55\%$ (Ours)}} & $-0.35\%$ & $\mathbf{1.80\times}$ & $\mathbf{6.36\times}$ & $\mathbf{1.68\times}$ & $\mathbf{4.45\times}$ & $\mathbf{9.14\times}$ ($0.13\%$) \\
        \textsc{EagleEye-1G} & $2.02\%$ & $2.73\times$ & $7.81\times$ & $2.29\times$ & $5.61\times$ & $12.29\times$ ($2.55\%$)\\
        \textbf{\textsc{HALP-$30\%$ (Ours)}} & $1.76\%$ & $\mathbf{2.91\times}$ & $\mathbf{9.61\times}$ & $\mathbf{2.56\times}$ & $\mathbf{6.44\times}$ & $\mathbf{14.12\times}$ ($2.38\%$) \\
        \bottomrule
    \end{tabular}
    }
    \vspace{-4mm}

\end{table}
To make it closer to the real application in production, we also export the models into onnx format and test the inference speed with TensorRT. We run the inference of the model with FP32, FP16 and also INT8. For INT8, we quantize the model using entropy calibration with $2560$ randomly selected ImageNet training images. Since the INT8 TensorCore speedup is not supported in TITAN V GPU, we only report the quantized results on RTX3080 GPU. The accelerations and the corresponding top1 accuracy drop (compared to PyTorch baseline model) are listed in Tab.~\ref{tab:acceleration_on_gpu}.
We include more pruning results specifically for \textbf{INT8 quantization} in Appendix.\ref{prune_for_int8_quantization}.

\subsection{Design Effort for Pruning}
\label{design-effort}
\begin{wraptable}{r}{0.6\textwidth}
    \vspace{-4mm}
    \centering
    \caption{Comparison of extra computation required by pruning methods on ImageNet. Our approach is around \textit{4.3$\times$ faster} than the next best method. Sub-network selection timing is approximated as running on same device (a NVIDIA V100).}
    \label{tab:algorithm-efficiency-compare}
    \resizebox{0.6\columnwidth}{!}{
     \begin{tabular}{cccc}
        \toprule
        \multirow{2}{*}{\textsc{Method}} & \textsc{Evaluate}  & \textsc{Auxiliary net} & \multicolumn{1}{c}{\textsc{Sub-network}}\\
               & \textsc{proposals}? &  \textsc{training?} & \multicolumn{1}{c}{\textsc{selection (ResNet50)}}\\
        \midrule
        \textsc{NetAdapt}~\cite{yang2018netadapt} & Y & N & $\sim195$h (GPU)\\
        \textsc{ThiNet}~\cite{luo2017thinet} & Y & N & $\sim210$h (GPU)\\
        \textsc{EagleEye}~\cite{li2020eagleeye} & Y & N & $30$h (GPU)\\
        \textsc{AutoSlim}~\cite{yu2019autoslim} & Y & Y & $-$ \\
        \textsc{MetaPruning}~\cite{liu2019metapruning} & Y & Y & $-$ \\
        \textsc{AMC}~\cite{he2018amc} & N & Y & $-$  \\
        \midrule
        \textsc{HALP \textbf{(Ours)}} & \textbf{N} & \textbf{N} & \textbf{$6.5$h (GPU) + $0.5$h (CPU)} \\
        \bottomrule
    \end{tabular}
    }
    \vspace{-4mm}
\end{wraptable}
In addition to noticeable performance boosts, HALP in fact requires less design effort compared to prior art, as summarized in Tab.~\ref{tab:algorithm-efficiency-compare} (details in Appendix~\ref{execute_breakdown}). NetAdapt~\cite{yang2018netadapt} and AutoSlim~\cite{yu2019autoslim} generate many proposals during iterative pruning. Then evaluations of the proposals are needed to select the best candidate for the next pruning iteration. EagleEye~\cite{li2020eagleeye} pre-obtains $1000$ candidates before pruning and evaluates all of them in order to get the best one. Such pruning candidate selection is intuitive but causes a lot of additional time costs. The computation cost for MetaPruning~\cite{liu2019metapruning} and AMC~\cite{he2018amc} can be even higher because they need to train auxiliary network to generate the pruned structure.

Compared to these methods, our method does not require auxiliary network training nor sub-network evaluation. The latency contribution in our method can be quickly obtained during pruning by the pre-generated latency lookup table. Although creating the table for the target platform might cost time, we only do it once for all pruning ratios. Solving the augmented knapsack problem brings extra computation, however, after neuron grouping, it only takes around additional $30$ minutes of CPU time in total for ResNet50 pruning and less than $1$ minute for MobileNetV1, which is negligible compared to the fine-tuning process or training additional models. Moreover, this is significantly lower than other methods, for example the fastest of them EagleEye~\cite{li2020eagleeye} requires $30$ GPU hours.

\subsection{Efficacy of Neuron Grouping}
\label{ablation_studies}
We then show the benefits of latency-aware neuron grouping and compare the performance under different group size settings.

\noindent
\textbf{Performance comparison.}
As described in Sec.~\ref{neuron-grouping}, we group $s$ neurons in a layer as an entirety so that they are removed or kept together. Choosing different group sizes leads to different performances, and also different computation cost on the augmented knapsack problem solving. In our method, we set an individual group size for each layer according to each layer's latency step size in the look-up table. We name the grouping in our method as latency-aware grouping (LG). For instance, for a ResNet50, using this approach we set the individual group size of 23 layers to 32, of 20 layers to 64, and 10 layers to 128. Layers closer to the input tend to use a smaller group size. Another option for neuron grouping is to heuristically set a fixed group size for all layers as literature does~\cite{yin2020dreaming}.

Fig.~\ref{fig:group_size_ablation} shows the performance of our grouping approach compared to various fixed group sizes for a ResNet50 pruned with different constraints.

\begin{wrapfigure}{r}{0.5\textwidth}
  \vspace{-8mm}
  \begin{center}
    \includegraphics[width=0.5\textwidth]{figures/group_size_impact}
  \end{center}
  \vspace{-2mm}
  \caption{Performance comparison of different group size settings for ResNet50 pruning on ImageNet. We compare to heuristic-based group selection studied by~\cite{yin2020dreaming}. LG denotes our proposed latency-aware grouping in HALP that yields consistent latency benefits per accuracy.}
  \label{fig:group_size_ablation}
  \vspace{-4mm}
\end{wrapfigure}
As shown, using small group sizes yields the worst performance independently of the latency constraint. At the same time, a very large group such as $256$ do also harm the final performance. Intuitively, a large group size averages the contribution of many neurons and therefore
is not discriminative enough to select the most important ones. Besides, large groups might promote pruning the entire layer in a single pruning step, leading to performance drop. On the other hand, small group sizes such as $2$ promote removing unimportant groups of neurons. These groups do not significantly improve the latency, but can contribute to the final performance. In contrast, our latency-aware grouping performs the best, showing the efficacy of our grouping scheme.

\noindent
\textbf{Algorithm efficiency improvement.} Setting the group size according to the latency step size not only improves the performance, but also reduces computation cost on knapsack problem solving for neuron selection since it reduces the total number of object $N$ to a smaller value. In our ResNet50 experiment, except for the first convolution layer, the group size of other layers varies from $32$ to $128$. By neuron grouping, the value of $N$ can be reduced to $215$, which takes around one minute on average at each pruning step to solve the knapsack problem on CPU. We have $30$ pruning steps in total in our experiments, thus the time spent on neuron selection is around $30$ minutes in total, which can be negligible compared to training time.

\subsection{Generalization to Object Detection}
\label{sec:object_detection}
\begin{wraptable}{r}{0.5\textwidth}
  \vspace{-8mm}
  \begin{center}
    \includegraphics[scale=0.5]{figures/detection_compare}
  \end{center}
  \vspace{-5mm}
  \caption{HALP for object detection on the PASCAL VOC dataset. Detailed numbers in the Appendix~\ref{sec:detection_detail}.}
  \vspace{-2mm}
  \label{fig:detection_compare}
\end{wraptable}
To show the generalization ability of our proposed HALP algorithm, we also apply the algorithm to the object detection task. In this experiment we take the popular architecture Single Shot Detector (SSD)~\cite{liu2016ssd} on the PASCAL VOC
dataset~\cite{everingham2010pascal}. Following the ``07+12'' setting in~\cite{liu2016ssd}, we use the union of VOC2007 and VOC2012 trainval as our training set and use the VOC2007 test as test set
We pretrain a SSD512 detector with ResNet50 as the backbone. The details of the SSD structure are elaborated in the appendix. Same to classification task, we prune the trained detector and finetune afterwards. We only prune the backbone network in the detector.
The results in Fig.~\ref{fig:detection_compare} show that the pruned detector maintains the similar final mAP but reduce the FLOPs and improve the inference speed greatly, with $77\%$ FLOPs reduction and around $1.94\times$ speedup at the cost of only $0.56\%$ mAP drop. We compare the pruned detector to some other commonly-used detectors in the table. The results show that pruning a detector using HALP improves performance in almost all aspects.
\section{Conclusion}
We proposed hardware-aware latency pruning (HALP) that focuses on pruning for underlying hardware towards latency budgets. We formulated pruning as a resource allocation optimization problem to achieve maximum accuracy within a given latency budget. We further proposed a latency-aware neuron grouping scheme to improve latency reduction. Over multiple neural network architectures, classification and detection tasks, and changing datasets, we have shown the efficiency and efficacy of HALP by showing consistent improvements over state-of-the-art methods. Our work effectively reduces the latency while maintaining the accuracy, which could significantly impact applications in resource-constrained environments, such as autonomous vehicles or other mobile devices.

\section{Algorithm~\ref{modified-knapsack-solution} explanation}
\label{algo_explain}
We follow the standard Knapsack problem dynamic programming solution to break down the original problem into sub-problems. Specifically, for each neuron $j$ (or neuron group) in layer $l$, we can choose to either include or not include it under the latency constraint $c$. When it is kept, the total importance score increases $\mathcal{I}_l^j$ while the latency constraint for the other neurons becomes $c-c_l^j$; If the neuron is removed, the latency constraint for the other neurons remains $c$. We choose to keep or remove the current neuron to maximize total importance. At the same time, we check whether the more important neurons in the same layer are included to ensure the correctness of the latency. The neuron selection from the remaining neurons is a sub-problem to solve.

Precisely, we use a vector $\text{maxV}\in \mathbb{R}^{(C+1)}$ to store the maximum importance that we can achieve under the latency constraint $c$, $0\leq c \leq C$ and $\textit{keep}\in \mathbb{R}^{L\times(C+1)}$, a 2D vector where $\text{keep}[l, c]$ denotes the number of neuron groups we need to maintain in layer $l$ to obtain the maximum importance $\text{maxV}[c]$. We process the neurons according to their importance score in decreasing order. In this way, all preceding neurons to the current one (i.e., neurons with a higher importance score in the same layer) will be always considered first. To decide if we keep or remove the current neuron, we check the total importance score and the inclusion status of its preceding neurons, so we can maximize the total importance and ensure the latency cost correctness.

\section{Experimental settings}
\label{exp_setting}
For image classification, in the main paper we focus on pruning networks on the large-scale ImageNet ILSVRC2012 dataset~\cite{imagenet} ($1.3$M images, $1000$ classes). Each pruning process consumes a single node with eight NVIDIA Tesla V100 GPUs. We use PyTorch~\cite{paszke2017pytorch} V1.4.0 model zoo for pretrained weights for our pruning for a fair comparison with literature.

In our experiments we perform iterative pruning. Specifically, we prune every $320$ minibatches after loading the pretrained model with $k=30$ pruning steps in total to satisfy the constraint. Unless otherwise specified, we finetune the network for $90$ epochs in total with an individual batch size at $128$ for each GPU. For finetuning, we follow NVIDIA's recipe~\cite{nvidiarecipe} with mixed precision and Distributed Data Parallel training. The learning rate is warmed up linearly in the first $8$ epochs and reaches the highest learning rate, then follows a cosine decay over the remaining epochs~\cite{loshchilov2016sgdr}.
For the result in Fig.1 that is trained with knowledge distillation, we use RegNetY-16GF (top1 $82.9\%$) as the teacher model when finetuning the pruned model. We use hard distillation on the logits and the final training loss is calculated as $L = (1-\alpha)L_{base}+\alpha L_{distil}$
where $\alpha=0.5$ to balance between the original loss $L_{base}$ and the distillation loss $L_{distil}$.

For latency lookup table construction, we target a NVIDIA TITAN V GPU with batch size $256$ for latency measurement to allow for highest throughput for inference, and target a Jetson TX2 with inference batch size $32$. We pre-generate a layer latency look-up table on the platform by iteratively reducing of the number of neurons in a layer to characterize the latency with NVIDIA cuDNN~\cite{chetlur2014cudnn} V7.6.5. We profile each latency measurement $100$ times and take the average to avoid randomness.

We also provide pruning results on the small-scale CIFAR10~\cite{krizhevsky2009learning} dataset in appendix Sec.~\ref{cifar_results}. For CIFAR10 experiments with ResNet-50/-56, we train the model on a single GPU for $200$ epochs in total where we perform pruning step very one epoch in the first $30$ epochs and finetune the pruned model during the remaining $170$ epochs. The initial learning rate is set to $0.1$ with batch size $128$. For DenseNet, we extend the finetuning epochs to $300$ epochs

\section{More pruning results on CIFAR10 and ImageNet}
\label{cifar_results}
We provide the pruning results of our method on CIFAR10 dataset in this section. We chose $3$ network architectures for the experiment: ResNet50, ResNet56 and DenseNet40-12~\cite{huang2017densely}. As most of the prior methods perform pruning under the FLOPs constraint, in our CIFAR10 experiment we also use FLOPs constraint instead of the latency constraint. We also add some additional ImageNet-ResNet50 results comparison in the table. For a fair comparison, in the ImageNet50 experiment, we also provide the model accuracy under the same finetuning recipe and epochs as the methods to be compared to alleviate the potential impact of the different finetuning settings. Specifically, when compared to GBN~\cite{you2019gate}, we finetune the pruned network for $60$ epochs, where initial learning rate is set to $0.01$ with batch size $256$. The learning rate is divided by $10$ at epoch $36$, $48$ and $54$. When compared to QCQP~\cite{jeong2022optimal}, the pruned network is finetuned for $80$ epochs with batch size $384$ and the initial learning rate of $0.015$. Then, the learning rate is decayed at epoch $30$ and $60$ by deviding $10$.
As shown in Tab.~\ref{tab:more_prune_result}, HALP method consistently outperforms with lower FLOPs and higher Top1 accuracy. When it comes to the actual inference speed comparison with QCQP~\cite{jeong2022optimal}, our method yields $0.16\%$ less accuracy drop while getting $0.08\times$ faster speed.

\begin{table}[t]
    \centering
    \caption{Additional pruning results and comparison on CIFAR10 and ImageNet dataset. FLOPS (\%) are relative to those of the unpruned network}
    \label{tab:more_prune_result}
    \begin{minipage}{\columnwidth}
    \centering
    \resizebox{0.75\columnwidth}{!}{
    \begin{tabular}{c|c|ccc}
        \toprule
        Dataset & Model & Method & FLOPs (\%) $\downarrow$ & Top1 (\%) $\uparrow$\\
        \midrule
        \multirow{8}{*}{CIFAR10} & \multirow{2}{*}{ResNet50} & ChipNet~\cite{tiwari2021chipnet} & $17.7$ & $92.8$\\
        & & \textbf{HALP(Ours)} & $\mathbf{13.7}$ & $\mathbf{93.2}$\\
        \cmidrule{2-5}
        & \multirow{4}{*}{ResNet56} & CHIP~\cite{sui2021chip} & $27.7$ & $92.05$ \\
        & & \textbf{HALP (Ours)} & $\mathbf{26.8}$ & $\mathbf{93.22}$ \\
        & & GDP~\cite{guo2021gdp} & $34.36$ & $93.55$ \\
        & & \textbf{HALP (Ours)} & $\mathbf{33.72}$ & $\mathbf{93.68}$ \\
        \cmidrule{2-5}
        & \multirow{2}{*}{DenseNet40-12$^{\dag}$} & QCQP~\cite{jeong2022optimal} & $29.2$ & $93.80^{\dag}$ \\
        & & \textbf{HALP (Ours)} & $29.2$ & $93.15^{\dag}$ \\
        \midrule
        \multirow{7}{*}{ImageNet} & \multirow{7}{*}{ResNet50} & GBN-60~\cite{you2019gate} & $59.46$ & $76.19$ \\
        & & QCQP~\cite{jeong2022optimal} & $59.0$ & $76.00$ \\
        & & \multirow{2}{*}{\textbf{HALP (Ours)}} & \multirow{2}{*}{$\mathbf{58.12}$} & $\mathbf{76.93}$ \\
        & & & & ($\mathbf{76.49^*}$ / $\mathbf{76.53^{**}}$) \\
        \cmidrule{3-5}
        & & GBN-50~\cite{you2019gate} & $44.94$ & $75.18$ \\
        & & \textbf{HALP (Ours)} & $\mathbf{42.05}$ & $\mathbf{76.09}$ ($\mathbf{75.27^{**}}$) \\

        \midrule
        \midrule
        Dataset & Model & Method & Inf speedup (\%) $\uparrow$ & Top1 drop (\%) $\downarrow$\\
        \midrule
        \multirow{2}{*}{ImageNet} & \multirow{2}{*}{ResNet50} & QCQP~\cite{jeong2022optimal} & $1.52\times$ & $0.32$ \\
        & & \textbf{HALP (Ours)} & $\mathbf{1.60\times}$ & $\mathbf{-0.22}$ ($\mathbf{0.16^{**}}$) \\
        \bottomrule
        \multicolumn{5}{l}{\footnotesize{$^{\dag}$ \ \ The baseline model used in QCQP has $95.01\%$ top1 accuracy, while our pretrained model has $94.40\%$ top1 accuracy.}} \\
        \multicolumn{5}{l}{\quad \footnotesize{The accuracy drop is $1.21\%$ vs. $1.25\%$, which is comparable.}} \\
        \multicolumn{5}{l}{\footnotesize{$^*$} \ \ use the same finetune recipe and epochs as GBN~\cite{you2019gate}} \\
        \multicolumn{5}{l}{\footnotesize{$^{**}$} use the same finetune recipe and epochs as QCQP~\cite{jeong2022optimal}}
    \end{tabular}
    }
    \end{minipage}
\end{table}
\begin{table}[t]
\caption{Pruning MobileNet-V1 and MobileNet-V2 on the ImageNet dataset with different targets.
    }
    \label{tab:mobilenets_more_result}
    \begin{minipage}{0.48\columnwidth}
    \centering
    \resizebox{0.9\columnwidth}{!}{
    \begin{tabular}{lccccc}
        \toprule
        \multirow{2}{*}{Method} & FLOPs & Top1 & Top5 &  FPS & \multirow{2}{*}{Speedup}\\
         & (M) & (\%) & (\%) & (im/s) &\\
        \midrule
        \midrule
        \multicolumn{6}{c}{\textbf{MobileNet-V1}}\\
         No pruning & $569$ & $72.64$ & $90.88$ & $3415$ & $1\times$ \\
        \midrule
        HALP-$40\%$ & $154$ & $67.20$ & $87.32$ & $8293$ & $2.43\times$ \\
        HALP-$42\%$ & $171$ & $68.30$ & $88.08$ & $7940$ & $2.32\times$ \\
        HALP-$50\%$ & $237$ & $69.79$ & $89.08$ & $6887$ & $2.02\times$ \\
        HALP-$60\%$ & $297$ & $71.31$ & $90.05$ & $5754$ & $1.68\times$ \\
        HALP-$70\%$ & $360$ & $71.78$ & $90.39$ & $4870$ & $1.43\times$ \\
        HALP-$80\%$ & $416$ & $72.52$ & $90.78$ & $4167$ & $1.22\times$ \\
        HALP-$90\%$ & $507$ & $72.95$ & $91.02$ & $3765$ & $1.10\times$ \\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
    \begin{minipage}{0.48\columnwidth}
    \centering
    \resizebox{0.9\columnwidth}{!}{
    \begin{tabular}{lccccc}
        \toprule
        \multirow{2}{*}{Method} & FLOPs & Top1 & Top5 &  FPS & \multirow{2}{*}{Speedup}\\
         & (M) & (\%) & (\%) & (im/s) &\\
        \midrule
        \midrule
        \multicolumn{6}{c}{\textbf{MobileNet-V2}}\\
         No pruning & $301$ & $72.10$ & $90.60$ & $3080$ & $1\times$ \\
        \midrule
        HALP-$60\%$ & $183$ & $70.42$ & $89.75$ & $5668$ & $1.84\times$ \\
        HALP-$65\%$ & $218$ & $71.41$ & $90.08$ & $5003$ & $1.62\times$ \\
        HALP-$70\%$ & $227$ & $71.88$ & $90.39$ & $4478$ & $1.45\times$ \\
        HALP-$75\%$ & $249$ & $72.16$ & $90.44$ & $4109$ & $1.33\times$ \\
        HALP-$90\%$ & $273$ & $72.45$ & $90.68$ & $3443$ & $1.12\times$ \\
        HALP-$95\%$ & $281$ & $72.55$ & $90.79$ & $3265$ & $1.06\times$ \\

        \bottomrule
    \end{tabular}
    }
    \end{minipage}
\end{table}

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-6mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.35\textwidth]{figures/mobilenets_more_results}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{Pruning MobileNets on the ImageNet dataset.}
  \vspace{-4mm}
  \label{fig:mobilenets_more_result}
\end{wrapfigure}
Table.~\ref{tab:mobilenets_more_result} and Fig.~\ref{fig:mobilenets_more_result} provide additional pruning results for lightweight networks such as MobileNet-V1 and MobileNet-V2. For the unpruned models, we find that even MobileNet-V2 has significantly lower FLOPs, the inference time is larger compared to MobileNet-V1.In both cases, HALP yields inference speeds-ups of $1.22\times$ and $1.33\times$ for MobileNet-V1 and MobileNet-V2 respectively, while maintaining the original top1 accuracy.

\section{Efficacy of neuron grouping on MobileNet}
In this section, we show the benefits of latency-aware neuron grouping and the performance under different group size settings on MobileNetV1.

Since MobileNet has group convolutional layers to speedup the inference, we take the group convolutional layer with its preceding connected convolutional layer together as coupled cross-layers~\cite{gao2019vacl} to
\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-4mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.45\textwidth]{figures/group_size_impact_mobilenet}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{Performance comparison of our latency-aware grouping to different fixed sizes for a MobielNetV1 pruned with different latency constraints on ImageNet. We compare to heuristic-based group selection studied by~\cite{yin2020dreaming}. LG denotes the proposed latency-aware grouping in HALP that yields consistent latency benefits per final accuracy.}
  \label{fig:group_size_mobilenet}
\end{wrapfigure}
make sure the input channel number and output channel number of the group convolution remain the same. All the $27$ convolutional layers can be divided into $14$ coupled layers. In our method, with the neuron grouping, we set the individual group size of $1$ coupled layer to $16$, of $3$ coupled layers to $32$ and $10$ coupled layers to $64$. Also, for MobileNetV1 pruning, we add the additional constraint that each layer has at least one group of neurons remaining to make sure that the pruned network is trainable.

We compare our latency-aware neuron grouping with an heuristic option by setting a fixed group size for all layers. Fig.~\ref{fig:group_size_mobilenet} shows the comparison results between our neuron grouping method and various fixed group sizes for a MobielNet pruned with different latency constraints on ImageNet. As shown, similar to ResNet50, using small group sizes such as $8$, $16$ leads to worse performance; a large group size like $128$ also harms the performance significantly. Our observations on ResNet50 pruning also hold in MobileNetV1 setting, further emphasizing the efficacy of our latency-aware neuron grouping.

\section{Ablation study of pruning step $k$}

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-8mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.45\textwidth]{figures/ablation_k}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{Performance comparison of different pruning steps $k$ for ResNet50 pruning on ImageNet.}
  \label{fig:ablation_k}
\end{wrapfigure}
In this work, similar to many other prior methods~\cite{alvarez2016learning,molchanov2019importance,yu2019autoslim}, we do iterative pruning with $k$ pruning steps in total. In this experiment, we analyze the the accuracy of the final result as a function of $k$. We set the value of $k$ to $10$, $20$, $30$ and $40$ for iterative pruning, and also use $k=1$ to perform a single-shot pruning. The result of this experiment is shown in Fig.~\ref{fig:ablation_k}. As shown, we get similar results independent of $k$. Imporantly, all these results outperform EagleEye~\cite{li2020eagleeye}. As expected, there is a drop in accuracy for single-shot pruning ($k=1$), especially for large pruning ratios. The main reason is the neuron importance would change as we remove some other neurons and, in this setting, the value is not updated. Iterative pruning does not have this limitation as the importance score and the latency cost of the remaining neurons is updated after each pruning step to reflect any changes. In our experiments, we use $k=30$ as it provides a good trade off between latency and accuracy.

\section{Comparison with EagleEye on ImageNet}
\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-8mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.45\textwidth]{figures/compare_with_eagleeye}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{Pruning ResNet50 on the ImageNet dataset using the same baseline model as in EagleEye with a top-1 accuracy of $77.23\%$. The proposed HALP surpasses EagleEye ECCV20~\cite{li2020eagleeye} in accuracy and latency. Top-left is better.}
  \label{fig:compare-with-eagleeye}
\end{wrapfigure}
We now use the same unpruned baseline model provided by EagleEye~\cite{li2020eagleeye} to compare our proposed HALP method with EagleEye~\cite{li2020eagleeye} varying the latency constraint. As shown in Fig.~\ref{fig:compare-with-eagleeye}, our approach dominates EagleEye by consistently delivering a higher top-1 accuracy with a significantly faster inference time.

We then analyze the structure difference between our pruned model and the EagleEye model. As mentioned in the main text that the proposed HALP method tries to make the number of remaining neurons in each layer fall to the right side of a step if the latency on the targeting platform presenting a staircase pattern. Fig.~\ref{fig:layer_compare_with_eagleeye} shows two examples of pruned layers after pruning from HALP-$45\%$ and EagleEye-2G model. In the left figure, we show that the layer in our pruned model has only $5$ more neurons pruned than that in EagleEye model, the latency is reduced to a much lower level which is a $0.76$ms drop while we have $31$ more input channels. In the right figure, we also show that sometimes we can remain a lot more neurons ($30$ neurons) in layer with only little latency ($0.21$ms) increase. These two examples both show the ability of method to fully exploit the latency traits and benefit the inference speed.
\begin{figure}
    \centering
    \includegraphics[scale=0.3]{figures/layer3.0.conv2_compare}
    \includegraphics[scale=0.3]{figures/layer2.1.conv3_compare}
    \caption{Two examples of pruned layers from HALP model and EagleEye~\cite{li2020eagleeye} model. The scattered black points are the locations of the layers fall to after pruning.}
    \label{fig:layer_compare_with_eagleeye}
\end{figure}

Our method benefits a lot from the non-linear latency characteristic since we are trying to keep as many neurons as possible under the latency constraint. If the latency of the layer on the targeting platform shows linear pattern, the advantage of our method becomes smaller. Fig.~\ref{fig:layer_compare_with_eagleeye} shows the latency behavior of the example layers on the targeting platform when reducing the number of input and output channels. As we can see, the staircase pattern becomes less obvious as the number of input channel reduces and the GPU has sufficient capacity for the reduced computation. This happens during pruning, especially for large prune ratios. In such a case, the FLOP count reflects the latency more accurately, and the performance gap between reducing FLOPs and reducing latency can possibly become small.
Nevertheless, our method can help avoid some latency peaks as shown in Fig.~\ref{fig:layer_compare_with_eagleeye}, which could otherwise happen using other pruning methods.

\section{Pruning results for small batch size}
In the main paper, we use a large batch $256$ in the experiment to allow for highest throughput for inference, which also makes the latency of the convolution layers show apparent staircase pattern so that we can take full advantage of the latency characteristic. In this section, we show that with small batch size $1$ that no obvious staircase pattern showing up in layer latency, our HALP algorithm still delivers better results compared to other methods.
\begin{table}[!t]
    \centering
    \caption{Pruning ResNet50 on the ImageNet dataset (TITAN V) targeting on inference with batch size $1$. HALP-$X\%$ indicates that $X\%$ latency to remain after pruning. The speedup is calculated as the ratio of FPS between the pruned network and the unpruned model.}
    \label{tab:resnet50_bs1}
    \begin{minipage}{\columnwidth}
    \centering
    \resizebox{0.7\columnwidth}{!}{
    \begin{tabular}{cccccc}
        \toprule
        \multirow{2}{*}{Method} & FLOPs & Top1 Acc & Top5 Acc &  FPS & \multirow{2}{*}{Speedup}\\
         & (G) & (\%) & (\%) & (imgs/s) &\\
        \midrule
        \midrule
         No pruning & $4.1$ & $76.2$ & $92.87$ & $181$ & $1\times$ \\
        \midrule

        $0.75 \times$ ResNet50~\cite{he2015deep} & $2.3$ & $74.8$ & - & $192$ & $1.06\times$ \\
        AutoSlim~\cite{yu2019autoslim} & $2.0$ & $75.6$ & - & $181$ & $1.00\times$  \\
        MetaPruning~\cite{liu2019metapruning} & $2.0$ & $75.4$ & - & $190$ & $1.05\times$ \\
        EagleEye-2G~\cite{li2020eagleeye} & $2.1$ & $76.4$ & $92.89$ & $190$ & $1.05\times$  \\
        GReg-2~\cite{wang2021neural} & $1.8$ & $75.4$ & - & $196$ & $1.09\times$ \\
        \textbf{HALP-$90\%$ (Ours)} & $2.9$ & $\mathbf{76.4}$ & $\mathbf{93.10}$ & $\mathbf{220}$ & $\mathbf{1.22\times}$ \\
        \midrule
        $0.50 \times$ ResNet50~\cite{he2015deep} & $1.1$ & $72.0$ & - & $193$ & $1.07\times$ \\
        AutoSlim~\cite{yu2019autoslim} & $1.0$ & $74.0$ & - & $191$ & $1.06\times$ \\
        MetaPruning~\cite{liu2019metapruning} & $1.0$ & $73.4$ & - & $196$ & $1.09\times$ \\
        EagleEye-1G~\cite{li2020eagleeye} & $1.0$ & $74.2$ & $91.77$ & $192$ & $1.06\times$ \\
        GReg-2~\cite{wang2021neural} & $1.3$ & $73.9$ & - & $206$ & $1.14\times$ \\
        \textbf{HALP-$80\%$ (Ours)} & $2.3$ & $\mathbf{75.3}$ & $\mathbf{92.35}$ & $\mathbf{247}$ & $\mathbf{1.37\times}$ \\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}

\end{table}

When we use batch size $1$ for inference, the layer latency of ResNet50 does not show obvious staircase pattern in most of the layers due to the insufficient usage of GPU. Therefore in this experiment, we use the latency lookup table granularity as a neuron grouping size, which in our case is $2$, to fully exploit the hardware latency traits during pruning. We show our pruned results and the comparison with other methods in Tab.~\ref{tab:resnet50_bs1}. As shown in the table, while other methods reduce the total FLOPs of the network after pruning, they do not reduce the actual latency much, which is up to $1.09\times$ faster than the original one at the cost of $2.8\%$ top1 accuracy drop. Compared to these methods, although we get less FLOPs reduction using our proposed method, the pruned models are faster and get higher accuracy, which is $1.22\times$ faster than the unpruned model while getting slightly higher accuracy and $1.37\times$ faster with only $0.9\%$ accuracy drop.

\section{Pruning results on object detection}
\label{sec:detection_detail}
In this section we show the detailed pruning results on objection detection task for Sec.~\ref{sec:object_detection}. To prune the detector, we first train a SSD512 with ResNet50 as backbone. We also train some other popular models for performance comparison. The detailed numbers of Fig.~\ref{fig:detection_compare} are shown in Tab.~\ref{tab:detection_compare}.

\begin{table}[t]
\caption{HALP for object detection on the PASCAL VOC dataset.
    }
    \label{tab:detection_compare}
    \begin{minipage}{\columnwidth}
    \centering
    \resizebox{0.8\columnwidth}{!}{
    \centering
    \begin{tabular}{ccccccc}
        \toprule
        Model & mAP & FLOPs (G) & params (M) & FPS (BS=1) & FPS (BS=32)\\
        \midrule
        SSD512-RN50, base model & $77.98$ & $65.56$ & $21.97$ & $68.24$ & $103.48$  \\
        \midrule
        SSD512-RN50-slim & $75.83$ & $46.09$ & $16.33$ & $76.49$ & $114.80$ \\
        SSD300-RN50 & $75.69$ & $16.23$ & $15.43$ & $128.85$ & $309.32$ \\
        SSD300-VGG16~\cite{liu2016ssd} & $76.72$ & $31.44$ & $26.29$ & $122.28$ & $262.93$ \\
        FasterRCNN-VGG16~\cite{ren2015faster} & $70.10$ & $91.23$ & $137.08$ & $29.21$ & - \\
        RetinaNet-RN50~\cite{lin2017focal} & $77.27$ & $106.50$ & $36.50$ & $36.92$ & - \\
        \textbf{SSD512-RN50-HALP (Ours)} & $\mathbf{77.42}$ & $\mathbf{15.38}$ & $\mathbf{10.40}$ & $\mathbf{132.57}$ & $\mathbf{323.36}$ \\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
\end{table}

\section{Implementation details}
\label{implementation-details}
\textbf{Convert latency in float to int.} Solving the neuron selection problem using the proposed augmented knapsack solver (Algo. 1 in the main paper), requires the neuron latency contribution and the latency constraint to be integers as shown in line $4$ of the algorithm. To convert the measured latency from a full precision floating-point number to integer type, we multiply the latency by $1000$ and perform rounding. Accordingly, we also scale and round the latency constraint value.

\noindent \textbf{Deal with negative latency contribution.} The neuron latency contribution in our augmented knapsack solver must be a non-negative value since we have $\text{dp\_array}\in \mathbb{R}^C$ and we need to visit $\text{dp\_array}[c - c_n]$ as in line $5$ of Algo. 1 in the main paper. However, by analyzing the layer latency from the look-up table we find that for some layers the measured latency might even increase when reducing some number of neurons. This means that the latency contribution could possibly be negative. The simplest way to deal with the negative values is to directly set the negative latency contributions to be $0$. This leads to the problem that the summed latency contribution would be larger than the actual latency value, causing less neurons being selected. Thus, during our implementation, we keep those negative latency values as they are, but update the vector size of $\text{dp\_array}$ to $\mathbb{R}^{C-\min(\min(\textbf{c}), 0)}$ where $\min(\textbf{c})$ is the minimum latency contribution. With such, the vector size of $\text{dp\_array}$ would be extended when there is negative latency contribution. This makes it possible to add one neuron with negative latency contribution to a subset of neurons whose summed latency is larger than the latency constraint. After the addition, the total latency will still remain  under the constraint.

\noindent \textbf{Pruning of the first layer.} In our ImageNet experiments, we leave the first convolutional layer of ResNets unpruned to help maintain the top-1 classification accuracy. For MobileNet, the first convolutional layer is coupled with its following group convolutional layer. In our MobileNet experiments, we prune the first coupled layers at most to the half of neurons.

\noindent \textbf{SSD for object detection.} Our SSD model is based on ~\cite{liu2016ssd}. When we train SSD-VGG16, we use the exactly same structure as described in the paper. When we train a SSD-ResNet50, the main difference between our model and the model described in the original paper is in the backbone, where the VGG is replaced by the ResNet50. Following~\cite{huang2017speed}, we apply the following enhancements in our backbone:
\begin{itemize}[topsep=1pt,itemsep=1pt,partopsep=0pt, parsep=0pt,leftmargin=\labelwidth]
    \item The last stage of convolution layers, last avgpool and fc layers are removed from the original ResNet50 classification model.
    \item All strides in the $3$rd stage of ResNet50 layers are set to $1\times1$.
\end{itemize}
The backbone is followed by $6$ additional coupled convolution layers for input size $512\times512$, or $5$ for input size $300\times300$. A BatchNorm layer is added after each convolution layer. The settings of these additional convolution layers are listed in Tab.~\ref{tab:ssd_addition_layer}, each layer is represented as (output channel, kernel size, stride, padding).

\begin{table}[t]
    \centering
    \caption{The additional convolution layers in SSD.}
    \resizebox{0.5\columnwidth}{!}{
    \begin{tabular}{cccc}
        \toprule
        layer & SSD512 & SSD512-slim & SSD300 \\
        \midrule
        layer1-conv1 & ($512$, $3$, $1$, $1$) & ($256$, $1$, $1$, $0$) & ($512$, $3$, $1$, $1$)\\
        layer1-conv2 & ($512$, $3$, $2$, $1$) & ($512$, $3$, $2$, $1$) & ($512$, $3$, $2$, $1$)\\
        layer2-conv1 & ($256$, $1$, $1$, $0$) & ($256$, $1$, $1$, $0$) & ($256$, $1$, $1$, $0$)\\
        layer2-conv2 & ($512$, $3$, $2$, $1$) & ($512$, $3$, $2$, $1$) & ($512$, $3$, $2$, $1$)\\
        layer3-conv1 & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$)\\
        layer3-conv2 & ($256$, $3$, $2$, $1$) & ($256$, $3$, $2$, $1$) & ($256$, $3$, $2$, $1$)\\
        layer4-conv1 & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$)\\
        layer4-conv2 & ($256$, $3$, $2$, $1$) & ($256$, $3$, $2$, $1$) & ($256$, $3$, $1$, $0$)\\
        layer5-conv1 & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$)\\
        layer5-conv2 & ($256$, $3$, $2$, $1$) & ($256$, $3$, $2$, $1$) & ($256$, $3$, $1$, $0$)\\
        layer6-conv1 & ($128$, $1$, $1$, $0$) & ($128$, $1$, $1$, $0$) & - \\
        layer6-conv2 & ($256$, $4$, $1$, $1$) & ($256$, $4$, $1$, $1$) & - \\
        \bottomrule
    \end{tabular}
    }
    \label{tab:ssd_addition_layer}
\end{table}
The detector heads are similar to the ones in the original paper. The first detection head is attached to the last layer of the backbone.The rest detection heads are attached to the corresponding additional layers. No additional BatchNorm layer in the detector heads.

\section{FLOPs-constrained pruning}
\label{flops-prune}
Our implementation of latency-constrained pruning can be easily converted to be a FLOPs-constrained. When constraining on FLOPs, $\Phi(\cdot)$ in the objective function (Eq.1 in the main paper) becomes the FLOPs measurement function and $C$ becomes the FLOPs constraint. Since the FLOPs of a layer linearly decreases as the number of neurons decreases in the layer, we do not need to group neurons in a layer any more. The problem can also be solved by original knapsack solver since each neuron's FLOPs contribution in a layer is exactly the same and no preceding constraint is required. We conduct some experiments by constraining the FLOPs and compare the results with EagleEye~\cite{li2020eagleeye}. We name the experiments using the same algorithm as HALP but targeting on optimizing the FLOPs as FLOP-T. As shown in Tab.~\ref{tab:flops-constrained-pruning}, with our pruning framework applying the knapsack solver, our results show higher top-1 accuracy compared to the pruned networks of EagleEye with similar FLOPs remaining. We also observe a larger gap between the methods when it comes to a more compact network.

\begin{table}[!t]
\caption{Pruning ResNet50 on the ImageNet dataset with FLOPs constraint and comparison with state-of-the-art method EagleEye (ECCV'20)~\cite{li2020eagleeye}. We remeasure the FLOPs, top1 and top5 accuracy of EagleEye to get results with two digits.
    }
    \label{tab:flops-constrained-pruning}
    \begin{minipage}{0.48\columnwidth}
    \centering
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{cccc}
            \toprule
            Method & FLOPs (G) & Top1 Acc ($\%$) & Top5 Acc ($\%$) \\
            \midrule
             No pruning & $4.1$ & $77.23$ & $93.70$\\
             \midrule
            EagleEye-3G & $3.08$ & $77.10$ & $93.36$ \\
            \textbf{FLOP-T (Ours)} & $\mathbf{2.99}$ & $\mathbf{77.36}$ & $\mathbf{93.62}$ \\
            \midrule
            EagleEye-2G & $2.06$ & $76.38$ & $92.90$ \\
            \textbf{FLOP-T (Ours)} & $\mathbf{1.95}$ & $\mathbf{\mathbf{76.64}}$ & $\mathbf{93.21}$ \\
            \midrule
            EagleEye-1G & $1.03$ & $74.18$ & $91.78$ \\
            \textbf{FLOP-T (Ours)} & $\mathbf{0.96}$ & $\mathbf{74.84}$ & $\mathbf{92.26}$ \\
            \bottomrule
        \end{tabular}
    }
    \end{minipage}
    \begin{minipage}{0.45\columnwidth}
    \centering
    \includegraphics[scale=0.35]{figures/flops-constrained-pruning}
    \end{minipage}
    \vspace{-2mm}
\end{table}

\section{FLOPs vs. latency}
FLOPs can be regarded as a proxy of inference latency; however, they are not equivalent [4, 33, 35, 40, 42]. We do global filter-wise pruning and have the same problem as NAS. The latency on a GPU usually imposes staircase-shaped patterns for convolutional operators with varying channels and requires pruning in groups. In contrast, FLOPs will change linearly. Depth-wise convolution, compared to dense counterparts, has significantly fewer FLOPs but almost the same GPU latency due to execution being memory-bounded\footnote{\texttt{\scriptsize{https://tlkh.dev/depsep-convs-perf-investigations/}}}.
The discrepancy also holds for ResNets where the same amount of FLOPs impose more latency in earlier layers than later ones as the number of channels increases and feature map dimension shrinks -- both increase compute parallelism. For example, the first $7\times7$ conv layer and the first bottleneck $3\times3$ conv in ResNet50 have nearly identical FLOPs but the former is $60\%$ slower on-chip.

We compare our results of FLOPs-targeted (FLOP-T) showed in Sec.~\ref{flops-prune} and results using latency-targeted pruning (HALP) in Tab.~\ref{tab:flopsT-vs-HALP}. As shown in the table, using different optimization targets leads to quite different FPS vs FLOPs curves. In overall, with similar FLOPs remaining, using our HALP algorithm targeting on reducing the actual latency can get more efficient networks with more image being processed per second.

\begin{table}[t]
\centering
\caption{ResNet50 pruning with FLOPs/latency constrain.
    }
    \label{tab:flopsT-vs-HALP}
    \begin{minipage}{0.82\columnwidth}
    \centering
    \resizebox{.82\columnwidth}{!}{
    \centering
    \begin{tabular}{|c | c c c | c |}
         \hline
         method & Top1(\%) & FLOPs (G) & FPS (imgs/s) & FPS vs FLOPs\\
         \hline
         FLOP-T & $74.84$ & $\mathbf{0.962}$ & $2202$ & \multirow{6}{*}{\includegraphics[scale=0.43]{figures/FlopsT-vs-HALP}}\\
         HALP & $\mathbf{74.92}$ & $1.210$ & $\mathbf{2396}$ & \\
         \cline{1-4}
         FLOP-T & $\mathbf{76.64}$ & $\mathbf{1.949}$ & $1436$ & \\
         HALP & $76.55$ & $1.957$ & $\mathbf{1672}$ &  \\
         \cline{1-4}
         FLOP-T & $77.36$ & $\mathbf{2.988}$ & $1146$ & \\
         HALP & $\mathbf{77.45}$ & $\mathbf{2.988}$ & $\mathbf{1203}$ & \\
         \hline
    \end{tabular}
    }
    \end{minipage}
\end{table}

\begin{wrapfigure}{r}{0.35\textwidth}
\vspace{-6mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.28\textwidth]{figures/layer1.0.conv2.png}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{The measured latency vs. FLOPs of the $2$nd convolution layer in the $1$st residual block of ResNet50.}
  \label{fig:latency_vs_flops}
\end{wrapfigure}
We also show a more straightforward relationship between the actual latency of a layer and its FLOPs in Fig.~\ref{fig:latency_vs_flops}. We use the $2$nd convolution layer in the $1$st residual block of ResNet50 as an example. We vary the number of neurons of the layer from $0$ to $128$ and measure the actual latency on GPU (TITAN V) as well as the FLOPs of the layer. We can see from the figure that the actual latency does not strictly linearly decrease as the FLOPs decreasing.

\section{Different choice of importance calculation}
We use the first Taylor expansion~\cite{molchanov2019importance} to estimate the loss change induced by pruning as the importance score of the neurons. It is a gradient-based importance calculation and is shown to be given promising results. In this section, we use the L2 norm of the neuron weights as the importance measurement and apply HALP framework to ResNet50 ImageNet classification task. As shown in Tab.~\ref{tab:l2_norm_importance_HALP}, Our algorithm is generic applying to different importance measurements. As shown, using L2 norm of weights as importance measurements leads to slightly lower accuracy.
\begin{table}[!h]
    \centering
    \caption{The results of HALP algorithm on ResNet50 ImageNet classification task with different choices of neuron importance measurements.}
    \label{tab:l2_norm_importance_HALP}
    \begin{minipage}{0.8\columnwidth}
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{c |cccc|cccc}
        \toprule
        \multirow{2}{*}{Method} & \multicolumn{4}{c}{First-Taylor Expansion (gradient-based)} & \multicolumn{4}{c}{L2 norm (magnitude-based)} \\
        \cmidrule(lr){2-9}
         & FLOPs(G) & Top1(\%) & Top5(\%) &  FPS(im/s) & FLOPs(G) & Top1(\%) & Top5(\%) &  FPS(im/s) \\
         \midrule
        HALP-$80\%$ & $3.0$ & $77.5$ & $93.60$ & $1203$ &  $3.0$ & $77.3$ & $93.60$ & $1196$ \\
        HALP-$55\%$ & $2.1$ & $76.7$ & $93.16$ & $1672$ & $2.0$ & $75.7$ & $92.66$ & $1595$ \\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
\end{table}

\section{Latency look-up table creation and calibration}
\label{lut_creation}
In this section, we provide additional details to build the latency look-up table used in HALP, computational cost and the correlation between the estimated and the real ones. As mentioned in Appendix~\ref{exp_setting}, we pre-generate the layer latency look-up table on the platform with NVIDIA cuDNN~\cite{chetlur2014cudnn} V7.6.5. For each layer, we iteratively reduce the number of neurons in the layer (each time reduce $8$ neurons) and characterize the corresponding latency. For each latency measurement, we use one profile for GPU warm up and another $3$ profiles and take the average to avoid randomness. The average standard deviation of profiles for an operation is $8.67e^{-3}$.

\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-4mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.5\textwidth]{figures/calibration}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{The correlation between the predicted latency reduction and the real latency reduction of the pruned models.}
  \label{fig:calibration}
\end{wrapfigure}
On a single TITAN V GPU, it takes around $5$ hours to build the look-up table for ResNets family and $1$ hour for MobileNets family. Note that the LUT can be shared by the network architectures within the same family since they usually have similar layer structures. We only need to create the latency look-up table once for all the possible latency targets.

There are some gaps between the predicted latency and the real latency of the model, because the latency look-up table is created layer-wise on convolution layers. There are additional costs in real inference such as pooling, non-linear activation etc. We plot the correlation between the expected latency reduction from look-up table and the real latency reduction ratio of our pruned models in Fig.~\ref{fig:calibration}. We also calculate the Pearson Correlation Coefficient $r$ for all the networks in the figure. We can clearly see a linear correlation between the predicted and real latency reduction from the figure, showing that the latency lookup table provides a good approximation and it is possible to calibrate the latency estimation using the linear coefficient to have a better estimation.

\textbf{Limitation of layer-wise latency lookup table.} We apply layer-wise latency lookup table in our method, which does not consider the caching and parallelization among layers. For networks like VGG without bypass paths, the layer operations will be executed sequentially, in which case, the latency lookup table models the actual latency well. For models with parallel paths, it depends on the hardware implementation whether there will be parallel execution in practice. When there is parallelization, e.g., in accelerators, models like ResNets still work well because the skip connection only takes small portion of computation; for models like InceptionNet, taking the parallelization and into consideration when generating the lookup table would help better estimate the latency. For wider applications in the future, the more domain knowledge we have about the GPU execution and improve accordingly, the more accurate estimation we will obtain using the latency lookup table.

\textbf{Comparison with quadratic model.} Recent work QCQP~\cite{jeong2022optimal} models latency using a quadratic equation and solve a latency constrained optimization problem. The main difference between our estimation from lookup table and the QCQP's estimation from quadratic modeling is that we use different ways to model each layer's latency. QCQP[1] uses $\alpha_l+\beta_l||r^{(l-1)}||_1+\delta_l||r^{(l-1)}||_1||r^{(l)}||_1$ to model the layer latency where $||r||_l$ is the number of remaining channels in the corresponding layer, $\alpha$, $\beta$ and $\delta$ are the coefficients that need to be optimized for the targeting platform. Note that QCQP also needs to profile latency for different samples of each layer, like what we do to create the lookup table but will less samples, in order to optimize $\alpha$, $\beta$ and $\delta$. It is also important to note that QCQP uses a linear model between the layer latency and FLOPs (the quadratic part) and memory. Therefore, QCQP fails to capture the latency staircase pattern (see Fig. 3a in the QCQP paper) which is the key to maximize GPU utilization (see latency surface in Fig.~\ref{fig:pipeline}). As shown in Fig.3a in the QCQP paper, the quadratic modeling gives different latency estimations to layers with different number of input and output channels. However, these layers have the same real inference time. As a result, the larger the number of input and output channels, the larger the error in the estimation of QCQP.

\section{Pruning for INT8 quantization}
\label{prune_for_int8_quantization}
\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-14mm}
  \begin{center}
    \hspace{-0.2cm}\includegraphics[width=0.48\textwidth]{figures/xavier_int8_prune}
  \end{center}
  \vspace{-4mm}
  \captionsetup{font={scriptsize}}
  \caption{The ResNet50 ImageNet pruning targeting INT8 inference on NVIDIA Xavier.}
  \label{fig:int8-prune}
\end{wrapfigure}
We now focus on results when the target is INT8 inference which is a common requirement for real-world applications. In particular, we use NVIDIA Xavier as the target platform as, in this platform, INT8 speedup is supported. We create a INT8 latency look-up table for INT8 inference. For comparison, we also create a FP32 latency look-up table on the same platform and use both look-up tables for pruning a ResNet50 model on ImageNet classification. After convergence, results are quantized into INT8 and the latency and accuracy is measured directly on the Xavier platform. We measure latency with a batch size $128$, using TensorRT (V8.2.0.1) to get INT8 speedup. Results for this experiment are shown in Fig.~\ref{fig:int8-prune}.

 As shown, even use a FP32 latency look-up table as the latency guidance, our method HALP outperforms the state-of-the-art method EagleEye~\cite{li2020eagleeye}. These results are consistent with Sec.~\ref{tensorrt-acceleration} where we show the HALP acceleration on GPUs with TensorRT. Pruning results of using a INT8 look-up table show that our method yields higher accuracy with lower latency on this platform. We obtain a $1.32\times$ speedup while maintaining the original Top1 accuracy. Compared to EagleEye, HALP achieves up to $1.26\times$ relative speedup and $0.15\%$ higher accuracy.

 \section{Breakdown of the algorithm execution time}
\label{execute_breakdown}
We provide additional details of the algorithm process of different methods in this section. We estimate the time cost needed to get the pruned network structure for each method. The time of following finetuning is not taken into consideration. For a fair comparison, we set the number of pruning steps $k$ for all iterative pruning methods to $30$. All the values are approximated as all the methods are running on the same device (a NVIDIA V100 GPU) to get a pruned ResNet50. For AutoSlim~\cite{yu2019autoslim}, MetaPruning~\cite{liu2019metapruning} and AMC~\cite{he2018amc}, more GPU time is needed for additional training of the network.

\begin{table}[!h]
    \centering
    \caption{The breakdown details of the execution process of different methods.}
    \label{tab:method_execution_breakdown}
    \begin{minipage}{\columnwidth}
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{ccccccc}
        \toprule
        \multirow{2}{*}{Method} & Evaluate & Auxiliary net & \multirow{2}{*}{Sub-network selection}  & \multirow{2}{*}{Additional time cost} & Estimate \\
        & proposals? & training? & & & time (RN50) \\
        \midrule
        \multirow{2}{*}{NetAdapt} & \multirow{2}{*}{Y} & \multirow{2}{*}{N} & $N$ candidates evaluation + finetune after each prune. & \multirow{2}{*}{Latency look-up table creation} & \multirow{2}{*}{$\sim195$h GPU}\\
        & & & Repeat $k$ times \\
        \cmidrule(lr){4-6}
        \multirow{2}{*}{ThiNet} & \multirow{2}{*}{Y} & \multirow{2}{*}{N} & $1$ or $2$ train epochs after each pruning. & \multirow{2}{*}{Additional forward pass to get neuron importance} & \multirow{2}{*}{$\sim210$h GPU}\\
        & & & Repeat $k$ times \\
        \cmidrule(lr){4-6}
        EagleEye & Y & N & $1000$ candidates evaluation & Monte Carlo sampling, prune to get $1000$ candidates & $30$h GPU\\
        \cmidrule(lr){4-6}
        \multirow{2}{*}{AutoSlim} & \multirow{2}{*}{Y} & \multirow{2}{*}{Y} & Train slimmable model &  & \\
        & & & $k$ candidates evaluation & & \\
        \cmidrule(lr){4-6}
        \multirow{2}{*}{MetaPruning} & \multirow{2}{*}{Y} & \multirow{2}{*}{Y} & Train an auxiliary network & \\
        & & & $k$ candidates evaluation & \\
        \cmidrule(lr){4-6}
        AMC & N & Y &  Train an RL agent &\\
        \midrule
        \multirow{2}{*}{HALP(\textbf{Ours})} & \multirow{2}{*}{\textbf{N}} & \multirow{2}{*}{\textbf{N}} & $40$ train iterations after each pruning. & Augmented Knapsack solver ($\sim30$min in total) & $6.5$h GPU\\
        & & & Repeat $30$ times. ($< 1$ train epoch in total) & Latency look-up table creation & $0.5$h CPU\\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
\end{table}

\section{Difference with prior work}
KnapsackPruning (KP)~\cite{aflalo2020knapsack} is one work that is mostly close to our method in the paper. While both works look at similar problems from the same combinatorial perspective, there are several key differences.  First, KP focuses on constraining FLOPs and shows an instantiation on latency; in contrast, we directly optimize the latency, which is more practical. Second, we show the latency characterization on device and augment the original knapsack problem formulation accordingly, Eq.~\ref{modified_optimization}, to accommodate to the latency traits - the neuron latency is dependent on the order of neuron pruning in a layer, while KP uses a standard knapsack where the neuron FLOP cost is independent of each other. Please note here that the formulation in KP assumes the independence thus can not directly apply to the latency-targeted pruning, Third, we are the first ones to use the latency-aware grouping which assigns different grouping sizes to each layer according to the latency traits rather than predefined fixed values.

For a fair comparison of pruning to the KP method, we use the PyTorch baseline as unpruned model and both without knowledge distillation during training. The results for ResNet50 pruning on ImageNet are show as Tab.~\ref{tab:compare_to_kp}. As shown, our method performs significantly better leading to pruned model with higher accuracy but less FLOPs. On the other side, as they are not considering the actual latency, the resultant network structure is not GPU friendly and would fail to maximize the GPU utilization.

\begin{table}[h]
    \centering
    \caption{ResNet50 pruning results on ImageNet comparison with Knapsack Pruning~\cite{aflalo2020knapsack}.}
    \begin{minipage}{0.5\columnwidth}
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{cccc}
        \toprule
        Method & FLOPs (G) & Top1 ($\%$) & Acc Drop ($\%$)  \\
        \midrule
        KP~\cite{aflalo2020knapsack} & $2.38$ & $76.17$ & $0.03$  \\
        KP~\cite{aflalo2020knapsack} & $2.03$ & $75.94$ & $0.21$ \\
        \textbf{HALP (Ours)} & $\mathbf{2.01}$ & $\mathbf{76.46}$ & $\mathbf{-0.26}$ \\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
    \label{tab:compare_to_kp}
\end{table}

 \section{Detailed configuration of pruned models}
\label{detailed-structure}
We provide the detailed configuration of our pruned models of Tab.~\ref{tab:latency-ware-result-compare}. For each model, we list the number of neurons remaining in each convolution layer, starting from the input to the output. For ResNets we use $[\cdot]$ to denote a residual block and $(\cdot)$ to denote the neuron number of the residual bypass layer.

Note that for ResNets, the configuration is the ``raw'' configuration after the pruning. For each residual block $[x_1, x_2, x_3]$, because of the existing of bypass layer, we allow the entire layer pruning and it still leads to trainable networks. Whenever there is entire layer pruning ($x_1 == 0$ or $x_2 == 0$ or $x_3 == 0$), all the other layers in the block can be removed and this branch can be replaced by a constant value. In such a case, the corresponding block in our final pruned model is cleaned to be $[0, 0, 0]$.
We also provide the detailed structure plot of two pruned ResNet50 models in Fig.~\ref{fig:strucure_visualization} for a better visualization.

\begin{table}[!h]
    \centering
    \caption{The detailed configuration of the HALP pruned models.}
    \label{tab:detailed_structure}
    \begin{minipage}{\columnwidth}
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{ll}
        \toprule
        \multicolumn{2}{c}{ResNet50 - EagleEye~\cite{li2020eagleeye} baseline}  \\
        \multirow{2}{*}{HALP-$80\%$} & $64, [64, 32, 256] (256), [32, 32, 256], [0, 32, 256], [128, 128, 512] (512), [64, 96, 512], [64, 128, 512],[ 64, 128, 512], [256, 256, 1024] (1024), [256, 160, 1024],$\\
         & $[256, 160, 1024], [256, 160, 1024], [256, 128, 1024], [256, 160, 1024], [512, 512, 2048] (2048), [448, 416, 2048], [512, 512, 2048]$ \\
         \cmidrule(lr){2-2}
        \multirow{2}{*}{HALP-$45\%$} & $64, [64, 32, 128] (128), [32, 0, 128], [0, 32, 128], [64, 64, 384] (384), [64, 96, 384], [32, 96, 384], [64, 128, 384], [256, 192, 1024] (1024), [128, 96, 1024], $\\
        & $[256, 64, 1024], [256, 96, 1024], [128, 32, 1024], [256, 96, 1024], [512, 448, 2048] (2048), [416, 288, 2048], [512, 352, 2048]$ \\
        \cmidrule(lr){2-2}
        \multirow{2}{*}{HALP-$30\%$} & $64, [0, 0, 64] (64), [0, 0, 64], [0, 32, 64], [64, 64, 256] (256), [64, 64, 256], [64, 128, 256], [64, 96, 256], [256, 64, 896] (896), [128, 64, 896], [0, 0, 896], $\\
        & $[128, 64, 896], [0, 0, 896], [0, 0, 896], [512, 320, 2048] (2048), [320, 160, 2048], [480, 160, 2048]$ \\
        \midrule

        \multicolumn{2}{c}{ResNet101} \\
        \multirow{4}{*}{HALP-$60\%$} & $64, [64, 32, 192](192), [32, 32, 192], [64, 32, 192], [64, 128, 384](384), [64, 96, 384], [96, 96, 384], [128, 128, 384], [256, 256, 896](896), [256, 96, 896], $\\
        & $[256, 128, 896], [256, 96, 896], [256, 96, 896], [256, 128, 896], [256, 96, 896], [256, 96, 896], [256, 96, 896], [256, 96, 896], [256, 64, 896], [256, 64, 896], $\\
        & $[256, 96, 896], [256, 64, 896], [256, 64, 896], [256, 96, 896], [256, 64, 896], [256, 96, 896], [256, 96, 896], [256, 96, 896], [256, 64, 896], [256, 128, 896], $\\
        & $[256, 64, 896], [512, 512, 2048](2048), [512, 448, 2048], [512, 480, 2048]$\\
        \cmidrule(lr){2-2}
        \multirow{4}{*}{HALP-$50\%$} & $64, [64, 32, 128](128), [0, 32, 128], [64, 32, 128], [64, 128, 384](384), [32, 32, 384], [128, 96, 384], [128, 96, 384], [256, 256, 896](896), [256, 96, 896], $\\
        & $[256, 96, 896], [256, 96, 896], [256, 64, 896], [256, 96, 896], [256, 95, 896], [256, 96, 896], [256, 64, 896], [256, 64, 896], [0, 0, 896], [0, 0, 896], [256, 64, 896], $ \\
        & $[0, 0, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], [256, 64, 896], $\\
        & $[512, 512, 2048](2048), [480, 416, 2048], [512, 416, 2048]$\\
        \cmidrule(lr){2-2}
        \multirow{4}{*}{HALP-$40\%$} & $64, [64, 32, 128](128), [0, 32, 128], [0, 0, 128], [64, 128, 384](384), [32, 64, 384], [64, 96, 384], [64, 128, 384], [256, 256, 896](896), [0, 64, 896], [128, 96, 896], $\\
        & $[0, 64, 896], [0, 64, 896], [128, 64, 896], [128, 64, 896], [0, 0, 896], [0, 0, 896], [128, 96, 896], [128, 64, 896], [256, 96, 896], [256, 64, 896], [256, 64, 896], $\\
        & $[128, 32, 896], [128, 64, 896], [0, 0, 896], [0, 0, 896], [256, 64, 896], [256, 64, 896], [256, 96, 896], [256, 64, 896], [256, 96, 896], [512, 512, 2048](2048), $\\
        &$[512, 352, 2048], [512, 352, 2048]$ \\
        \cmidrule(lr){2-2}
        \multirow{4}{*}{HALP-$30\%$} & $64, [64, 32, 128](128), [0, 0, 128], [0, 0, 128], [64, 128, 256](256), [0, 96, 256], [64, 96, 256], [64, 128, 256], [256, 192, 768](768), [0, 64, 768], [128, 64, 768], $\\
        & $[0, 64, 768], [0, 64, 768], [128, 64, 768], [128, 64, 768], [0, 0, 768], [0, 0, 768], [128, 64, 768], [128, 96, 768], [256, 64, 768], [0, 0, 768], [0, 0, 768], [128, 32, 768],$\\
        & $ [128, 64, 768], [128, 64, 768], [128, 64, 768], [0, 0, 768], [0, 0, 768], [256, 64, 768], [256, 0, 768], [256, 64, 768], [512, 512, 2048](2048), [480, 288, 2048], $\\
        & $[480, 256, 2048]$ \\
        \midrule

        \multicolumn{2}{c}{MobileNet-V1} \\
        HALP-$60\%$ & $896, 14, 14, 32, 32, 64, 64, 64, 64, 192, 192, 192, 192, 384, 384, 320, 320, 384, 384, 384, 384, 384, 384, 448, 448, 960, 960$ \\
        \cmidrule(lr){2-2}
        HALP-$42\%$ & $832, 16, 16, 32, 32, 32, 32, 32, 32, 64, 64, 128, 128, 320, 320, 256, 256, 256, 256, 256, 256, 320, 320, 320, 320, 896, 896$\\
        \midrule

        \multicolumn{2}{c}{MobileNet-V2} \\
        \multirow{2}{*}{HALP-$75\%$} &  $16, 16, 16, 64, 64, 24, 64, 64, 24, 112, 112, 32, 128, 128, 32, 128, 128, 32, 192, 192, 64, 384, 384, 64, 352, 352, 64, 352, 352, 64, 384, 384, 96, 512, 512, 96, $\\
        & $512, 512, 96, 576, 576, 160, 960, 960, 160, 960, 960, 160, 960, 960, 320, 1280$\\
        \cmidrule(lr){2-2}
        \multirow{2}{*}{HALP-$60\%$} & $16, 16, 8, 32, 32, 16, 16, 16, 16, 64, 64, 32, 32, 32, 32, 64, 64, 32, 176, 176, 64, 288, 288, 64, 320, 320, 64, 320, 320, 64, 384, 384, 96, 448, 448, 96, 448, 448, 96, $\\
        & $576, 576, 160, 960, 960, 160, 960, 960, 160, 960, 960, 192, 1152$\\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
\end{table}

\begin{figure}[t]
    \centering
    \begin{minipage}{\columnwidth}
    \resizebox{\columnwidth}{!}{
    \includegraphics{figures/RN50_45_structure.pdf}
    }
    \subcaption{ResNet50 HALP-$45\%$}
    \end{minipage}
    \begin{minipage}{\columnwidth}
    \resizebox{\columnwidth}{!}{
    \includegraphics{figures/RN50_70_structure.pdf}
    }
    \subcaption{ResNet50 HALP-$30\%$}
    \end{minipage}
    \caption{Visualization of the pruned ResNet50 structure. }
    \label{fig:strucure_visualization}
\end{figure}

\section{Discussion on the augmented knapsack solver}
Our augmented knapsack solver in Algo.~\ref{modified-knapsack-solution} is modified based on the standard dynamic programming solution for the 0-1 knapsack problem~\cite{andonov2000unbounded, martello1999dynamic, martello1990knapsack}. With the original 0-1 knapsack problem formulation, each neuron can be selected to be removed or kept independently. However, the fact is that 1). the layer always has the same latency with the same number of channels remaining no matter which neurons are selected; 2). the neurons with higher importance are favored to maximize the accuracy. So in this latency-aware pruning problem, we add an additional constraint, namely, each neuron can be selected only when all the more importance neurons in the same layer are already kept, leading to Eq.~\ref{modified_optimization}. The original solution is modified in lines 6-9 in Algo.~\ref{modified-knapsack-solution} accordingly, and is converted into a greedy approximation selection to retain the same time complexity as the original problem. We'll discuss the non-greedy solution later.

In the augmented solver lines 6-9, every time when we decide whether to keep a neuron, we not only compare the total importance score can be reached under the constraint, but also check the inclusion of the ``preceding'' neurons. This is a greedy selection as it does not consider the potential importance value that the following neurons in the same layer would bring if the current neuron is kept. The overall time complexity of the solution is $O(N\times C)$ where $N=\sum_{l=1}^L N_l$ is the total number of neuron groups in the network and $C$ is the latency constraint. We also provide the non-greedy solution in Algo.~\ref{optimal-dp-solution}. In this solution, for each neuron we add a process calculating and comparing the potential importance score that the layer would further bring if the current neuron is selected to be kept. This brings additional $O(N_l)$ complexity for each neuron in layer $l$. As a result, the total time complexity of the solution increases to $O(\sum_{l=1}^L N_l^2\times C)$. We test both of the solutions and observe similar performance in the ImageNet experiments as shown in Tab.~\ref{solver-cmp}. We hypothesize that the efficacy of the greedy approach suffices from the already decreasingly ranked neurons feeding into the solver and the iterative nature during pruning. Thus, the greedy approximation solution Algo.~\ref{modified-knapsack-solution} is applied in our method to have a better pruning efficiency.
\begin{algorithm}[!t]
     \tiny
    \caption{Non-greedy solution for Eq.~\ref{modified_optimization}}
    \label{optimal-dp-solution}
    \textbf{Input:} Importance score $\{\mathcal{I}_l \in \mathbb{R}^{N_l}\}_{l=1}^L$ where $\mathcal{I}_l$ is sorted descendingly; Neuron latency contribution $\{c_l\in \mathbb{R}^{N_l} \}_{l=1}^L$; Latency constraint $C$.
    \begin{algorithmic}[1]
        \State $\text{maxV} \in \mathbb{R}^{(C+1)}$, $\text{keep} \in \mathbb{R}^{L\times (C+1)}$ \Comment{maxV[$c$]: max importance under constraint $c$; keep[$l$, $c$]: \# neurons to keep in layer $l$ to achieve maxI[$c$]}
        \For{$l = 1, \dots, L$}
        \For{$j = 1, \dots, N_l$}
            \For{$c = 1, \dots, C$}
                \State $v_{keep} = \mathcal{I}_l^j + \text{maxV}[c - c_l^j]$, \ $v_{prune} = \text{maxV}[c]$ \Comment{total importance can achieve under constraint $c$ with object $n$ being kept or not}
                \State flag = False
                \For{$p_l = j+1, \dots, N_l$}
                    \State $v_{potential} = \sum_{j'=j}^{p_l}\mathcal{I}_l^{j'} + \text{maxV}[c-\sum_{j'=j}^{p_l}c_l^{j'}]$ \Comment{calculate the potential score this layer would bring if keep this neuron.}
                    \If{$v_{potential} > v_{prune}$ \textbf{and} $\text{keep}[l, c-c_l^j] == j-1$} \Comment{check if leads to higher score and more important neurons in layer are kept}
                    \State flag = True
                    \State break
                    \EndIf
                \EndFor

                \If{flag == True}
                    \State $\text{keep}[l, c] = j$, \ $\text{update\_maxV}[c]=v_{keep}$
                \Else
                    \State $\text{keep}[l, c] = \text{keep}[l, c-1]$, \ $\text{update\_maxV}[c]=v_{prune}$
                \EndIf
            \EndFor
            \State $\text{maxV} \leftarrow \text{update\_maxV}$
        \EndFor
        \EndFor \\

        \State $\text{keep\_n} = \O$ to save the kept neurons in model

        \For{$l = L, \dots, 1$}  \Comment{retrieve the set of kept neurons}
            \State $p_l = \text{keep}[l, C]$
            \State $\text{keep\_n}
            \leftarrow \text{keep\_n} \cup \{p_l \ \text{top ranked neurons in layer} \ l\}$
            \State $C
            \leftarrow C - \sum_{j=1}^{p_l}c_l^j$
        \EndFor
    \end{algorithmic}
    \textbf{Output:} Kept important neurons ($\text{keep\_n}$).
\end{algorithm}

\begin{table}[h]
    \centering
    \caption{ResNet50 pruning results on ImageNet with the greedy method Algo.~\ref{modified-knapsack-solution} and non-greedy method Algo~\ref{optimal-dp-solution}}
    \label{solver-cmp}
    \begin{minipage}{0.8\columnwidth}
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{c|cc|cc|cc}
        \toprule
        \multirow{2}{*}{Method} & \multicolumn{2}{c}{1G model} & \multicolumn{2}{c}{2G model} & \multicolumn{2}{c}{3G model}  \\
        & Algo.~\ref{modified-knapsack-solution} & Algo.~\ref{optimal-dp-solution} & Algo.~\ref{modified-knapsack-solution} & Algo.~\ref{optimal-dp-solution} & Algo.~\ref{modified-knapsack-solution} & Algo.~\ref{optimal-dp-solution} \\
        \midrule
        Top1 (\%) & $77.45$ & $77.51$ & $76.56$ & $76.51$ & $74.45$ & $74.51$\\
        FPS (img/s) & $1203$ & $1185$ & $1672$ & $1688$ & $2597$ & $2524$\\
        \bottomrule
    \end{tabular}
    }
    \end{minipage}
    \label{tab:compare_to_kp}
\end{table}
\section*{References}

redpajama_set_name: RedPajamaArXiv