
\section{Problem Statement, Training Data and Evaluation Protocol}
\label{sec:accel}
Our template-based parameterization maps the accelerator, denoted as ${\mathbf{x}}$, to a discrete design space, ${\mathbf{x}} = [{\mathbf{x}}_1, {\mathbf{x}}_2, \cdots, {\mathbf{x}}_K]$, and each ${\mathbf{x}}_i$ is a discrete-valued variable representing one component of the microarchitectural template, as shown in Table~\ref{tab:arch_params} (See Appendix~\ref{sec:dla_shi_fast} for the description of other accelerator search spaces studied in our work).
A design maybe be infeasible due to various reasons, such as a compilation failure or the limitations of physical implementation, and we denote the set of all such feasibility criterion as $\mathrm{Feasible}({\mathbf{x}})$.
The feasibility criterion depends on both the target software and the underlying hardware, and it is not easy to identify if a given ${\mathbf{x}}$ is infeasible without explicit simulation. 
We will require our optimization procedure to not only learn the value of the objective function but also to learn to navigate through a sea of infeasible solutions to high-performing feasible solutions ${\mathbf{x}}^*$ satisfying $\mathrm{Feasible}({\mathbf{x}}^*) = 1$. 

Our training dataset $\mathcal{D}$ consists of a modest set of accelerators ${\mathbf{x}}_i$ that are randomly sampled from the design space and evaluated by the hardware simulator.
We partition the dataset $\mathcal{D}$ into two subsets, $\mathcal{D}_\text{feasible}$ and $\mathcal{D}_\text{infeasible}$.
Let $f({\mathbf{x}})$ denote the desired objective (e.g., latency, power, etc.) we intend to optimize over the space of accelerators ${\mathbf{x}}$. We do not possess functional access to $f({\mathbf{x}})$, and the optimizer can only access $f({\mathbf{x}})$ values for accelerators ${\mathbf{x}}$ in the feasible partition of the data, $\mathcal{D}_\text{feasible}$.
For all infeasible accelerators, the simulator does not provide any value of $f({\mathbf{x}})$.
In addition to satisfying feasibility, the optimizer must handle explicit constraints on parameters such as area and power~\citep{flynn2011computer}.
In our applications, we impose an explicit area constraint, $\mathrm{Area}({\mathbf{x}}) \leq \alpha$, though additional explicit constraints are also possible. 
To account for different constraints, we formulate this task as a constrained optimization problem.
Formally:  
\begin{equation}
\label{eqn:opt_prob}
\vspace{-0.2cm}
\begin{aligned}
\min_{{\mathbf{x}}}~ & f({\mathbf{x}})
~~~\textrm{s.t.}~~~\mathrm{Area}({\mathbf{x}}) \leq \alpha, ~~~ \mathrm{Feasible}({\mathbf{x}}) = 1 \\
\quad &~\text{on}~~ \mathcal{D} = \mathcal{D}_\text{feasible} \cup \mathcal{D}_\text{infeasible} = \{({\mathbf{x}}_1, {\mathbf{y}}_1), \cdots, ({\mathbf{x}}_N, {\mathbf{y}}_N)\} \cup \{{\mathbf{x}}'_1, \cdots, {\mathbf{x}}'_{N'}\}
\end{aligned}
\end{equation}
While Equation~\ref{eqn:opt_prob} may appear similar to other standard black-box optimization problems, solving it over the space of accelerator designs is challenging due to the large number of infeasible points, the need to handle explicit design constraints, and the difficulty in navigating the non-smooth landscape (See Figure~\ref{fig:ds_dist_all} and Figure~\ref{fig:appx_ds} in the Appendix) of the objective function.
\input{tables/arch_params}

\niparagraph{What makes optimization over accelerators challenging?}
Compared to other domains where model-based optimization methods have been applied~\citep{brookes19a,trabucco2021conservative}, optimizing accelerators introduces a number of practical challenges.
First, accelerator design spaces typically feature a narrow manifold of feasible accelerators within a sea of infeasible points~\citep{prac_dse:mascots:2019,shi2020learned,gelbart2014bayesian}, as visualized in Figure~\ref{fig:ds_dist_all} and Appendix (Figure~\ref{fig:tsne_infeasible}).
While some of these infeasible points can be identified via simple rules (e.g. estimating chip area usage), most infeasible points correspond to failures during compilation or hardware simulation. These infeasible points are generally not straightforward to formulate into the optimization problem and requires simulation~\citep{shi2020learned,timeloop,yazdanbakhsh2021apollo}.

Second, the optimization objective can exhibit high sensitivity to small variations in some architecture parameters (Figure~\ref{fig:appx_ds_memory}) in some regions of the design space, but remain relatively insensitive in other parts, resulting in a complex optimization landscape. This suggests that optimization algorithms based on local parameter updates (e.g., gradient ascent,  evolutionary schemes, etc.) 
\begin{wrapfigure}{r}{0.35\textwidth}
    \vspace{-0.25cm}
    \centering
    \begin{minipage}{\linewidth}
    \includegraphics[width=1.0\linewidth]{figs/dataset/dist.png}
    \vspace{-0.1cm}
    \label{fig:ds_dist}\par\vfill
    \includegraphics[width=1.0\linewidth]{figs/dataset/dist_large.png}
    \label{fig:ds_dist_large}
    \end{minipage}
    \vspace{-0.2cm}
    \caption{\textbf{Top:} histogram of infeasible (right orange bar with large score values) and feasible (left cluster of bars) data points; \textbf{Bottom:} zoomed-in histogram focused on feasible points highlighting the variable latencies.}
    \vspace{-0.7cm}
    \label{fig:ds_dist_all}
\end{wrapfigure}
may have a challenging task traversing the nearly flat landscape of the objective, which can lead to poor performance.

\niparagraph{Training dataset.}
We used an offline dataset $\mathcal{D}$ of (accelerator parameters, latency) via random sampling from the space of 452M possible accelerator configurations.
Our method is only provided with a relatively modest set of feasible points ($\leq 8000$ points) for training, and these points are the \emph{worst-performing} feasible points across the pool of randomly sampled data.
This dataset is meant to reflect an easily obtainable and an application-agnostic dataset of accelerators that could have been generated once and stored to disk, or might come from real physical experiments. 
We emphasize that no assumptions or domain knowledge about the application use case was made during dataset collection.
Table~\ref{tab:models} depicts the list of target applications, evaluated in this work, includes three variations of MobileNet~\citep{edgetpu:arxiv:2020,mnv2:arxiv:2018,mnv3:cvpr:2019}, three in-house industry-level models for object detection (M4, M5, M6; names redacted to prevent anonymity violation), a U-net model~\citep{unet}, and two RNN-based encoder-decoder language models~\citep{trnn01,trnn02,trnn03,trnn04}. 
These applications span the gamut from small models, such as \msix, with only 0.4~MB model parameters that demands less on-chip memory, to the medium-sized models ($\geq$~5~MB), such as MobileNetV3 and \mfour models, and large models ($\geq$~19~MB), such as t-RNNs, hence requiring larger on-chip memory. 
\input{tables/models}

\niparagraph{Evaluation protocol.}
To compare state-of-the-art simulator-driven methods and our data-driven method, we limit the number of feasible points (costly to evaluate) that can be used by any algorithm to equal amounts. 
We still provide infeasible points to any method and leave it up to the optimization method to use it or not.
This ensures our comparisons are fair in terms of the amount of data available to each method.
However, it is worthwhile to note that in contrast to our method where \emph{worse-quality} data points from small offline dataset are used, the simulator-driven methods have an inherent advantage because they can steer the query process towards the points that are more likely to be better in terms of performance.
Following prior work~\citep{brookes19a,trabucco2021conservative,trabucco2021designbench}, we evaluate each run of a method by first sampling the top $n=256$ design candidates according to the algorithm's predictions, evaluating all of these under the ground truth objective function and recording the performance of the best accelerator design.
The final reported results is the median of ground truth objective values across five independent runs.
\section{Background on Hardware Accelerators}
\label{sec:background}
The goal of specialized hardware accelerators---Google TPUs~\citep{jouppi2017datacenter,edgetpu:arxiv:2020}, Nvidia GPUs~\citep{nvidia}, GraphCore~\citep{graphcore}---is to improve the performance of specific applications, such as machine learning models. To design such accelerators, architects typically create a parameterized design and sweep over parameters using simulation. In this section, we will provide an overview of hardware accelerators, present the design of our template-based accelerator and explain how an accelerator works.

\begin{wrapfigure}{r}{0.4\textwidth}
    \centering
    \vspace{-0.2in}
    \includegraphics[width=\linewidth]{figs/accelerator/template-accel.png}
   
    \caption{An industry-level machine learning accelerator~\cite{yazdanbakhsh2021evaluation}.}
    \label{fig:template_accel}
    \vspace{-0.4cm}
    \label{fig:accels}
\end{wrapfigure}
\niparagraph{Target hardware accelerators.}
Our primary evaluation uses an industry-grade and highly parameterized template-based accelerator following prior work~\citep{yazdanbakhsh2021evaluation}.
This template enables architects to determine the organization of various components, such as compute units, memory cells, memory, etc., by searching for these configurations in a discrete design space. Some ML applications may have large memory requirements (e.g., large language models~\citep{brown2020language}) demanding sufficient on-chip memory resources, while others may benefit from more compute blocks. The hardware design workflow directly selects the values of these parameters.
In addition to this accelerator and to further show the generality of our method to other accelerator design problems, we evaluate two distinct dataflow accelerators with different search spaces, namely NVDLA-style~\citep{nvdla} and ShiDianNao-style~\citep{shidiannao} from~\citet{kao2020confuciux} (See Section~\ref{sec:eval} and Appendix~\ref{sec:dla_shi_fast} for a detailed discussion; See Table~\ref{table:dla_shi} for results).

\niparagraph{How does an accelerator work?}
We briefly explain the computation flow on our template-based accelerators (Figure~\ref{fig:template_accel}) and refer the readers to Appendix~\ref{sec:dla_shi_fast} for details on other accelerators.
This template-based accelerator is a 2D array of processing elements (PEs). Each PE is capable of performing matrix multiplications in a single instruction multiple data (SIMD) paradigm~\citep{simd}. A controller orchestrates the data transfer (both activations and model parameters) between off-chip DRAM memory and the on-chip buffers and also reads in and manages the instructions (e.g. convolution, pooling, etc.) for execution. The computation stages on such accelerators start by sending a set of activations to the compute lanes, executing them in SIMD manner, and either storing the partial computation results or offloading them back into off-chip memory.
Compared to prior works~\citep{hegdemind,shidiannao,kao2020confuciux}, this parameterization is unique---it includes multiple compute lanes per each PE and enables SIMD execution model within each compute lane---and yields a distinct accelerator search space accompanied by an end-to-end simulation framework.
Appendix~\ref{sec:dla_shi_fast} elaborates on other accelerators evaluated in this work.
\section{Related Work}
\label{sec:related}
Optimizing hardware accelerators has become more important recently. Prior works~\citep{bo:frontiers:2020,flexibo:arxiv:2020,cnn_gen:cyber:2020,prac_dse:mascots:2019,accel_gen:dac:2018,spatial:pldi:2018,automomml:hpc:2016,opentuner:pact:2014,hegdemind} mainly rely on expensive-to-query hardware simulators to navigate the search space. For example, HyperMapper~\citep{prac_dse:mascots:2019} targets compiler optimization for FPGAs by continuously interacting with the simulator in a design space with relatively few infeasible points.
Mind Mappings~\citep{hegdemind}, optimizes software mappings to a fixed hardware provided access to millions of feasible points and throws away infeasible points during learning.
\citet{kao2020confuciux} utilizes reinforcement learning against a simulator to optimize the parameters of a set of simple accelerators.
In contrast, our data-driven approach, \methodname~, not only learns a conservative surrogate using offline data but can also effectively leverage information from the large number of infeasible points and is effective with just a few thousand feasible points.
In addition, to the best of our knowledge, our work, is the first to demonstrate generalization to unseen applications for accelerator design, outperforming state-of-the-art online methods.

A popular approach for solving black-box optimization problems is model-based optimization (MBO)~\citep{snoek15scalable,shahriari2016TakingTH,snoek2012practical}.
Most of these methods fail to scale to high-dimensions, and have been extended with neural networks~\citep{snoek15scalable,snoek2012practical,kim2018attentive,garnelo18neural,garnelo18conditional,angermueller2020population,angermueller2019model,mirhoseini2020chip}. While these methods work well in the active setting, they are susceptible to out-of-distribution inputs~\citep{trabucco2021designbench} in the offline, data-driven setting.
To prevent this, offline MBO methods that constrain the optimizer to the manifold of valid, in-distribution inputs have been developed~\citet{brookes19a,fannjiang2020autofocused,kumar2019model}.
However, modeling the manifold of valid inputs can be challenging for accelerators. \methodname\ dispenses with the need for generative modeling, while still avoiding out-of-distribution inputs. \methodname\  builds on ``conservative'' offline RL and offline MBO methods that train robust surrogates~\citep{kumar2020conservative,trabucco2021conservative}. However, unlike these approaches, \methodname\ can handle constraints by learning from infeasible data and utilizes a better optimizer (See Appendix Table~\ref{table:coms_vs_prime} for a comparison).
In addition, while prior works area mostly restricted to a single application, we show that \methodname\ is effective in multi-task optimization and zero-shot generalization.

\section{Discussion}
\label{sec:discussion}
In this work, we present a data-driven offline optimization method, \methodname\ to automatically architect hardware accelerators. Our method learns a conservative surrogate of the objective function by leveraging  infeasible data points to better model the desired objective function of the accelerator using a one-time collected dataset of accelerators, thereby alleviating the need for time-consuming simulation.
Our results show that, on average, our method outperforms the best designs observed in the logged data by 2.46$\times$ and improves over the best simulator-driven approach by about 1.54$\times$. 
In the more challenging setting of designing accelerators jointly optimal for multiple applications or for new, unseen applications, zero-shot, \methodname\ outperforms simulator-driven methods by 1.2$\times$, while reducing the total simulation time by 99\%.

{At a high level, the efficacy of \methodname\ highlights the potential for utilizing the logged offline data in conjunction with strong offline methods in an accelerator design pipeline. While \methodname, in principle, can itself be used in the inner loop of an online method that performs active data collection beyond an initial offline dataset, the strong generalization ability of neural networks when trained with good offline methods and offline datasets consisting of low-performing designs, can serve as a highly effective ingredient for multiple design problems. Utilizing \methodname\ for other problems in architecture and systems, such as software-hardware co-optimization is an interesting avenue for future work.}

\section*{Acknowledgements}
We thank the ``Learn to Design Accelerators'' team at Google Research and the Google EdgeTPU team for their invaluable feedback and suggestions.
In addition, we extend our gratitude to the Vizier team, Christof Angermueller, Sheng-Chun Kao, Samira Khan, Stella Aslibekyan, and Xinyang Geng for their help with experiment setups and insightful comments.
\section{Introduction}
\label{sec:intro}
The death of Moore's Law~\citep{esmaeilzadeh2011dark} and its spiraling effect on the semiconductor industry have driven the growth of specialized hardware accelerators. These specialized accelerators are tailored to specific applications~\citep{yazdanbakhsh2021apollo,reagen2017case,prac_dse:mascots:2019,shi2020learned}. To design specialized accelerators, designers first spend considerable amounts of time developing simulators that closely model the real accelerator performance, and then optimize the accelerator using the simulator. While such simulators can automate accelerator design, this requires a large number of simulator queries for each new design, both in terms of simulation time and compute requirements, and this cost increases with the size of the design space~\citep{yazdanbakhsh2021evaluation,shi2020learned,hegdemind}.
Moreover, most of the accelerators in the design space are typically infeasible~\citep{hegdemind,yazdanbakhsh2021apollo} because of build errors in silicon or compilation/mapping failures. 
When the target applications change or a new application is added, the complete simulation-driven procedure is generally repeated.
To make such approaches efficient and practically viable, designers typically ``bake-in'' constraints or otherwise narrow the search space, but such constraints can leave out high-performing solutions~\citep{dmazerunner,timeloop,marvel}.

An alternate approach, proposed in this work, is to devise a \textit{data-driven} optimization method that only utilizes a database of previously tested accelerator designs, annotated with measured performance metrics, to produce new optimized designs \emph{without} additional active queries to an explicit silicon or a cycle-accurate simulator.
Such a data-driven approach provides three key benefits: \textbf{(1)} it significantly shortens the recurring cost of running large-scale simulation sweeps, \textbf{(2)} it alleviates the need to explicitly bake in domain knowledge or search space pruning, and {\textbf{(3)} it enables data re-use by empowering the designer to optimize accelerators for new unseen applications, by the virtue of effective generalization.}
While data-driven approaches have shown promising results in biology~\citep{fu2021offline,brookes19a,trabucco2021conservative},
using offline optimization methods to design accelerators 
has been challenging primarily due to the abundance of infeasible design points~\citep{yazdanbakhsh2021apollo,hegdemind} (see Figures~\ref{fig:ds_dist_all} and~\ref{fig:tsne_infeasible}).

The key contribution of this paper is a data-driven approach, \methodname\,, to automatically architect high-performing application-specific accelerators by using only previously collected offline data.
\methodname\ learns a robust surrogate model of the task objective function from an existing offline dataset, and finds high-performing application-specific accelerators by optimizing the architectural parameters 
\begin{wrapfigure}{r}{0.48\textwidth}
    \centering
    \vspace{-0.3cm}
    \includegraphics[width=0.99\linewidth]{figs/overview/prime-overview.pdf}
   
    \caption{\label{fig:overview} \footnotesize{\textbf{Overview of \methodname.} We use a one-time collected dataset of prior hardware accelerator designs, including TPU-style~\citep{yazdanbakhsh2021evaluation}, NVDLA-style~\citep{nvdla}, and ShiDianNao-style~\citep{shidiannao} accelerators to train a conservative surrogate model, which can then be used to design accelerators to meet desired goals and constraints.}}
    \vspace{-0.4cm}
\end{wrapfigure}
against this learned surrogate function, as shown in Figure~\ref{fig:overview}. While na\"ively learned surrogate functions usually produces poor-performing, out-of-distribution designs that appear quite optimistic  under the learned surrogate~\citep{kumar2019model,brookes19a,trabucco2021conservative}.
The robust surrogate in \methodname\ is explicitly trained to prevent overestimation on ``adversarial'' designs that would be found during optimization.
Furthermore, in contrast to prior works that discard infeasible points~\citep{hegdemind,trabucco2021conservative}, our proposed method instead incorporates infeasible points when learning the conservative surrogate by treating them as additional negative samples. Additionally, \methodname\ can be used effectively for multi-model and zero-shot optimization, capabilities that prior works~\citep{trabucco2021conservative,hegdemind} do not show.
During evaluation, \methodname\ optimizes the learned surrogate using a discrete optimizer.

Our results show that \methodname\ architects hardware accelerators that improve over the best design in the training dataset, on average, by 2.46$\times$ (up to 6.7$\times$) when specializing for a single application. 
In this case, \methodname\ also improves over the best conventional simulator-driven optimization methods by 1.54$\times$ (up to 6.6$\times$).
These performance improvements are obtained while reducing the total simulation time to merely 7\% and 1\% of that of the simulator-driven methods for single-task and multi-task optimization, respectively.
More importantly, a contextual version of \methodname\ can design accelerators that are \emph{jointly optimal} for a set of \textit{nine} applications without requiring any additional domain information.
In this challenging setting, \methodname\ improves over simulator-driven methods, which tend to scale poorly as more applications are added, by 1.38$\times$.
Finally, we show that the surrogates trained with \methodname\ on a set of training applications can be readily used to obtain accelerators for \textit{unseen} target applications, without any retraining on the new application.
Even in this \emph{zero-shot} optimization scenario, \methodname\ outperforms simulator-based methods that require re-training and active simulation queries by up to 1.67$\times$.
In summary, \methodname\ allows us to effectively address the shortcomings of simulation-driven approaches, significantly reduces the simulation time, enables data reuse and enjoys generalization properties, and does not require domain-specific engineering or search space pruning.
To facilitate further research in architecting hardware accelerators, we will also release the dataset in our experiments, consisting of many accelerator design points.

\part*{Appendices}
\section{Additional Experiments}

\subsection{Comparison to Other Baseline Methods}
\label{app:additional_experiments}
\niparagraph{Comparison to COMs.} 
In this section, we perform a comparative evaluation of \methodname\ to the COMs method~\citep{trabucco2021conservative}. 
Like several offline reinforcement learning algorithms~\citep{kumar2020conservative}, our method, \methodname\, and COMs are based on the key idea of learning a conservative surrogate of the desired objective function, such that it does not overestimate the value of unseen data points, which prevents the optimizer from finding accelerators that appear promising under the learned model but are not actually promising under the actual objective. 
The key differences between our method and COMs are:
\textbf{(1)} \methodname\ uses an evolutionary optimizer ($\mathrm{Opt}(\cdot)$) for negative sampling compared to gradient ascent of COMs, which can be vastly beneficial in discrete design spaces as our results show empirically,
\textbf{(2)} \methodname\ can explicitly learn from infeasible data points provided to the algorithm, while COMs does not have a mechanism to incorporate the infeasible points into the learning of surrogate.
To further assess the importance of these differences in practice, we run COMs on three tasks from Table~\ref{table:results_single_task}, and present a comparison our method, COMs, and Standard method in Table~\ref{table:coms_vs_prime}.
The ``Standard'' method represents a surrogate model without utilizing any infeasible points.
On average, \methodname\ outperforms COMs by 1.17$\times$ (up to 1.24$\times$ in \msix).

\begin{table}[H]
\small
\centering
\vspace*{0.1cm}
\caption{Optimized objective values (i.e., latency in milliseconds) obtained by \methodname\ and COMs~\citep{trabucco2021conservative} when optimizing over single applications (MobilenetV2, MobilenetV3 and \msix), extending Table~\ref{table:results_single_task}. Note that \methodname\ outperforms COMs. However, COMs improves over baseline ``Standard'' method (last column).}
\label{table:coms_vs_prime}
\resizebox{0.8\textwidth}{!}{
\begin{tabular}{l||l||l||l}
\toprule
\textbf{Application}&\textbf{\methodname~}\textbf{(Ours)}&\textbf{COMs}&\textbf{Standard}\\\midrule
MobileNetV2&\textbf{207.43}&251.58&374.52\\\hline
MobileNetV3&\textbf{454.30}&485.66&575.75\\\hline
\msix&\textbf{131.46}&163.94&180.24\\\bottomrule
\cellcolor{Gray} \textbf{Geomean of \methodname's Improvement}&\cellcolor{Gray}~\texttt{\textbf{1.0$\times$}}&\cellcolor{Gray}~\texttt{\textbf{1.17$\times$}}&\cellcolor{Gray}~\texttt{\textbf{1.46$\times$}}\\
\bottomrule
\end{tabular}
}
\vspace{-0.1cm}
\end{table}

\niparagraph{Comparison to generative offline MBO methods.} 
We also ran a prior offline MBO method, model inversion networks (MINs)~\citep{kumar2019model}, that trains a generative model of the accelerator on our data. However, we were unable unable to train a discrete objective-conditioned GAN model to 0.5 discriminator
\begin{wrapfigure}{r}{0.3\textwidth}
    \vspace{-0.1in}
    \includegraphics[width=\linewidth]{figs/latent.png}
    \vspace{-0.5in}
\end{wrapfigure}
 accuracy on our offline dataset, and often observed a collapse of the discriminator.
As a result, we trained a $\delta-$VAE~\citep{razavi2019preventing}, conditioned on the objective function (i.e., latency).
A standard VAE~\citep{kingma2013auto} suffered from posterior collapse and thus informed our choice of utilizing a $\delta-$VAE. 
The latent space of a trained objective-conditioned $\delta-$VAE corresponding to accelerators on a held-out validation dataset (not used for training) is visualized in the t-SNE plot in the figure on the right.
This is a 2D t-SNE of the accelerators configurations (\S Table~\ref{tab:arch_params}). 
The color of a point denotes the latency value of the corresponding accelerator configuration, partitioned into three bins. 
Observe that while we would expect these objective conditioned models to disentangle accelerators with different objective values in the latent space, the models we trained did not exhibit such a structure, which will hamper optimization.
While our method \methodname\ could also benefit from a generative optimizer (i.e., by using a generative optimizer in place of $\mathrm{Opt}(\cdot)$ with a conservative surrogate), we leave it for future work to design effective generative optimizers for accelerators.


\niparagraph{Comparison to P3BO.}
We perform a comparison against P3BO, a state-of-the-arts online MBO method in biology~\citep{p3bo:arxiv:2020}.
On average, \methodname\ outperforms the P3BO method by 2.5$\times$ (up to 8.7$\times$ in U-Net) in terms of the latency of the optimized accelerators found.
In addition, we present the comparison between the total simulation runtime of the P3BO and Evolutionary methods in Figure~\ref{fig:converg_p3bo_evolutionary}.
Note that, not only the total simulation time of P3BO is around 3.1$\times$ higher than the Evolutionary method, but also the latency of final optimized accelerator is around 18\% for MobileNetEdge.
On the other hand, the total simulation time of \methodname\ for the task of accelerator design for MobileNetEdge is lower than both methods (only 7\% of the Evolutionary method as shown in Figure~\ref{fig:convergence_time}).
\begin{table}[H]
\small
\centering
\vspace*{0.1cm}
\caption{Optimized objective values (i.e., latency in milliseconds) obtained by \methodname\ and P3BO~\citep{p3bo:arxiv:2020} when optimizing over single applications (MobileNetEdge, \mfour, t-RNN Dec, t-RNN Enc, and U-Net). On average, \methodname\ outperforms P3BO by 2.5$\times$.}
\label{table:p3bo_vs_prime}
\resizebox{0.7\textwidth}{!}{
\begin{tabular}{l||l||l}
\toprule
\textbf{Application}&\textbf{\methodname~}\textbf{(Ours)}&\textbf{P3BO}\\\midrule
MobileNetEdge&\textbf{298.50}&376.02\\\hline
\mfour&\textbf{370.45}&483.39\\\hline
U-Net&\textbf{740.27}&771.70\\\hline
t-RNN Dec&\textbf{132.88}&865.12\\\hline
t-RNN Enc&\textbf{130.67}&1139.48\\\bottomrule
\cellcolor{Gray} \textbf{Geomean of \methodname's Improvement}&\cellcolor{Gray}~\texttt{\textbf{1.0$\times$}}&\cellcolor{Gray}~\texttt{\textbf{2.5$\times$}}\\
\bottomrule
\end{tabular}
}
\vspace{-0.1cm}
\end{table}
\begin{figure}[t!]
    \centering
    \includegraphics[width=0.5\textwidth]{figs/convergence_time_v2_evolutionary_vs_p3bo.png}
    \caption{Comparing the total simulation time needed by the P3BO and Evolutionary method on MobileNetEdge. Note that, not only the total simulation time of P3BO is around 3.1$\times$ higher than the Evolutionary method, but also the latency of final optimized accelerator is around 18\% for MobileNetEdge. The total simulation time of our method is around 7\% of the Evolutionary method (See Figure~\ref{fig:convergence_time}).}
    \label{fig:converg_p3bo_evolutionary}
    \vspace{-0.1in}
\end{figure}
\subsection{Learned Surrogate Model Reuse for Accelerator Design}
\label{app:additional_experiments_multi}
Extending our results in Table~\ref{table:results_multi_task}, we present another variant of optimizing accelerators jointly for multiple applications.
In that scenario, the learned surrogate model is reused to architect an accelerator for a subset of applications used for training.
We train a contextual conservative surrogate on the variants of MobileNet (Table~\ref{tab:models}) as discussed in Section~\ref{sec:method}, but generated optimized designs by only optimizing the average surrogate on only two variants of MobileNet (MobileNetEdge and MobileNetV2). 
This tests the ability of our approach \methodname\ to provide a general contextual conservative surrogate that can be trained \textit{only once} and optimized multiple times with respect to different subsets of applications.  
Observe in Table~\ref{table:results_edge_v2}, \methodname\ architects high-performing accelerator configurations (better than the best point in the dataset by 3.29$\times$ -- last column) while outperforming the online optimization methods by 7\%.
\begin{table}[t!]
\small
\renewcommand{1.0}{1.2}
\centering
\caption{Optimized objective values (i.e., latency in milliseconds) obtained by our \methodname\ when using the jointly optimized model on three variants of MobileNets and use for MobileNetEdge and MobileNetV2 for different dataset configurations. \methodname\ outperforms the best online method by \textbf{7\%} and finds an accelerator that is \textbf{3.29$\times$} better than the best accelerator in the training dataset (last row). The best accelerator configuration is highlighted in bold.}
\label{table:results_edge_v2}
\resizebox{\textwidth}{!}{
\begin{tabular}{l||l||l|l||l|l|l||l}
\toprule
&\multicolumn{3}{c||}{\textbf{\methodname}}& &\multicolumn{2}{c||}{\textbf{Online Optimization}}&\\\cline{2-4}\cline{6-7}
\textbf{Applications}&\textbf{All}& \textbf{-Opt}&\textbf{-Infeasible}&\textbf{Standard}& \textbf{Bayes Opt}&\textbf{Evolutionary}&\textbf{$\mathcal{D}$ (Best in Training)}\\\midrule
(MobileNetEdge, MobileNetV2)&\textbf{253.85}&297.36&264.85&341.12&275.21&271.71&834.68\\
\bottomrule
\end{tabular}
}
\end{table}
\subsection{Learned Surrogate Model Reuse under Different Design Constraints}
\label{app:transfer}
We also test the robustness of our approach in handling variable constraints at test-time such as different chip area budget.
We evaluate the learned conservative surrogate trained via \methodname\ under a reduced value of the area threshold, $\alpha$, in Equation~\ref{eqn:opt_prob}.
To do so, we utilize a variant of rejection sampling -- we take the learned model trained for a default area constraint $\alpha = 29~\mathrm{mm}^2$ and then reject all optimized accelerator configurations which do not satisfy a reduces area constraint: $\mathrm{Area}({\mathbf{x}}) \leq \alpha_0 = 18~\mathrm{mm}^2$.
Table~\ref{table:results_edge_18} summarizes the results for this scenario for the MobileNetEdge~\citep{edgetpu:arxiv:2020} application under the new area constraint ($\alpha = 18~\mathrm{mm}^2$).
A method that produces diverse designs which are both high-performing and are spread across diverse values of the area constraint are expected to perform better.
As shown in Table~\ref{table:results_edge_18}, \methodname\ provides better accelerator than the best online optimization from scratch with the new constraint value by 4.4\%, even when \methodname\ does not train its conservative surrogate with this unseen test-time design constraint.
Note that, when the design constraint changes, online methods generally need to restart the optimization process from scratch and undergo costly queries to the simulator.
This would impose additional overhead in terms of total simulation time (see Figure~\ref{fig:convergence_time} and Figure~\ref{fig:convergence_time_seven_models}). However, the results in Table~\ref{table:results_edge_18} shows that our learned surrogate model can be reused under different test-time design constraint eliminating additional queries to the simulator.
\begin{table}[t!]
\small
\renewcommand{1.0}{1.2}
\centering
\caption{Optimized objective values (i.e., latency in milliseconds) obtained by various methods for the task of learning accelerators specialized to MobileNetEdge under chip area budget constraint 18~mm$^2$ reusing the already learned model by our method for MobileNetEdge (shown in Table~\ref{table:results_single_task}). Lower latency/runtime is better. From left to right: our method, our method without negative sampling (``\methodname-$\mathrm{Opt}$'') and without utilizing infeasible points (``\methodname-Infeasible''), standard surrogate (``Standard''), online Bayesian optimization (``Bayes Opt''), online evolutionary algorithm (``Evolutionary'') and the best design in the training dataset. Note that \methodname\ improves over the best in the dataset by 12\%, outperforms the best online optimization method by 4.4\%. The best accelerator configuration is highlighted in bold.}
\label{table:results_edge_18}
\resizebox{\textwidth}{!}{
\begin{tabular}{l||l||l|l||l|l|l||l}
\toprule
&\multicolumn{3}{c||}{\textbf{\methodname}}& &\multicolumn{2}{c||}{\textbf{Online Optimization}}&\\\cline{2-4}\cline{6-7}
\textbf{Applications}&\textbf{All}& \textbf{-Opt}&\textbf{-Infeasible}&\textbf{Standard}& \textbf{Bayes Opt}&\textbf{Evolutionary}&\textbf{$\mathcal{D}$ (Best in Training)}\\\midrule
MobileNetEdge, Area $\leq$ 18~mm$^2$&\textbf{315.15}&433.81&351.22&470.09&331.05&329.13&354.13\\
\bottomrule
\end{tabular}
}
\end{table}


\subsection{Comparison with Human-Engineered Accelerators}
\label{app:human_engineered}
In this section, we compare the optimized accelerator design found by \methodname\ to the  EdgeTPU design~\citep{yazdanbakhsh2021evaluation,edgetpu:arxiv:2020} targeted towards single applications. The goal of this comparison is to present the potential benefit of specialization towards single applications, \textit{only} using architecture exploration.
We utilize an area constraint of 27~mm$^2$ and a DRAM bandwidth of 25 Gbps, identical to the specifications of the EdgeTPU accelerator.
Table~\ref{table:edgetpu_comparison} shows the summary of results in two sections, namely ``Latency'' and ``Chip Area''. The first and second under each section show the results for \methodname\ and EdgeTPU, respectively.
The final column for each section shows the improvement of the design suggested by \methodname\ over EdgeTPU.
On average (as shown in the last row), \methodname\ finds accelerator designs that are 2.69$\times$ (up to 11.84$\times$ in t-RNN Enc) better than EdgeTPU in terms of latency. Our method achieves this improvement while, on average, reducing the chip area usage by 1.50$\times$ (up to 2.28$\times$ in MobileNetV3).

\begin{table}[t!]
\small
\renewcommand{1.0}{1.2}
\centering
\caption{The comparison between the accelerator designs suggested by \methodname\ and EdgeTPU~\citep{yazdanbakhsh2021evaluation,edgetpu:arxiv:2020} for single model specialization. On average (last row), with single-model specialization our method reduces the latency by 2.69$\times$ while minimizes the chip area usage by 1.50$\times$.}
\label{table:edgetpu_comparison}
\resizebox{\textwidth}{!}{
\begin{tabular}{l|r|r|r||r|r|r}
\toprule
&\multicolumn{3}{c||}{\textbf{Latency~(milliseconds)}}&\multicolumn{3}{c}{\textbf{Chip Area~(mm$^2$)}}\\\cline{2-7}
\textbf{Application}&\textbf{\methodname}&\textbf{EdgeTPU}&\textbf{Improvement}&\textbf{\methodname}&\textbf{EdgeTPU}&\textbf{Improvement}\\\midrule
{\textbf{MobileNetEdge}}&294.34&523.48&1.78$\times$&18.03&27&1.50$\times$\\\hline
{\textbf{MobileNetV2}}&208.72&408.24&1.96$\times$&17.11&27&1.58$\times$\\\hline
{\textbf{MobileNetV3}}&459.59&831.80&1.81$\times$&11.86&27&2.28$\times$\\\hline
\textbf{\mfour}&370.45&675.53&1.82$\times$&19.12&27&1.41$\times$\\\hline
\textbf{\mfive}&208.42&377.32&1.81$\times$&22.84&27&1.18$\times$\\\hline
\textbf{\msix}&132.98&234.88&1.77$\times$&16.93&27&1.59$\times$\\\hline
\textbf{U-Net}&1465.70&2409.73&1.64$\times$&25.27&27&1.07$\times$\\\hline
\textbf{t-RNN Dec}&132.43&1384.44&10.45$\times$&14.82&27&1.82$\times$\\\hline
\textbf{t-RNN Enc}&130.45&1545.07&11.84$\times$&19.87&27&1.36$\times$\\\hline
\cellcolor{Gray}~\textbf{Average Improvement}&\cellcolor{Gray}~---&\cellcolor{Gray}~---&\cellcolor{Gray}~\textbf{2.69$\times$}&\cellcolor{Gray}~---&\cellcolor{Gray}~---&\cellcolor{Gray}~\textbf{1.50$\times$}\\\bottomrule
\end{tabular}
}
\end{table}



\subsection{Comparison with Online Methods in Zero-Shot Setting}
\label{sec:app_zero_shot}
We evaluated the Evolutionary (online) method under two protocols for the last two rows of Table~\ref{table:zero_shot}: first, we picked the best designs (top-performing 256 designs similar to the \methodname\ setting in Section~\ref{sec:method}) found by the evolutionary algorithm on the training set of applications and evaluated them on the target applications and second, we let the evolutionary algorithm continue simulator-driven optimization on the target applications.
The latter is unfair, in that the online approach is allowed access to querying more designs in the simulator. Nevertheless, we found that in either configuration, the evolutionary approach performed worse than \methodname\, which does not access training data from the target application domain.
For the area constraint 29~mm$^2$ and 100~mm$^2$, the Evolutionary algorithm reduces the latency from 1127.64~$\rightarrow$~820.11 and 861.69~$\rightarrow$~552.64, respectively, although still worse than \methodname.
In the second experiment in which we \emph{unfairly} allow the evolutionary algorithm to continue optimizing on the target application, the Evolutionary algorithm suggests worse designs than Table~\ref{table:zero_shot} (e.g. 29~mm$^2$: 1127.64~$\rightarrow$~1181.66 and 100~mm$^2$: 861.69~$\rightarrow$~861.66).
\subsection{Ablation Studying Various Components of \methodname}
\label{sec:appx_ablation}
\input{tables/ablation_study.tex}
Here we ablate over components of our method: (1) $\mathrm{Opt}$ was not used for negative sampling (``\methodname-$\mathrm{Opt}$'' in Table~\ref{table:appx_results_single_task}) (2)  infeasible points were not used (``\methodname-Infeasible'' in Table~\ref{table:appx_results_single_task}).
As shown in Table~\ref{table:appx_results_single_task}, the variants of our method generally performs worse compared to the case when both negative sampling and infeasible data points are utilized in training the surrogate model.


\section{Comparing Optimized Accelerators Found By \methodname\ and Evolutionary Methods}
\label{app:analysis}
\begin{table}[t!]
\small
\renewcommand{1.0}{1.2}
\centering
\caption{Per application latency for the best accelerator design suggested by \methodname\ and the Evolutionary method according to Table~\ref{table:results_multi_task} for multi-task accelerator design (nine applications and area constraint 100~mm$^2$). \methodname\ outperforms the Evolutionary method by 1.35$\times$.}
\label{table:per_application_latency}
\resizebox{0.9\textwidth}{!}{
\begin{tabular}{l|r|r|r}
\toprule
&\multicolumn{2}{c|}{\textbf{Latency (ms)}}&\\\cline{2-3}
\textbf{Applications}&\textbf{\methodname}&\textbf{Evolutionary~(Online)}&\textbf{Improvement of \methodname\ over Evolutionary}\\\midrule
{MobileNetEdge}&\textbf{288.38}&319.98&1.10$\times$\\\hline
{MobileNetV2}&\textbf{216.27}&255.95&1.18$\times$\\\hline
{MobileNetV3}&\textbf{487.46}&573.57&1.17$\times$\\\hline
{\mfour}&\textbf{400.88}&406.28&1.01$\times$\\\hline
{\mfive}&248.18&\textbf{239.18}&0.96$\times$\\\hline
{\msix}&164.98&\textbf{148.83}&0.90$\times$\\\hline
{U-Net}&1268.73&\textbf{908.86}&0.71$\times$\\\hline
{t-RNN Dec}&\textbf{191.83}&862.14&5.13$\times$\\\hline
{t-RNN Enc}&\textbf{185.41}&952.44&4.49$\times$\\\bottomrule
\cellcolor{Gray} \textbf{Average~(Latency in ms)}&\cellcolor{Gray}~\texttt{\textbf{383.57}}&\cellcolor{Gray}~\texttt{\textbf{518.58}}&\cellcolor{Gray}~\texttt{\textbf{1.35$\times$}}\\\bottomrule
\end{tabular}
}
\end{table}
\begin{table}[t!]
\small
\renewcommand{1.0}{1.2}
\centering
\caption{Optimized accelerator configurations (See Table~\ref{tab:arch_params}) found by \methodname\ and the Evolutionary method for multi-task accelerator design (nine applications and area constraint 100~mm$^2$). Last row shows the accelerator area in mm$^2$. \methodname\ reduces the overall chip area usage by 1.97$\times$. The difference in the accelerator configurations are shaded in gray.}
\label{table:best_accelerator_config}
\resizebox{0.6\textwidth}{!}{
\begin{tabular}{l|r|r}
\toprule
&\multicolumn{2}{c}{\textbf{Parameter Value}}\\\cline{2-3}
\textbf{Accelerator Parameter}&\textbf{\methodname}&\textbf{Evolutionary~(Online)}\\\midrule
\# of PEs-X&4&4\\\hline
\cellcolor{Gray}~\# of PEs-Y&\cellcolor{Gray}~6&\cellcolor{Gray}~8\\\hline
\cellcolor{Gray}\# of Cores&\cellcolor{Gray}~64&\cellcolor{Gray}~128\\\hline
\cellcolor{Gray}~\# of Compute Lanes&\cellcolor{Gray}~4&\cellcolor{Gray}~6\\\hline
\cellcolor{Gray}~PE Memory&\cellcolor{Gray}~2,097,152&\cellcolor{Gray}~1,048,576\\\hline
Core Memory&131,072&131,072\\\hline
\cellcolor{Gray}~Instruction Memory&\cellcolor{Gray}~32,768&\cellcolor{Gray}~8,192\\\hline
Parameter Memory&4,096&4,096\\\hline
\cellcolor{Gray}~Activation Memory&\cellcolor{Gray}~512&\cellcolor{Gray}~2,048\\\hline
DRAM Bandwidth~(Gbps)&30&30\\\bottomrule
\cellcolor{Gray}~\textbf{Chip Area~(mm$^2$)}&\cellcolor{Gray}~\texttt{\textbf{46.78}}&\cellcolor{Gray}~\texttt{\textbf{92.05}}\\\bottomrule
\end{tabular}
}
\end{table}
In this section, we overview the best accelerator configurations that \methodname\ and the Evolutionary method found for multi-application accelerator design (See Table~\ref{table:results_multi_task}), when the number of target applications are nine and the area constraint is set to 100~mm$^2$.
The average latencies of the best accelerators found by \methodname\ and the Evolutionary method across nine target applications are \textbf{383.57~ms} and \textbf{518.58~ms}, respectively.
In this setting, our method outperforms the best online method by \textbf{1.35$\times$}.
Table~\ref{table:per_application_latency} shows per application latencies for the accelerator suggested by our method and the Evolutionary method.
The last column shows the latency improvement of \methodname\ over the Evolutionary method. Interestingly, while the latency of the accelerator found by our method for MobileNetEdge, MobileNetV2, MobileNetV3, \mfour, t-RNN Dec, and t-RNN Enc are better, the accelerator identified by the online method yields lower latency in \mfive, \msix, and U-Net.

To better understand the trade-off in design of each accelerators designed by our method and the Evolutionary method, we present all the accelerator parameters (See Table~\ref{tab:arch_params}) in Table~\ref{table:best_accelerator_config}.
The accelerator parameters that are different between each of the designed accelerator are shaded in gray (e.g. \# of PEs-Y, \# of Cores, \# of Compute Lanes, PE Memory, Instruction Memory, and Activation Memory).
Last row of Table~\ref{table:best_accelerator_config} depicts the overall chip area usage in mm$^2$. \methodname\ not only outperforms the Evolutionary algorithm in reducing the average latency across the set of target applications, but also reduces the overall chip area usage by \textbf{1.97$\times$}.
Studying the identified accelerator configuration, we observe that \methodname\ trade-offs compute (\colorbox{lightgray}{\textbf{64 cores vs. 128 cores}}) for larger PE memory size (\colorbox{lightgray}{\textbf{2,097,152 vs. 1,048,576}}). These results show that \methodname\ favors PE memory size to accommodate for the larger memory requirements in t-RNN Dec and t-RNN Enc (See Table~\ref{tab:models} Model Parameters) where large gains lie.
Favoring larger on-chip memory comes at the expense of lower compute power in the accelerator. This reduction in the accelerator's compute power leads to higher latency for the models with large number of compute operations, namely \mfive, \msix, and U-Net (See last row in Table~\ref{tab:models}).
\mfour is an interesting case where both compute power and on-chip memory is favored by the model (6.23~MB model parameters and 3,471,920,128 number of compute operations). This is the reason that the latency of this model on both accelerators, designed by our method and the Evolutionary method, are comparable (400.88~ms in \methodname\ vs. 406.28~ms in the online method).

\section{Details of \methodname}
\label{app:details}
In this section, we provide training details of our method \methodname\ including hyperparameters and compute requirements and details of different tasks. 
\subsection{Hyperparameter and Training Details}
\label{sec:practical_implementation}
Algorithm~\ref{alg:prime} outlines our overall system for accelerator design.
\methodname\ parameterizes the function $f_\theta({\mathbf{x}})$ as a deep neural network as shown in Figure~\ref{fig:method}. 
The architecture of $f_\theta({\mathbf{x}})$ first embeds the discrete-valued accelerator configuration ${\mathbf{x}}$ into a continuous-valued 640-dimensional embedding via two layers of a self-attention transformer~\citep{vaswani2017attention}. 
Rather than directly converting this 640-dimensional embedding into a scalar output via a simple feed-forward network, which we found a bit unstable to train with Equation~\ref{eqn:final_training}, possibly due to the presence of competing objectives for a comparison), we pass the 640-dimensional embedding into $M$ different networks that map it to $M$ different scalar predictions $(f^i_\theta({\mathbf{x}}))_{i=1}^M$. 
Finally, akin to attention~\citep{vaswani2017attention} and mixture of experts~\citep{shazeer2017outrageously}, we train an additional head to predict weights $(w_i)_{i=1}^M \geq 0$ of a linear combination of the predictions at different heads that would be equal to the final prediction: $f_\theta({\mathbf{x}}) = \sum_{i=1}^K w_i f^i_\theta({\mathbf{x}})$.
Such an architecture allows the model to use different predictions $f^i_\theta({\mathbf{x}})$, depending upon the input, which allows for more stable training. To train $f_\theta({\mathbf{x}})$, we utilize the Adam~\citep{kingma2014adam} optimizer.
Equation~\ref{eqn:final_training} utilizes a procedure $\mathrm{Opt}$ that maximizes the learned function approximately. We utilize the same technique as Section~\ref{sec:method} (``optimizing the learned surrogate'') to obtain these negative samples.
We periodically refresh $\mathrm{Opt}$, once in every 20K gradient steps on $f_\theta({\mathbf{x}})$ over training.
\begin{algorithm}[ht]
  \caption{Training the conservative surrogate in PRIME}\label{alg:prime}
  \begin{algorithmic}[1]
    \State Initialize a neural model $f_{\theta_0}({\mathbf{x}})$ and a set $M = 23$ of negative particles to be updated by the firefly optimizer $\{{\mathbf{x}}^{-}_1(0), \cdots,  {\mathbf{x}}^{-}_i(0), {\mathbf{x}}^{-}_M(0)\}$ to random configurations from the design space.
    \For{iteration $i = 0, 1, 2, 3, \dots $ until convergence}
        \For{firefly update step  $t = 0, 1, \dots,  4$  \hfill \Comment{\textbf{Inner loop}}}
          \State Update the $M$ fireflies according to the firefly update rule in Equation~\ref{eqn:firefly1},\\ ~~~~~~~~~~~~towards maximizing $f_{\theta_i}({\mathbf{x}})$ according to: \hfill \Comment{\textbf{Negative mining}}\\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${{\mathbf{x}}_{i}(ti+ 1) = {\mathbf{x}}_{i}(ti) + \beta({\mathbf{x}}_{i}(ti) - {\mathbf{x}}_{j}(ti)) + \alpha\epsilon_{ti}}$
      \EndFor
      \State Find the best firefly found in these steps to be used as the negative sample:\\ ~~~~~~~~~~~~~~~~~~~~~~${\mathbf{x}}^{-}_i = \arg \min \{f_{\theta_i}({\mathbf{x}}^{-}_1(t i)), \cdots, f_{\theta_i}({\mathbf{x}}^{-}_M(t i))\}$ \hfill \Comment{\textbf{Find negative sample}}
      \State Run one gradient step on $\theta_i$ using Equation~\ref{eqn:final_training} with ${\mathbf{x}}^{-}_i$ as the negative sample
      \State \textbf{if} $i \% p == 0$, (p = 20000), then: \hfill \Comment{\textbf{Periodically reinitialize the optimizer}} \\~~~~~~~~~~~~~~~Reinitialize firefly particles  $\{{\mathbf{x}}^{-}_1(0), \cdots,  {\mathbf{x}}^{-}_i(0), {\mathbf{x}}^{-}_M(0)\}$ to random designs.
    \EndFor
    \State Return the final model $f_{\theta^*}({\mathbf{x}})$
  \end{algorithmic}
\end{algorithm}

The hyperparameters for training the conservative surrogate in Equations~\ref{eqn:final_training} and its contextual version are as follows:
\begin{itemize}
    \item \textbf{Architecture of ${f}_\theta({\mathbf{x}})$}. As indicated in Figure~\ref{fig:method}, our architecture takes in list of categorical (one-hot) values of different accelerator parameters (listed in Table~\ref{tab:arch_params}), converts each parameter into $64$-dimensional embedding, thus obtaining a $10 \times 64$ sized matrix for each accelerator, and then runs two layers of self-attention~\citep{vaswani2017attention} on it. The resulting $10 \times 64$ output is flattened to a vector in $\mathbb{R}^{640}$ and fed into $M = 7$ different prediction networks that give rise to $f^1_\theta({\mathbf{x}}), \cdots, f^M_\theta({\mathbf{x}})$, and an additional attention 2-layer feed-forward network (layer sizes $=[256, 256]$) that determines weights $w_1, \cdots, w_M$, such that $w_i \geq 0$ and $\sum_{i=1}^M w_i = 1$. Finally the output is simply $f_\theta({\mathbf{x}}) = \sum_i w_i f^i_\theta({\mathbf{x}})$. 
    \item \textbf{Optimizer/learning rate for training $f_\theta({\mathbf{x}})$}. Adam, $1e-4$, default $\beta_1 = 0.9$, $\beta_2 = 0.999$.
    \item \textbf{Validation set split.} Top 20\% high scoring points in the training dataset are used to provide a validation set for deciding coefficients $\alpha$, $\beta$ and the checkpoint to evaluate.
    \item \textbf{Ranges of $\alpha$, $\beta$.} We trained several $f_\theta({\mathbf{x}})$ models with $\alpha \in [0.0, 0.01, 0.1, 0.5, 1.0, 5.0]$ and $\beta \in [0.0, 0.01, 5.0, 0.1, 1.0]$. Then we selected the best values of $\alpha$ and $\beta$ based on the highest Kendall's ranking correlation on the validation set. Kendall's ranking correlation between two sets of objective values: $S = \{y_1, y_2, \cdots, y_N\}$ corresponding to ground truth latency values on the validation set and $S' = \{y'_1, y'_2, \cdots, y'_N \}$ corresponding to the predicted latency values on the validation set is given by $\tau$ equal to:
    \begin{equation}
        \tau = \frac{\sum_{i, j}^{N, N} \mathbb{I}[(y_i - y_j) (y'_i - y'_j) > 0] - \sum_{i, j}^{N, N} \mathbb{I}[(y_i - y_j) (y'_i - y'_j) \leq 0]}{N \cdot (N - 1)}.   
    \end{equation}
    \item \textbf{Clipping $f_\theta({\mathbf{x}})$ during training}. Equation~\ref{eqn:final_training} increases the value of the learned function $f_\theta({\mathbf{x}})$ at ${\mathbf{x}} = {\mathbf{x}}_0 \in \mathcal{D}_\text{infeasible}$ and ${\mathbf{x}}^- \sim \mathrm{Opt}(f_\theta)$. We found that with the small dataset, these linear objectives can run into numerical instability, and produce $+\infty$ predictions. To avoid this, we clip the predicted function value both above and below by $\pm 10000.0$, where the valid range of ground-truth values is $\mathcal{O}(1000)$.
    \item \textbf{Negative sampling with $\mathrm{Opt}(\cdot)$}. As discussed in Section~\ref{sec:method}, we utilize the firefly optimizer for both the negative sampling step and the final optimization of the learned conservative surrogate. When used during negative sampling, we refresh (i.e., reinitialize) the firefly parameters after every $p = 20000$ gradient steps of training the conservative surrogate, and run $t = 5$ steps of firefly optimization per gradient step taken on the conservative surrogate. 
    \item \textbf{Details of firefly:} The initial population of fireflies depends on the number of accelerator configurations ($\mathcal{C}$) following the formula $10+\round{(\mathcal{C}^{1.2}+\mathcal{C})\times0.5}$. In our setting with ten accelerator parameters (See Table~\ref{tab:arch_params}), the initial population of fireflies is 23. We use the same hyperparameters: $\gamma = 1.0, \beta_0 = 1.0$, for the optimizer in all the experiments and never modify it. The update to a particular optimization particle (i.e., a firefly) ${\mathbf{x}}_i$, at the $t$-th step of optimization is given by: 
    \begin{equation}
    \label{eqn:firefly1}
    \begin{aligned}
    {{\mathbf{x}}_{i}(t+1) = {\mathbf{x}}_{i}(t) + \beta({\mathbf{x}}_{i}(t) - {\mathbf{x}}_{j}(t)) + ~\text{i.i.d. Gaussian noise},}
    \end{aligned}
    \end{equation}
    where ${\mathbf{x}}_j(t), j \neq i$ is a different firefly that achieves a better objective value compared to ${\mathbf{x}}_i$ and the function $\beta$ is given by: $\beta(r) = \beta_{0}e^{-\gamma{}r^2}$.
\end{itemize}
\subsection{Details of Architecting Accelerators for Multiple Applications Simultaneously}
\label{sec:appx_multi_task_tsne}
Now we will provide details of the tasks from Table~\ref{table:results_multi_task} where the goal is to architect an accelerator which is jointly optimized for multiple application models.
For such tasks, we augment data-points for each model with the context vector $c_k$ from Table~\ref{tab:models} that summarizes certain parameters for each application.
For entries in this context vector that have extremely high magnitudes (e.g., model parameters and number of compute operations), we normalize the values by the sum of values across the applications considered to only encode the relative scale, and not the absolute value which is not required.
To better visualize the number of feasible accelerators for joint optimization, Figure~\ref{fig:tsne_overlap} show the tSNE plot (raw architecture configurations are used as input) of high-performing accelerator configurations. The blue-colored dots are the jointly feasible accelerators in the combined dataset, and note that these data points are no more than 20-30 in total. The highlighted red star presents the best design suggested by \methodname\ with average latency of 334.70 (Table~\ref{table:results_multi_task}).
This indicates that this contextual, multi-application problem poses a challenge for data-driven methods: these methods need to produce optimized designs even though very few accelerators are jointly feasible in the combined dataset.
Despite this limitation, \methodname\ successfully finds more efficient accelerator configurations that attain low latency values on each of the applications jointly, as shown in Table~\ref{table:results_multi_task}.

\begin{figure}[t]
    \centering
    \includegraphics[width=0.7\textwidth]{figs/tsne/tsne-overlap.pdf}
    \caption{tSNE plot of the joint dataset and randomly sampled infeasible data points. The blue points show the accelerator configurations that are jointly feasible for all the applications. The highlighted point with red star shows the best design proposed by \methodname\. The rest of the points show the infeasible points.}
    \label{fig:tsne_overlap}
    \vspace{-0.1in}
\end{figure}


\subsection{Dataset Sensitivity to Accelerator Parameters}
\label{sec:app_ds_sensitivity}
We visualize the sensitivity of the objective function (e.g. latency) with respect to the changes in certain accelerator parameters, such as memory size (Table~\ref{tab:arch_params}), in Figure~\ref{fig:appx_ds_memory}, illustrating this sensitivity.
As shown in the Figure, the latency objective that we seek to optimize can exhibit high sensitivity to small variations in the architecture parameters, making the optimization landscape particularly ill-behaved.
Thus, a small change in one of the discrete parameters, can induce a large change in the optimization objective.
This characteristic of the dataset further makes the optimization task challenging. 


\section{Overview of Accelerators and Search Space}
\label{sec:dla_shi_fast}
This section briefly discuss the additional accelerators (similar to \citep{kao2020confuciux}) that we evaluate in this work, namely NVDLA~\citep{nvidia} and ShiDianNao~\citep{shidiannao}, and their corresponding search spaces.

\niparagraph{NVDLA: Nvidia Deep Learning Accelerator.}
NVDLA~\citep{nvdla} is an open architecture inference accelerator designed and maintained by Nvidia.
In compared to other inference accelerators, NVDLA is a weight stationary accelerator. That is, it retains the model parameters on each processing elements and parallelizes the computations across input and output channels.
NVDLA-style dataflow accelerators generally yield better performance for the computations of layers at the later processing stages. This is because these layers generally have larger model parameters that could benefit from less data movement associated to the model parameters.

\niparagraph{ShiDianNao: Vision Accelerator.}
Figure~\ref{fig:shi_dla} shows the high-level schematic of ShiDianNao accelerator~\citep{shidiannao}.
ShiDianNao-style dataflow accelerator is an output-stationary accelerator.
\begin{figure}[t!]
\centering
    \includegraphics[width=0.3\linewidth]{figs/accelerator/shidian.pdf}
    \caption{Overview of ShiDianNao dataflow accelerator. This dataflow accelerators exhibits an output-stationary dataflow where it keeps the partial results stationary within each processing elements (PEs).}
    \label{fig:shi_dla}
    \vspace{-0.1in} 
\end{figure}
That is, it keeps the partial results inside each PE and instead move the model parameters and input channel data. 
As such, in compared to NVDLA-style accelerators, ShiDianNao provides better performance for the computations of the layers with large output channels (generally first few layers of a model).

\niparagraph{Search space of dataflow accelerators.}
We follow a similar methodology as \citep{kao2020confuciux} to evaluate additional hardware accelerators, discussed in the previous paragraphs.
We use MAESTRO~\citep{maestro}, an analytical cost model, that supports the performance modeling of various dataflow accelerators.
In this joint accelerator design and dataflow optimization problem, the total number of parameters to be optimized is up to 106---the tuple of (\# of PEs, Buffers) per per model layer---with each parameter taking one of 12 discrete values. This makes the hardware search space consist of $\approx$~2.5$\times10^{114}$ accelerator configurations.
We also note that while the method proposed in~\citep{kao2020confuciux} treats the accelerator design problem as a sequential decision making problem, and uses reinforcement learning techniques, \methodname\ simply designs the whole accelerator in a single step, treating it as a model-based optimization problem.

\begin{figure}[t]
    \centering
    %
    \subfloat[]{
    \includegraphics[width=0.45\textwidth]{figs/dataset/dist.png}
    \label{fig:appx_ds_dist}}
    %
    \subfloat[]{
    \includegraphics[width=0.45\textwidth]{figs/dataset/core-memory.png}
    \label{fig:appx_ds_memory}}
    \caption{The (a) histogram of infeasible (orange bar with large score values)/feasible (blue bars) data points and (b) the sensitivity of runtime to the size of core memory for the MobileNetEdge~\citep{efficientnet:2020} dataset.} 
    \label{fig:appx_ds}
    \vspace{-0.4cm}
\end{figure}

\begin{figure}[t!]
    \centering
    \includegraphics[width=0.5\textwidth]{figs/tsne/tsne_infeasible.pdf}
    \caption{tSNE plot of the infeasible and feasible hardware accelerator designs. Note that feasible designs (shown in blue) are embedded in a sea of infeasible designs (shown in red), which makes this a challenging domain for optimization methods.}
    \label{fig:tsne_infeasible}
    \vspace{-0.1in}
\end{figure}

\begin{figure}[t!]
    \centering
    \includegraphics[width=0.4\textwidth]{figs/results/calibration_plot.png}
    \caption{To verify if the overestimation hypothesis--that optimizing an accelerator against a na\"ive standard surrogate model is likely to find optimizers that appear promising under the learned model, but do not actually attain low-latency values--in our domain, we plot a calibration plot of the top accelerator designs found by optimizing a na\"ively trained standard surrogate model. In the scatter plot, we represent each accelerator as a point with its x-coordinate equal to the actual latency obtained by running this accelerator design in the simulator and the y-coordinate equal to the predicted latency under the learned surrogate. Note that for a large chunk of designs, the predicted latency is much smaller than their actual latency (i.e., these designs lie beneath the $y=x$ line in the plot above). This means that optimizing designs under a na\"ive surrogate model is prone to finding designs that appear overly promising (i.e., attain lower predicted latency values), but are not actually promising. This confirms the presence of the overestimation hypothesis on our problem domain.}
    \label{fig:cali_plot}
    \vspace{-0.1in}
\end{figure}
\section{\methodname: Architecting Accelerators via Conservative Surrogates}
\vspace{-0.03in}
\label{sec:method}
As shown in Figure~\ref{fig:method}, our method first learns a conservative surrogate model of the optimization objective using the offline dataset.
Then, it optimizes the learned surrogate using a discrete optimizer.
The optimization process does not require access to a simulator, nor to real-world experiments beyond the initial dataset, except when evaluating the final top-performing $n=256$ designs (Section~\ref{sec:accel}).

\niparagraph{Learning conservative surrogates using logged offline data.}
Our goal is to utilize a logged dataset of feasible accelerator designs labeled with the desired performance metric (e.g., latency),  $\mathcal{D}_\text{feasible}$, and infeasible designs,  $\mathcal{D}_\text{infeasible}$ to learn a mapping ${f}_\theta: \mathcal{X} \rightarrow \mathbb{R}$, that maps the accelerator configuration ${\mathbf{x}}$ to its corresponding metric $y$. This learned surrogate can then be optimized by the optimizer. While a straightforward approach for learning such a mapping is to train it via supervised regression, by minimizing the mean-squared error $\mathbb{E}_{{\mathbf{x}}_i, y_i \sim \mathcal{D}}[(f_\theta({\mathbf{x}}_i) - y_i)^2]$, prior work~\citep{kumar2019model,kumar2020conservative,trabucco2021conservative} has shown that such predictive models can arbitrarily overestimate the value of an unseen input ${\mathbf{x}}_i$. This can cause the optimizer to find a solution ${\mathbf{x}}^*$ that performs poorly in the simulator but looks promising under the learned model. We empirically validate this overestimation hypothesis and find it to confound the optimizer in on our problem domain as well (See Figure~\ref{fig:cali_plot} in appendix). 
\begin{wrapfigure}{r}{0.7\textwidth}
    \centering
    \vspace{-0.1in}
    \includegraphics[width=0.95\linewidth]{figs/overview/mbo-method.pdf}
    \vspace{-0.1in}
    \caption{\small{Overview of \methodname\ which trains a conservative surrogate ${f}_\theta({\mathbf{x}}_i)$ using Equation~\ref{eqn:final_training}. Our neural net model for ${f}_\theta({\mathbf{x}})$ utilizes two transformer layers~\citep{vaswani2017attention}, and a multi-headed architecture which is pooled via a soft-attention layer.}}
    \label{fig:method}
    \vspace{-0.4cm}
\end{wrapfigure}
To prevent overestimated values at unseen inputs from confounding the optimizer, we build on COMs \citep{trabucco2021conservative} and train $f_\theta({\mathbf{x}})$ with an additional term that explicitly maximizes the function value $f_\theta({\mathbf{x}})$ at unseen ${\mathbf{x}}$ values.
Such unseen designs ${\mathbf{x}}$, where the learned function $f_\theta({\mathbf{x}})$ is likely to be overestimated, are ``negatively mined'' by running a few iterations of an approximate stochastic optimization procedure that aims to maximize $f_\theta$ in the inner loop. This procedure is analogous to adversarial training~\citep{goodfellow2014explaining} in supervised learning. Equation~\ref{eqn:training} formalizes this objective:
\newcommand{black}{black}
\begin{equation}
\label{eqn:training}
    \theta^* := \arg \min_\theta~~ \mathcal{L}(\theta):= \mathbb{E}_{{\mathbf{x}}_i, y_i \sim \mathcal{D}_{\text{feasible}}} \left[ (f_\theta({\mathbf{x}}_i) - y_i)^2 \right] - \alpha \mathbb{E}_{{\mathbf{x}}^{-}_i \sim \textcolor{black}{\mathrm{Opt}(f_\theta)}} \left[f_\theta({\mathbf{x}}^-_i) \right].
\end{equation}
\vspace{-0.1in}
${\mathbf{x}}^{-}_i$ denotes the negative samples produced from an optimizer $\mathrm{Opt}(\cdot)$ that attempts to maximize the current learned model, $f_\theta$. %
We will discuss our choice of $\mathrm{Opt}$ in the Appendix Section~\ref{app:details}.  
 
\niparagraph{Incorporating design constraints via infeasible points.}
While prior work~\citep{trabucco2021conservative} simply optimizes Equation~\ref{eqn:training} to learn a surrogate, this is not enough when optimizing over accelerators, as we will also show empirically (Appendix~\ref{app:additional_experiments}).
This is because explicit negative mining does not provide any information about accelerator design constraints. Fortunately, this information is provided by infeasible points, $\mathcal{D}_\text{infeasible}$. The training procedure in Equation~\ref{eqn:training} provides a simple way to do incorporate such infeasible points: we simply incorporate ${\mathbf{x}}'_i \sim \mathcal{D}_{\text{infeasible}}$ as additional negative samples and maximize the prediction at these points.
This gives rise to our final objective:
\begin{equation}
\label{eqn:final_training}
    \min_\theta~~ \mathcal{L}^\text{inf}(\theta) := \mathcal{L}(\theta)
    - \textcolor{blue}{\beta \mathbb{E}_{{\mathbf{x}}'_i \sim \mathcal{D}_{\text{infeasible}}}\left[ f_\theta({\mathbf{x}}'_i) \right]}
\end{equation}

\niparagraph{Multi-application optimization and zero-shot generalization.}
One of the central benefits of a data-driven approach is that it enables learning powerful surrogates that generalize over the space of applications, potentially being effective for new unseen application domains. In our experiments, we evaluate \methodname\ on designing accelerators for multiple applications denoted as $k=1, \cdots, K$, jointly or for a novel unseen application. In this case, we utilized a dataset $\mathcal{D} = \{\mathcal{D}_1, \cdots, \mathcal{D}_K\}$, where each $\mathcal{D}_k$ consists of a set of accelerator designs, annotated with the latency value and the feasibility criterion for a given application $k$. While there are a few overlapping designs that appear in each of the parts of the dataset, and these designs are annotated with latency values for more than one application, most of the designs only appear in one part, and so our training procedure does not have access to the latency values corresponding to more than one application for such designs. This presents a challenging scenario for any data-driven method, which must generalize correctly to unseen combinations of accelerators and applications. 

To train a single conservative surrogate $f_\theta({\mathbf{x}})$ for multiple applications, we extend the training procedure in Equation~\ref{eqn:final_training} to incorporate \textit{context vectors} ${\mathbf{c}}_k \in \mathbb{R}^d$ for various applications driven by a list of application properties in Table~\ref{tab:models}. The learned function in this setting is now conditioned on the context $f_\theta({\mathbf{x}}, {\mathbf{c}}_k)$. We train $f_\theta$ via the objective in Equation~\ref{eqn:final_training}, but in expectation over all the contexts and their corresponding datasets: $\min_\theta \mathbb{E}_{\textcolor{blue}{k \sim [K]}}\left[\mathcal{L}^\text{inf}_k(\theta)\right]$. Once such a contextual surrogate is learned, we can either optimize the average surrogate across a set of contexts $\{{\mathbf{c}}_i, {\mathbf{c}}_2, \cdots, {\mathbf{c}}_n\}$ to obtain an accelerator that is optimal for multiple applications simultaneously on an average (``multi-model'' optimization), or optimize this contextual surrogate for a novel context vector, corresponding to an unseen application (``zero-shot'' generalization). In this case, \methodname\ is not allowed to train on any data corresponding to this new unseen application.  While such zero-shot generalization might appear surprising at first, note that the context vectors are not simply one-hot vectors, but consist of parameters with semantic information, which the surrogate can generalize over.

\niparagraph{Optimizing the learned conservative surrogate.} Prior work~\citep{yazdanbakhsh2021apollo} has shown that the most effective optimizers for accelerator design are meta-heuristic/evolutionary optimizers. We therefore choose to utilize, firefly~\citep{yang2010nature,yang2010eagle,liu2013adaptive} to optimize our conservative surrogate. This algorithm maintains a set of optimization candidates (a.k.a. ``fireflies'') and jointly update them towards regions of low objective value, while adjusting their relative distances appropriately to ensure multiple high-performing, but diverse solutions. We discuss additional details in Appendix~\ref{sec:practical_implementation}.

\niparagraph{Cross validation: which model and checkpoint should we evaluate?} Similarly to supervised learning, models trained via Equation~\ref{eqn:final_training} can overfit, leading to poor solutions. 
Thus, we require a procedure to select which hyperparameters and checkpoints should actually be used for the design.
This is crucial, because we cannot arbitrarily evaluate as many models as we want against the simulator.
While effective methods for model selection have been hard to develop in offline optimization~\citep{trabucco2021conservative,trabucco2021designbench}, we devised a simple scheme using a validation set for choosing the values of $\alpha$ and $\beta$ (Equation~\ref{eqn:final_training}), as well as which checkpoint to utilize for generating the design.
For each training run, we hold out the best 20\% of the points out of the training set and use them \textit{only} for cross-validation as follows.
Typical cross-validation strategies in supervised learning involve tracking validation error (or risk), but since our model is trained conservatively, its predictions may not match the ground truth, making such validation risk values unsuitable for our use case.
Instead, we track Kendall's ranking correlation between the predictions of the learned model $f_\theta({\mathbf{x}}_i)$ and the ground truth values $y_i$ (Appendix~\ref{app:details}) for the held-out points for each run.
We pick values of $\alpha$, $\beta$ and the checkpoint that attain the highest validation ranking correlation.
We present the pseudo-code for \methodname\ (Algorithm~\ref{alg:prime}) and implementation details in Appendix~\ref{sec:practical_implementation}.
\section{Experimental Evaluation}
\label{sec:eval}
Our evaluations aim to answer the following questions: \textbf{Q(1)} {Can \methodname\ design accelerators tailored for a given application that are better than the best observed configuration in the training dataset, and comparable to or better than state-of-the-art simulation-driven methods under a given simulator-query budget?} \textbf{Q(2)} {Does \methodname\ reduce the total simulation time compared to other methods?} \textbf{Q(3)} {Can \methodname\ produce hardware accelerators for a family of different applications?} \textbf{Q(4)} {Can \methodname\ trained for a family of applications extrapolate to designing a high-performing accelerator for a new, unseen application, thereby enabling effective data reuse?} Additionally, we ablate various properties of \methodname\ (Appendix~\ref{sec:appx_ablation}) and evaluate its efficacy in designing different accelerators with distinct dataflow architectures, with a larger search space (up to 2.5$\times10^{114}$ possible candidates). We also show that \methodname\ improves over a human-engineered accelerator in Appendix~\ref{app:human_engineered}. We also show how \methodname\ can be reused when the design constraints (such as area constraints) change in Appendix~\ref{app:transfer}. 

\niparagraph{Baselines and comparisons.}
We compare \methodname\ against three state-of-the-art online optimization methods that actively query the simulator: \textbf{(1)} evolutionary search with the firefly optimizer~\citep{yazdanbakhsh2021apollo} (``Evolutionary''), which is the shown to the best online method in designing the accelerators that we consider by prior work~\citep{yazdanbakhsh2021apollo}. \textbf{(2)} Bayesian Optimization (``Bayes Opt'')~\citep{vizier:sigkdd:2017} implemented via the Google Vizier framework, a Gaussian process-based optimizer that is widely use to tune machine learning models at Google and more broadly.
\textbf{(3)} MBO~\citep{angermueller2019model}, a state-of-the-art online MBO method for designing biological sequences. In all of our experiments, we allow all the methods access to an identical number of feasible points. Note however that while online methods can actively select which points to query, our offline method \methodname\ is constrained to utilizing the worst performing feasible designs. 
``$\mathcal{D}$(Best in Training)'' denotes the best latency value in the training dataset used in \methodname. We also present ablation results with different components
\begin{wrapfigure}{r}{0.3\textwidth}
    \centering
    \vspace{-0.4cm}
    \includegraphics[width=\linewidth]{figs/motivation/simulation_time.png}
    \vspace{-0.5cm}
    \caption{\small{Comparing the total simulation time needed by \methodname\ and online evolutionary optimization on MobileNetEdge. Note that optimizing \methodname\ only requires about \textbf{7\%} of the total simulation time of the online method.}}
    \vspace{-0.7cm}
    \label{fig:convergence_time}
\end{wrapfigure}
of our method removed in Appendix~\ref{sec:appx_ablation}, where we observe that utilizing both infeasible points and negative sampling are generally important for attaining good optimization performance. 
Appendix~\ref{app:additional_experiments} presents additional comparisons to COMs~\citep{trabucco2021conservative}---which only obtains negative samples via gradient ascent on the learned surrogate and does not utilize infeasible points---and P3BO~\citep{p3bo:arxiv:2020}---an state-of-the-art online method. \methodname\ outperforms both of these prior approaches. 

\niparagraph{Architecting application-specific accelerators.}
We first evaluate \methodname\ in designing specialized accelerators for each of the applications in Table~\ref{tab:models}.
We train a conservative surrogate using the method in Section~\ref{sec:method} on the logged dataset for each application separately.
The area constraint $\alpha$ (Equation~\ref{eqn:opt_prob}) is set to $\alpha = 29~\text{mm}^2$, a realistic budget for accelerators~\citep{yazdanbakhsh2021apollo}. Table~\ref{table:results_single_task} summarizes the results.
On average, the best accelerators designed by \methodname\ outperforms the best accelerator configuration in the training dataset (last row Table~\ref{table:results_single_task}), by \textbf{2.46$\times$}.
\input{tables/single_models} 
\methodname\ also outperforms the accelerators in the best online method by \textbf{1.54$\times$} (up to 5.80$\times$ and 6.62$\times$ in t-RNN Dec and t-RNN Enc, respectively).
Moreover, perhaps surprisingly, \methodname\ generates accelerators that are better than the best online optimization method for \textbf{7/9 applications}, and performs on par in the other two scenarios (on average only 6.8$\%$ slowdown compared to the best accelerator with online methods in \mfive and \msix). 
These results indicates that offline optimization of accelerators using \methodname\ can be more data-efficient compared to online methods with active simulation queries. We also emphasize again that \methodname\ exhibits this strong performance by only learning from an equal number of feasible points as the online methods, and these are the worst feasible points in the training dataset. 


To answer \textbf{Q(2)}, we compare the total simulation time of \methodname\ and the best evolutionary approach from Table~\ref{table:results_single_task} on the MobileNetEdge domain.
On average, not only that \methodname\ outperforms the best online method, but also considerably reduces the total simulation time by \textbf{93\%}, as shown in Figure~\ref{fig:convergence_time}.
Even the total simulation time to the first occurrence of the final design that is eventually returned by the online methods is about 11$\times$ what \methodname\ requires to find the better design.
This indicates that data-driven \methodname\ is much more preferred, both because it attains a better performance, and because it requires only a tiny fraction of the simulation time of online methods.

\niparagraph{Architecting accelerators for multiple applications.}
To answer \textbf{Q(3)}, we evaluate the efficacy of the contextual version of \methodname\ in designing an accelerator that attains the lowest latency averaged over a set of application domains.
\input{tables/multi_models}
As discussed previously, the training data used does not label a given accelerator with latency values corresponding to each application, and thus, \methodname\ must extrapolate accurately to estimate the latency of an accelerator for a context it is not paired with in the training dataset.
This also means that \methodname\ cannot simply return the accelerator with the best average latency and must run non-trivial optimization to find a design that actually accelerates all the applications. 
We evaluate our method in seven different multi-application design scenarios (Table~\ref{table:results_multi_task}), 
\begin{wrapfigure}{r}{0.3\textwidth}
    \centering
    \vspace{-0.5cm}
    \includegraphics[width=\linewidth]{figs/motivation/convergence_time_seven_models.png}
    \vspace{-0.5cm}
    \caption{\small{Comparing the total simulation time needed by \methodname\ and online methods on seven models (Area $\leq$ 100mm$^2$)~. \methodname\ only requires about 1\%, 6\%, and 0.9\% of the total simulation time of Evolutionary, MBO, and Bayes Opt, respectively, although \methodname\ outperforms the best online method by 41\%.}}
    \vspace{-0.8cm}
    \label{fig:convergence_time_seven_models}
\end{wrapfigure}
comprising various combinations of models from Table~\ref{tab:models} and under different area constraints, where the smallest set consists of the three MobileNet variants and the largest set consists of nine models from image classification, object detection, image segmentation, and speech recognition.
This scenario is also especially challenging for online methods since the number of jointly feasible designs is expected to drop significantly as more applications are added.
For instance, for the case of the MobileNet variants, random sampling only finds a few (20-30) accelerator configurations that are jointly feasible and high-performing (Appendix~\ref{sec:appx_multi_task_tsne}---Figure~\ref{fig:tsne_overlap}), but for the largest scenario of nine applications, there are very few jointly feasible designs.

Table~\ref{table:results_multi_task} shows that, on average, \methodname\ finds accelerators that outperform the best online method by \textbf{1.2$\times$} (up to 41\%).
While \methodname\ performs similar to online methods in the smallest three-model scenario (first row), it outperforms online methods as the number of applications increases and the set of applications become more diverse.
In addition, comparing with the best jointly feasible design point across the target applications, \methodname\ finds significantly better accelerators (3.95$\times$).
Finally, as the number of model increases the total simulation time difference between online methods and \methodname\ further widens (Figure~\ref{fig:convergence_time_seven_models}).
These results indicate that \methodname\ is effective in designing accelerators jointly optimized across multiple applications while reusing the same dataset as for the single-task, and scales more favorably than its simulation-driven counterparts.
Appendix~\ref{app:analysis} expounds on the details of the designed accelerators for nine applications, comparing our method and the best online method.

\niparagraph{Accelerating previously unseen applications (``zero-shot'' optimization).}
Finally, we answer \textbf{Q(4)} by demonstrating that our data-driven offline method, \methodname\ enables effective data reuse by using logged accelerator data from a set of applications to design an accelerator for an unseen new application, without requiring any training on data from the new unseen application(s).
We train a contextual version of \methodname\ using a set of ``training applications'' and then optimize an accelerator using the learned surrogate with different contexts corresponding to ``test applications,'' without any additional designs evaluated against the test application. In this case, we train the evolutionary (online) method on the test application domain for 1000 iterations, for comparison. We also compare directly to the accelerator found by the evolutionary (online) method when jointly optimizing the training applications in Appendix~\ref{app:additional_experiments_multi}, but found that to be worse than running a few iterations of the evolutionary (online) method on the test applications. 
Table~\ref{table:zero_shot} shows that, on an average, \methodname\ outperforms the best online method on the test applications by \textbf{1.26$\times$} (up to 66$\%$) and only 2$\%$ slowdown in one case.
Note that the difference in performance increases as the number of training applications increases.
These results show the effectiveness of \methodname\ in the zero-shot setting (more results in Appendix~\ref{sec:app_zero_shot}) and highlight the effectiveness of data re-use by our offline approach.

\niparagraph{Applying \methodname\ on other accelerator architectures and dataflows.}
Finally, to test the the generalizability of \methodname\ to other accelerator architectures~\citet{kao2020confuciux}, we evaluate \methodname\ to optimize latency of two style of dataflow accelerators---NVDLA-style and ShiDianNao-style---across three applications (Appendix~\ref{sec:dla_shi_fast} details the methodology).
As shown in Table~\ref{table:dla_shi}, \methodname\ outperforms the online evolutionary method by 6\% and improves over the best point in the training dataset by 3.75$\times$.
This demonstrates that \methodname\ is effective in optimizing accelerators with different dataflow architectures and can successfully optimize over extremely large hardware search spaces.
\input{tables/zero_shot}
\input{tables/dla_shi}





















