This application is based on and claims priority under 35 U.S.C. § 119 to British Patent Application No. GB1913353.7, filed on Sep. 16, 2019 in the Intellectual Property Office of the United Kingdom, and Korean Patent Application No. 10-2020-0034093, filed Mar. 19, 2020, in the Korean Intellectual Property Office, the disclosures of which are incorporated by reference herein in their entireties.
The disclosure relates to an electronic device and a method for controlling thereof and, for example, to an electronic device for determining a pair of accelerators and a neural network capable of outputting optimal accuracy and efficiency metrics and a method for controlling thereof.
FPGA accelerator are especially useful at low-batch DNN inference tasks, in custom hardware (HW) configurations, and when tailored to specific properties of a DNN such as sparsity or custom precision. One of the FPGA strengths is that the HW design cycle is relatively short when compared to custom application-specific integrated circuits (ASICs). However, this strength comes with an interesting side effect: FPGA accelerator HW is typically designed after the algorithm (e.g., DNN) is decided and locked down.
Even if the accelerator is software-programmable, its HW is usually overoptimized for a specific DNN to maximize its efficiency. As a result, different DNNs are typically inefficient with the same HW. To address this “overoptimization” problem, FPGA designs are typically configurable at the HW level. In this case, when a new DNN is discovered, the accelerator parameters can be tuned to the new DNN to maximize the HW efficiency. Even with the HW configurability, FPGA accelerators have the disadvantage of always needing to catch up to new DNNs.
The way of designing a DNN may be automated and may be termed neural architecture search (NAS). NAS has been successful in discovering DNN models that achieve state-of-the-art accuracy on image classification, super-resolution, speech recognition and machine translation.
A further development termed FNAS is described in “Accuracy vs. Efficiency: Achieving Both Through FPGA-Implementation Aware Neural Architecture Search” by Jiang et al, published in arXiv e-prints (January, 2019). FNAS is a HW-aware NAS which has been used in an attempt to discover DNNs that minimize latency on a given FPGA accelerator. FNAS is useful in discovering convolutional neural networks (CNNs) that are suited to a particular FPGA accelerator. Other HW-aware NAS adds latency to the reward function so that discovered models optimize both accuracy and inference latency, for example, when running on mobile devices.
It is also noted that for CPUs and GPUs, the algorithm is optimized to fit the existing HW, and for successful ASICs, it is necessary to build-in a lot of flexibility and programmability to achieve some future-proofing accuracy.
Embodiments of the disclosure provide and electronic device for determining a pair of accelerators and a neural network capable of outputting optimal accuracy and efficiency metrics and a method for controlling thereof.
According to an example embodiment, a method for controlling an electronic device comprising a memory storing a plurality of accelerators and a plurality of neural networks includes: selecting a first neural network among the plurality of neural networks and selecting a first accelerator configured to implement the first neural network among the plurality of accelerators, implementing the first neural network on the first accelerator to obtain information associated with an implementation result, obtaining a first reward value for the first accelerator and the first neural network based on the information associated with the implementation, selecting a second neural network to be implemented on the first accelerator among the plurality of neural networks, implementing the second neural network on the first accelerator to obtain the information associated with the implementation result, obtaining a second reward value for the first accelerator and the second neural network based on the information associated with the implementation, and selecting a neural network and an accelerator having a largest reward value among the plurality of neural networks and the plurality of accelerators based on the first reward value and the second reward value.
According to an example embodiment, an electronic device includes: a memory for storing a plurality of accelerators and a plurality of neural networks and a processor configured to: select a first neural network among the plurality of neural networks and select a first accelerator configured to implement the first neural network among the plurality of accelerators, implement the first neural network on the first accelerator to obtain information associated with the implementation result, obtain a first reward value for the first accelerator and the first neural network based on the information associated with the implementation, select a second neural network to be implemented on the first accelerator among the plurality of neural networks, implement the second neural network on the first accelerator to obtain the information associated with the implementation result, obtain a second reward value for the first accelerator and the second neural network based on the information associated with the implementation, and select a neural network and an accelerator having a largest reward value among the plurality of neural networks and the plurality of accelerators based on the first reward value and the second reward value.
The above and other aspects, features and advantages of certain embodiments of the present disclosure will be more apparent from the following detailed description, taken in conjunction with the accompanying drawings, in which:
Hereinbelow, the disclosure will be described in greater detail with reference to the attached drawings.
The memory 110 may store instructions or data related to at least one other component of the electronic device 100. An instruction may refer, for example, to one action statement which can be executed by the processor 120 in a program creation language, and may be a minimum unit for the execution or operation of the program. The memory 110 may be accessed by the processor 120, and reading/writing/modifying/updating, or the like, data by the processor 120 may be performed.
The memory 110 may store a plurality of accelerators (e.g., including various processing circuitry and/or executable program elements) 10-1, 10-2, . . . , 10-N and a plurality of neural networks (e.g., including various processing circuitry and/or executable program elements) 20-1, 20-2, . . . , 20-N. The memory 110 may store an accelerator sub-search space including a plurality of accelerators 10-1, 10-2, . . . , 10-N and a neural sub-search space including a plurality of neural networks 20-1, 20-2, . . . , 20-N. The total search space may be defined by the following Equation 1.
S=S
NN
×S
FPGA [Equation 1]
Where SNN is the sub-search space for the neural network, and the SFPGA is the sub-search space for the FPGA. If the accelerator is implemented as another type of accelerator rather than the FPGA, the memory 110 can store a sub-search space for searching and selecting an accelerator of the implemented type. The processor 120 may access each search space stored in the memory 110 to search and select a neural network or an accelerator. The related embodiment will be described below.
A neural network (or artificial neural network) may refer, for example, to a model capable of processing data input using an artificial intelligence (AI) algorithm. The neural network may include a plurality of layers, and the layer may refer to each step of the neural network. A plurality of layers included in a neural network have a plurality of weight values, and operations of a layer can be performed through operation result of a previous layer and an operation of a plurality of weights. The neural network may include a combination of several layers, and the layer may be represented by a plurality of weights. A neural network may include various processing circuitry and/or executable program elements.
Examples of neural networks may include, but are not limited to, a convolutional neural network (CNN), a deep neural network (DNN), a recurrent neural network (RNN), a restricted Boltzmann machine (RBM), a deep belief network (DBN), a bidirectional recurrent deep neural network (BRDNN), deep Q-networks, or the like. The CNN may be include different blocks selected from conv1×1, conv3×3 and pool3×3. As another example, the neural network may include a GZIP compression type neural network, which is an algorithm that includes two main computation blocks that perform LZ77 compression and Huffman encoding. The LZ77 calculation block includes parameters such as compression window size and maximum compression length. The Huffman computation block may have parameters such as Huffman tree size, tree update frequency, and the like. These parameters affect the end result of the GZIP string compression algorithm, and typically there may be a trade-off at the compression ratio and compression rate.
Each of the plurality of neural networks may include a first configurable parameter. The hardware or software characteristics of each of the plurality of neural networks may be determined by a number (or weight) corresponding to a configurable parameter included in each of the neural networks. The first configurable parameter may include at least one of an operational mode of each neural network, or a layer connection scheme. The operational mode may include the type of operation performed between layers included in the neural network, the number of times, and the like. The layer connection scheme may include the number of layers included in each operation network, the number of stacks or cells included in the layer, the connection relationship between layers, and the like.
The accelerator may refer, for example, to a hardware device capable of increasing the amount or processing speed of data to be processed by a neural network learned on the basis of an artificial intelligence (AI) algorithm. In one example, the accelerator may be implemented as a platform for implementing a neural network, such as, for example, and without limitation, a field-programmable gate-array (FPGA) accelerator or an application-specific integrated circuit (ASIC), or the like.
Each of the plurality of accelerators may include a second configurable parameter. The hardware or software characteristics of each of the plurality of accelerators may be determined according to a value corresponding to a second configurable parameter each including. The second configurable parameter included in each of the plurality of accelerators may include, for example, and without limitation, at least one of a parallelization parameter (e.g., parallel output functions or parallel output pixels), buffer depth (e.g., buffer depth for input, output and weight buffers), pooling engine parameters, memory interface width parameters, convolution engine ratio parameter, or the like.
The memory 110 may store an evaluation model 30. The evaluation model 30 may refer, for example, to an AI model that can output a reward value for the accelerator and neural network selected by the processor 120, and can be controlled by the processor 120. For example, the evaluation model 30 may perform normalization on information related to the implementation obtained by implementing the selected neural network on the selected accelerator (e.g., accuracy metrics and efficiency metrics).
The evaluation model 30 may perform a weighted sum operation on the normalized accuracy metrics and the efficiency metrics to output a reward value. The process of normalizing each metrics and performing a weighted sum operation by the evaluation model 30 will be described in greater detail below. The larger the reward value for the pair of accelerators and neural networks output by the evaluation model 30, the more accurate and efficient implementation and operation of the pair of accelerators and neural networks may be performed.
The evaluation model 30 may limit the value at which the evaluation model 30 can output through a threshold corresponding to each of the accuracy metrics and the efficiency metrics. For example, the algorithm to be applied for the accuracy metrics and efficiency metrics by the evaluation model 30 to output the reward value may be implemented as in Equation 2.
:{m|∈
n∧∀i[mi≤thi]}→
(m)=w·m [Equation 2]
In Equation 2, m may refer to the accuracy metrics or efficiency metrics, w may refer to a weight vector of m, and th may refer to a threshold value vector of m. The evaluation model 30 may output the reward value using Equation 3 below.
In Equation 3, ar is the area of the accelerator, lat (e.g., latency) is a waiting time, acc is an accuracy value, and w1, w2 and w3 are weight sets for each area, latency, and accuracy. If optimization is performed on the search space s, the evaluation model output E(s)=m satisfies a given constraint (e.g., a wait time of less than a particular value).
The accuracy metrics may refer, for example, to a value that indicates with which accuracy the neural network has been implemented on the accelerator. The efficiency metrics may refer, for example, to a value that indicates at which degree the neural networks can perform an optimized implementation on the accelerator. The efficiency metrics may include, for example, and without limitation, at least one of a latency metrics, a power metrics, an area metrics of the accelerator when a neural network is implemented on the accelerator, or the like.
The memory 110 may include a first predictive model 40 and a second predictive model 50. The first predictive model 40 may refer, for example, to an AI model capable of outputting an estimated value of hardware performance corresponding to the input accelerator and the neural network. The hardware performance corresponding to the first accelerator and the first neural network may include the latency or power required when the first neural network is implemented on the first accelerator.
The first predictive model 40 may output an estimated value of the latency or power that may be required when the first neural network is implemented on the first accelerator. The first hardware criteria may be a predetermined value at the time of design of the first predictive model 40, but may be updated by the processor 120. The embodiment associated with the first predictive model 40 will be described in greater detail below.
The second predictive model 50 may refer, for example, to an AI model capable of outputting an estimated value of hardware performance corresponding to the neural network. For example, when the first neural network is input, the second predictive model 50 may output an estimated value of the hardware performance corresponding to the first neural network. The estimated value of the hardware performance corresponding to the first neural network may include, for example, and without limitation, at least one of a latency predicted to be required when the first neural network is implemented at a particular accelerator, a memory footprint of the first neural network, or the like. The memory foot print of the first neural network may refer, for example, to the size of the space occupied by the first neural network on the memory 110 or the first accelerator. An example embodiment associated with the second predictive model 50 is described in greater detail below.
The first predictive model 40 and the second predictive model 50 may be controlled by the processor 120. Each model may be learned by the processor 120. For example, the processor 120 may input the first accelerator and the first neural network to the first predictive model to obtain an estimated value of the hardware performance of the first accelerator and the first neural network. The processor 120 may train the first predictive model 40 to output an optimal estimation value that may minimize and/or reduce the difference between the hardware performance value that can be obtained when the first neural network is implemented on the first accelerator and the obtained estimation value.
For example, the processor 120 may input the first neural network to the second predictive model 50 to obtain an estimated value of the hardware performance of the first neural network. The processor 120 can train the second predictive model 50 to output an optimal estimation value that can minimize and/or reduce the difference between the hardware performance value that can be obtained through the first neural network when the actual first neural network is implemented in a particular accelerator and the obtained estimation value.
The memory 110 may include a policy function model 60. The policy function model 60 may refer, for example, to an AI model that can output a probability value corresponding to a configurable parameter included in each of a neural network and an accelerator, and can be controlled by processor 120. In an example embodiment, when a plurality of neural networks are input, the policy function model 60 may apply a policy function to a first configurable parameter included in each neural network to output a probability value corresponding to each of the first configurable parameters. The policy function may refer, for example, to a function that can give a high probability value for a parameter that enables outputting a high reward value of the configurable parameters and can include a plurality of parameters. The plurality of parameters included in the policy function may be updated by the control of the processor 120.
The probability value corresponding to the first configurable parameter may refer, for example, to a probability value of whether the neural network including the first configurable parameter is a neural network capable of outputting a higher reward value than the other neural network. For example, a first configurable parameter may be an operation method, a first neural network may perform a first operation method, and a second neural network may perform a second operation method. When the first neural network and the second neural network are input, the policy function model 60 can apply a policy function to an operation method included in each neural network to output a probability value corresponding to each operation method. If the probability corresponding to the first operation method is 40% and the probability corresponding to the second operation method is 60%, the processor 120 may select a case where the probability of selecting the first neural network including the first operation method among the plurality of neural networks is 40%, and the probability of selecting the second neural network including the second operation method is 60%.
The policy function may be applied to the possible parameters to output a probability value corresponding to each of the second configurable parameters. The probability value corresponding to the second configurable parameter may refer, for example, to a probability value for which accelerator may output a higher reward value than the other accelerator, including the second configurable parameter. For example, if the second configurable parameter included in the accelerator is a convolution engine rate parameter, the first accelerator includes a convolution engine rate parameter, and the second neural network includes a convolution engine rate parameter, when the first accelerator and the second accelerator are input, the policy function model 60 may apply a policy function to the accelerator including each of the first and second convolution engine rate parameters to output a probability value corresponding to each convolution engine rate parameter. If the probability of selecting the first convolution engine rate parameter is 40% and the probability of selecting the second convolution engine rate parameter is 60%, the processor 120 may select a case where the probability of selecting the first accelerator including the first convolution engine rate parameter of the plurality of accelerators is 40%, and the probability of selecting the second accelerator including the second convolution engine rate parameter is 60%.
The evaluation model 30, the first predictive model 40, the second predictive model 50, and the policy function model 60 may have been stored in a non-volatile memory and then may be loaded to a volatile memory under the control of the processor 120. The volatile memory may be included in the processor 120 as an element of the processor 120 as illustrated in
The non-volatile memory may refer, for example, to a memory capable of maintaining stored information even if the power supply is interrupted. For example, the non-volatile memory may include, for example, and without limitation, at least one of a flash memory, a programmable read-only memory (PROM), a magnetoresistive random access memory (MRAM), a resistive random access memory (RRAM), or the like. The volatile memory may refer, for example, to a memory in which continuous power supply is required to maintain stored information. For example, the volatile memory may include, without limitation, at least one of dynamic random-access memory (DRAM), static random access memory (SRAM), or the like.
The processor 120 may be electrically connected to the memory 110 and control the overall operation of the electronic device 100. For example, the processor 120 may select one of the plurality of neural networks stored in the neural network sub-search space by executing at least one instruction stored in the memory 110. The processor 120 may access a neural network sub-search space stored in memory 110. The processor 120 may input a plurality of neural networks included in the neural network sub-search space into the policy metric function model 60 to obtain a probability value corresponding to a first configurable parameter included in each of the plurality of neural networks. For example, if the first configurable parameter has a connection scheme of a layer, the processor 120 may input a plurality of neural networks into the policy function model 60 to obtain a probability value corresponding to a layer connection scheme of each of the plurality of neural networks. If the probability values corresponding to the layer connection scheme of each of the first neural network and the second neural network are 60% and 40%, respectively, the processor 120 may select the first neural network and the second neural network of the plurality of neural networks with a probability of 60% and 40%, respectively.
The processor 120 may select an accelerator to implement a selected neural network of the plurality of accelerators. The processor 120 may access the sub-search space of the accelerator stored in the memory 110. The processor 120 may input a plurality of accelerators stored in the accelerator sub-search space into the policy function model 60 to obtain a probability value corresponding to a second configurable parameter included in each of the plurality of accelerators. For example, if the second configurable parameter is a parallelization parameter, the processor 120 may enter a plurality of accelerators into the policy function model 60 to obtain a probability value corresponding to the parallelization parameter included in each of the plurality of accelerators. If the probability values corresponding to the parallelization parameters which each of the first accelerator and the second accelerator includes are 60% and 40%, respectively, the processor 120 may select the first accelerator and the second accelerator among the plurality of accelerators with the probabilities of 60% and 40%, respectively, as the accelerator to implement the first neural network.
In an example embodiment, when a first neural network among a plurality of neural networks is selected, the processor 120 may obtain an estimated value of the hardware performance corresponding to the first neural network via the second predictive model 50 before selecting the accelerator to implement the first neural network of the plurality of accelerators. If the estimated value of the hardware performance corresponding to the first neural network does not satisfy the second hardware criteria, the processor 120 may select one of the plurality of neural networks again except for the first neural network. The processor 120 may input the first neural network to the second predictive model 50 to obtain an estimated value of the hardware performance corresponding to the first neural network. The estimated value of the hardware performance corresponding to the first neural network may include at least one of a latency predicted to take place when the first neural network is implemented in a particular accelerator or the memory foot print of the first neural network.
The processor 120 may identify whether an estimated value of the hardware performance corresponding to the neural network satisfies the second hardware criteria. If the estimated value of the hardware performance corresponding to the first neural network is identified to satisfy the second hardware criteria, the processor 120 may select the accelerator to implement the first neural network among the plurality of accelerators. If it is identified that the estimated value of the hardware performance corresponding to the first neural network does not satisfy the second hardware criterion, the processor 120 can select one neural network among the plurality of neural networks except for the first neural network. If the performance of the hardware corresponding to the first neural network does not satisfy the second hardware criterion, it may mean that high reward value may not be obtained through the first neural network. If the hardware performance of the first neural network is identified to not satisfy the second hardware criteria, the processor 120 can minimize and/or reduce unnecessary operations by excluding the first neural network. However, this is only an example embodiment, and the processor 120 may select the first accelerator to implement the first neural network of the plurality of accelerators immediately after selecting the first neural network among the plurality of neural networks.
In another embodiment, if the first neural network among the plurality of neural networks is selected, and the first accelerator in which the first neural network of the plurality of accelerators is to be implemented is selected, the processor 120 may input the first accelerator and the first neural network to the first predictive model 40 to obtain an estimated value of the hardware performance corresponding to the first accelerator and the first neural network. The hardware performance corresponding to the first accelerator and the first neural network may include the latency or power required when the first neural network is implemented on the first accelerator.
The processor 120 may identify whether an estimated value of the obtained hardware performance satisfies the first hardware criteria. If the estimated value of the obtained hardware performance is identified to satisfy the first hardware criterion, the processor 120 may implement the first neural network on the first accelerator and obtain information related to the implementation. If it is identified that the obtained hardware performance does not satisfy the first hardware criteria, the processor 120 may select another accelerator to implement the first neural network of the plurality of accelerators except for the first accelerator. That the hardware performance of the first neural network and the first accelerator does not satisfy the first hardware criterion may refer, for example, to a high reward value not being obtained via information related to the implementation obtained by obtaining the first neural network on the first accelerator. Thus, if it is identified that the hardware performance of the first neural network and the first accelerator does not satisfy the first hardware criteria, the processor 120 can minimize and/or reduce unnecessary operations by immediately excluding the first neural network and the first accelerator. However, this is only an example embodiment, and if the first accelerator and the first neural network are selected, the processor 120 may directly implement the selected accelerator and neural network without inputting the selected accelerator and neural network to the first predictive model 40 to obtain information related to the implementation.
The first hardware criteria and the second hardware criteria may be predetermined values obtained through experimentation or statistics, but may be updated by the processor 120. For example, if the threshold latency of the first hardware criteria is set to 100 ms, but the average value of the estimated value of the latency corresponding to the plurality of neural networks is identified as 50 ms, the processor 120 can reduce (e.g., to 60 ms) the threshold latency. The processor 120 may update the first hardware criteria or the second hardware criteria based on an estimated value of the hardware performance of the plurality of neural networks or a plurality of accelerators.
The processor 120 may implement the neural network selected on the selected accelerator to obtain information related to the implementation including implementation and accuracy and efficiency metrics. The processor 120 may input information related to the implementation to the evaluation model 30 to obtain a reward value corresponding to the selected accelerator and neural network. As described above, the evaluation model 30 may normalize the accuracy metrics and the efficiency metrics, and perform a weighted sum operation on the normalized index to output a reward value.
If the first reward value is obtained by implementing the first neural network on the first accelerator, the processor 120 may select a second neural network to be implemented on the first accelerator of the plurality of neural networks. The processor 120 may select a second neural network by searching for a neural network that may obtain a higher reward value than when implementing the first neural network on the first accelerator among the plurality of neural networks. The processor 120 may select a second neural network among the plurality of neural networks except for the first neural network in the same manner as the way to select the first neural network among the plurality of neural networks.
The processor 120 may obtain information related to the implementation by implementing a second neural network selected on the first accelerator. Before implementing the second neural network on the first accelerator, the processor 120 may input the first accelerator and the second neural network into the first prediction model 30 to identify whether the hardware performance corresponding to the first accelerator and the second neural network satisfies the first hardware criteria. If the hardware performance corresponding to the first accelerator and the second neural network is identified to satisfy the first hardware criteria, the processor 120 may implement the second neural network on the first accelerator to obtain information related to the implementation. However, this is only an example embodiment, and the processor 120 can obtain information related to the implementation directly without inputting the first accelerator and the second neural network to the first predictive model 30.
The processor 120 may implement the first accelerator and the second neural network to obtain the second reward value based on the obtained accuracy metrics and an efficiency metrics. The processor 120 may select a neural network and an accelerator having the largest reward value among the plurality of accelerators based on the first reward value and the second reward value. The second reward value being greater than the first reward value may refer, for example, to the implementing the first neural network on the first accelerator being more efficient and accurate than implementing the second neural network. The processor 120 may identify that the first accelerator and the second neural network pair are more optimized and/or improved pairs than the first accelerator and the first neural network pair.
The processor 120 may select an accelerator to implement a second neural network among the plurality of accelerators except for the first accelerator. When the second accelerator is selected as the accelerator for implementing the second neural network, the processor 120 may implement the second neural network on the second accelerator to obtain information related to the implementation and obtain a third reward value based on the information associated with the obtained implementation. The processor 120 may compare the second reward value with the third reward value to select a pair of accelerator and neural networks that can output a higher reward value. The processor 120 can select a pair of neural networks and accelerators that can output the largest reward value among the stored accelerator and neural networks by repeating the above operation. A pair of neural networks and accelerators that can output the largest reward value can perform specific tasks, such as, for example, and without limitation, image classification, voice recognition, or the like, accurately and efficiently than other pairs.
The processor 120 may include various processing circuitry, such as, for example, and without limitation, one or more among a central processing unit (CPU), a dedicated processor, a micro controller unit (MCU), a micro processing unit (MPU), a controller, an application processor (AP), a communication processor (CP), an Advanced Reduced instruction set computing (RISC) Machine (ARM) processor for processing a digital signal, or the like, or may be defined as a corresponding term. The processor 120 may be implemented, for example, and without limitation, in a system on chip (SoC) type or a large scale integration (LSI) type which a processing algorithm is implemented therein or in a field programmable gate array (FPGA). The processor 120 may perform various functions by executing computer executable instructions stored in the memory 110. The processor 120 may include at least one of a graphics-processing unit (GPU), neural processing unit (NPU), visual processing unit (VPU) that may include AI-only processors, for performing an AI function.
The function related to AI operates through the processor and memory. One or a plurality of processor may include, for example, and without limitation, a general-purpose processor such as a central processor (CPU), an application processor (AP), a digital signal processor (DSP), a dedicated processor, or the like, a graphics-only processor such as a graphics processor (GPU), a vision processing unit (VPU), an AI-only processor such as a neural network processor (NPU), or the like, but the processor is not limited thereto. The one or a plurality of processors may control processing of the input data according to a predefined operating rule or AI model stored in the memory. If one or a plurality of processors are an AI-only processor, the AI-only processor may be designed with a hardware structure specialized for the processing of a particular AI model.
Predetermined operating rule or AI model may be made through learning. For example, being made through learning may refer, for example, to a predetermined operating rule or AI model set to perform a desired feature (or purpose) is made by making a basic AI model trained using various training data using learning algorithm. The learning may be accomplished through a separate server and/or system, but is not limited thereto and may be implemented in an electronic apparatus. Examples of learning algorithms include, but are not limited to, supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning.
The AI model may be comprised of a plurality of neural network layers. Each of the plurality of neural network layers may include a plurality of weight values, and may perform a neural network operation through an operation between result of a previous layer and a plurality of parameters. The parameters included in the plurality of neural network layers may be optimized and/or improved by learning results of the AI model. For example, the plurality of weight values may be updated such that a loss value or a cost value obtained by the AI model may be reduced or minimized during the learning process.
The electronic device 100 may select a first neural network among the plurality of neural networks and select the first accelerator for implementing the first neural network among a plurality of accelerators in step S210. The process of selecting by the first neural network and the first accelerator by the electronic device 100 has been described, by way of non-limiting example, with reference to
The electronic device 100 may obtain an estimated value of the hardware performance corresponding to the first neural network and the first accelerator through the first predictive model in step S220. When the first neural network and the first accelerator are input, the first predictive model may output an estimate value of the hardware performance corresponding to the first neural network and the first accelerator. For example, the first predictive model may output a latency and power that is estimated to be required when implementing the first neural network on the first accelerator.
The electronic device 100 may identify whether the estimated value of the obtained hardware performance satisfies the first hardware criteria in step S230. For example, if the latency estimated to be required when implementing the first neural network on the first accelerator exceeds the first hardware criteria, the electronic device 100 may identify that an estimated value of the hardware performance corresponding to the first neural network and the first accelerator does not satisfy the first hardware criteria. As another example, if the power estimated to be consumed in implementing the first neural network on the first accelerator does not exceed the first hardware criteria, the electronic device 100 may identify that an estimated value of the hardware performance corresponding to the first neural network and the first accelerator satisfies the first hardware criteria.
If the estimated value of the hardware performance corresponding to the first neural network and the first accelerator does not satisfy the first hardware criteria (“No” in S230), the electronic device 100 can select a second accelerator to implement the first neural network among the accelerators except the first accelerator in step S240. That an estimated value of the hardware performance corresponding to the first neural network and the first accelerator does not satisfy the first hardware criteria may mean that a high reward value may not be obtained via the first neural network and the first accelerator. The electronic device 100 can minimize and/or reduce unnecessary operations by selecting a pair of neural networks and accelerators except for the first neural network and the first accelerator pair.
If the estimated value of the hardware performance corresponding to the first neural network and the first accelerator satisfies the first hardware criteria (“Yes” in S230), the electronic device 100 can implement the first neural network on the first accelerator in step S250. Since the estimated value of the hardware performance corresponding to the first neural network and the first accelerator satisfies the first hardware reference, the electronic device 100 may obtain information related to the implementation by implementing the first neural network on an actual first accelerator.
The electronic device 100 may select the first neural network among a plurality of neural networks in step S310. The process of selecting the first neural network by the electronic device 100 among the plurality of neural networks has been described above and thus, a duplicate description may not be repeated here.
The electronic device 100 can obtain an estimated value of the hardware performance corresponding to the first neural network through the second predictive model in step S320. When the first neural network is input, the second predictive model can output an estimated value of the hardware performance corresponding to the first neural network. For example, the second predictive model may estimate the latency or memory foot print of the first neural network estimated to be required when the first neural network is implemented on a particular accelerator.
The electronic device 100 can identify whether an estimated value of hardware performance corresponding to the obtained first neural network satisfies a second hardware reference in step S330. For example, if the latency estimated to be required when implementing the first neural network on a particular accelerator exceeds the second hardware reference, the electronic device 100 may identify that an estimated value of the hardware performance corresponding to the first neural network does not satisfy the second hardware criteria. As another example, if the capacity of the first neural network satisfies the second hardware criteria, the electronic device 100 may identify that an estimated value of the hardware performance corresponding to the first neural network satisfies the second hardware criteria.
If it is identified that the estimated value of the hardware performance corresponding to the first neural network does not satisfy the second hardware reference (“No” in S330), the electronic device 100 may select one of the plurality of neural networks except for the first neural network in step S340. That the estimated value of the hardware performance corresponding to the first neural network does not satisfy the second hardware criteria may mean that it does not obtain a high reward value via the first neural network. Thus, the electronic device 100 can minimize and/or reduce unnecessary operations by selecting another neural network of the plurality of neural networks except for the first neural network.
If it is identified that the estimated value of the hardware performance corresponding to the first neural network and the first accelerator satisfies the second hardware criteria (“Yes” in S330), the electronic device 100 can select the accelerator to implement the first neural network among the plurality of accelerators in step S350. The process of selecting by the electronic device 100 the accelerator to implement the first neural network has been described with reference to
As shown in
The method may be described as a reinforcement learning system to jointly optimize and/or improve the structure of a CNN with the underlying FPGA accelerator. As described above, the related art NAS may adjust the CNN to a specific FPGA accelerator or adjust the FPGA accelerator for the newly discovered CNN. However, the NAS according to the disclosure may design both the CNN and the FPGA accelerator corresponding thereto commonly.
The processor 120 shown in
S=O
1
×O
2
× . . . O
n (1)
Where Oi is the set of available options for the i-th decision. In each iteration t, the processor 120 generates a structure sequence st.
The sequence st is passed to the evaluation model which evaluates the proposed structure and creates a reward rt generated by the reward function R(st) based on evaluated metrics. The reward is then used to update the processor such that (as t→∞) it selects sequences st which maximize the reward function.
Different approaches to the problem of updating the processor exist. For example, in deep RL, a DNN may be used as a trainable component and it is updated using backpropagation. For example, in REINFORCE, which is used in the method outlined above in
[Equation 4]
∇(−r log p)(s|D)) (2)
Where D={D1, D2, . . . , Dn} is the set of probability distributions for each decision. Since s is 0 generated from a sequence of independently sampled decisions s1, s2, . . . , sn, the overall probability p(s|D) can be easily calculated as:
p(s|D)=Πi=1np(si|Di) (3)
RL-based algorithms are convenient because they do not impose any restrictions on what s elements are (what the available options are) or how the reward signal is calculated from s. Therefore, without the loss of generality, we can abstract away some of the details and, in practice, identify each available option simply by its index. The sequence of indices selected by the processor 120 is then transformed into a model and later evaluated to construct the reward signal independently from the algorithm described in this section. Different strategies can be used without undermining the base methodology. Following this property, a search space may be described using a shortened notation through Equation 5:
[Equation 5]
S=(k1,k2, . . . ,kn)ki∈N+ (4)
Where it should be understood as a search space S as defined in Equation 1 with |Oil=ki, where k are the number of options available for each parameter.
An overview of the generic algorithm is illustrated by way of non-limiting example in the Algorithm below:
(st)
(mt)
The REINFORCE algorithm or a similar algorithm may be used to conduct the search in conjunction with evaluating the metrics and generating the reward function. The algorithm may comprise a policy function that takes in weights/parameters and distributions Dt may be obtained from the policy function. A sequence st from the distributions may then be sampled. When searching the combined space, a sequence contains both FPGA parameters and CNN parameters. The sequence is then evaluated by an evaluation model 30 running the selected CNN on the selected FPGA, or simulating performance as described in more detail below). Metrics mt are measured by the evaluation model 30 such as latency, accuracy, area, power. These metrics are used as input to a reward function R(mt). The reward function, together with the probability of selecting that sequence, are used to update the parameters/weights of the policy function. This makes the policy function learn to choose a sequence that maximizes reward.
The method shown in
The search space described above is not fundamentally different from the definition provided in Equation 5 and does not imply any changes to the search algorithm. However, since the search domain for the two parts is different, it may be helpful to explicitly distinguish between them and use that differentiation to illustrate their synergy. Each sub-search space is discussed in greater detail below.
The search space for the cell design may be limited to a maximum of 7 operations (with the first and last fixed) and 9 connections. The operations are selected from the following available options: 3×3 or 1×1 convolutions, and 3×3 maximum pooling, all with stride 1, and connections are required to be “forward” (e.g., an adjacency matrix of the underlying computational graph needs to be upper-triangular). Additionally, concatenation and elementwise addition operations are inserted automatically when more than one connection is incoming to an operation. As in equation (1), the search space is defined as a list of options (e.g., configurable parameters), in this case, the CNN search space contains 5 operations with 3 options each, and 21 connections that can be either true or false (2 options)—the 21 connections are the non-zero values of the adjacency matrix between the 7 operations.
SCNN=(3,3, . . . 3,2,2, . . . 2) (6)
5 times 21 times
The search space does not directly capture the requirement of having at most 9 connections and therefore contains invalid points, e.g., points in the search space for which it may be impossible to create a valid model. Additionally, a point can be invalid if the output node of a cell is disconnected from the input.
The search space for the FPGA accelerator is defined by the configurable parameters for each of the key components of the FPGA accelerator. As described in greater detail below, the configurable parameters which define the search space include parallelization parameters (e.g. parallel output features or parallel output pixels), buffer depths (e.g. for the input, output and weights buffers), memory interface width, pooling engine usage and convolution engine ratio.
The configurable parameters of the convolution engine(s) include the parallelization parameters “filter_par” and “pixel_par” which determine the number of output feature maps and the number of output pixels to be generated in parallel, respectively. The parameter convolution engine ratio “ratio_conv_engines” is also configurable and is newly introduced in this method. The ratio may determine the number of DSPs assigned to each convolution engine. When set to 1, this may refer, for example, to there being a single general convolution engine which runs any type of convolution and the value of 1 may be considered to be the default setting used in the ChaiDNN library. When set to any number below 1, there are dual convolution engines—for example one of them specialized and tuned for 3×3 filters, and the other for 1×1 filters.
The configurable parameter for pooling engine usage is “pool_enable”. If this parameter is true, extra FPGA resource is used to create a standalone pooling engine. Otherwise the pooling functionality in the convolution engines is used.
In the implementation shown in
The FPGA communicates with the CPU and external DDR4 memory 404 via an AXI bus. As in the CHaiDNN library, a configurable parameter allows for configuring the memory interface width to achieve trade-off between resource and performance.
The following defines the FPGA accelerator search space for the parameters (filter_par, pixel_par, input, output, weights buffer depths, mem_interface_width, pool_en and ratio_conv_engines).
S_{FPGA}=(2,5,4,3,3,2,2,6) (7)
Considering the detail of the evaluation model in greater detail, it is noted that the area and latency of the accelerator are determined by parameters in the accelerator design space. Compiling all configurations in the design space to measure area and latency online during NAS is thus unlikely to be practical, since each compile takes hours and running CNN model simultaneously requires thousands of FPGAs. Accordingly, a fast evaluation model may be useful to find efficiency metrics.
For each accelerator architecture, step S406 of
When the configurable parameter “ratio_conv_engines” is set to less than 1, there may be two specialized convolution engines. In this case, the CLBs and DSPs usage of the convolution engines is decreased by 25% compared to the general convolution engine. This is a reasonable estimate of potential area savings that can arise due to specialization, and much larger savings have been demonstrated in the literature. In addition, when standalone pooling engine is used and the configurable parameter “pool_enable” is set to 1, a fixed amount of CLBs and DSPs are consumed.
BRAMs buffer data for the convolution and pooling engines. The size of input, output and weight buffers are configurable via the depth. This data is double buffered and thus consumes twice the amount of BRAMs. Fixed number of BRAMs are also dedicated to pooling (if enabled), bias, scale, mean, variance and beta. The number of BRAMs are calculated assuming that each BRAM is 36 Kbits. Based on the FPGA resource utilization, the next step is then to estimate the FPGA sizes in mm2 such that the area is quantified to a single number—silicon area. The area of each resource is scaled relative to CLB. Since this data is not available for the device that being used, data for similar devices is used from “Design Tradeoffs for Hard and Soft FPGA-based Network on Chips” by Abdelfattah et al publication in International Conference on Field Programmable Technology 95-103 (2012), which is incorporated by reference herein in its entirety. Account for the smaller process node (20 nm vs. 40 nm) and the different block properties (8 LUTs per CLB instead of 10, and 36 Kbit per BRAM instead of 9 Kbit) is also taken. The table below shows the estimated block area of a device which may be used in the method.
architecture with configurable parameters “filter_par”=16, “pixel_par”=64 is sized at 218.62
20 mm2.
Once the FPGA resource utilization in terms of CLBs, DSPs and BRAMs has been estimated. The latency may be estimated as part of step S406 of
The latency model may, for example, include two parts—1) latency lookup table of operations and 2) scheduler. From the NASBench search space, 85 operations are obtained including 3×3 and 1×1 convolutions, max pooling and element-wise addition operations of various dimensions. Running each operation on the FPGA accelerator with different configurations and using the performance evaluation API provided by CHaiDNN profiles the latency numbers which are then stored in a lookup table. The scheduler assigns operations to parallel compute units greedily and calculates the total latency of the CNN model using the latency of operations in the lookup table.
The latency of convolution operation depends on the parallelism factors “filter_par” and “pixel_par”. Since CHaiDNN does not support architectures “filter_par=8”, “pixel_par=4” and “filter_par=16”, “pixel_par=64”, their latency is interpolated using the measurements from the other architectures. In the case with dual convolution engines, one of them is specialized for 3×3 filters and the other for 1×1 filters. The performance of corresponding convolution is scaled in proportion to the number of engines available. For example, when the parameter ratio_conv_engines=0.75, the latency of 3×3 convolution increases by 1/0.75 and the latency of 1×1 convolution increases by 1/0.25.
In the original CHaiDNN accelerator, the data buffers must be sized to fit the entire input, output and filter tensors to achieve the highest possible throughput. However, if the image resolution increases and the CNN becomes deeper, such an allocation scheme is infeasible and restricts the feasibility of the accelerator. In the method described in
Some assumptions have thus been made when building the latency model due to the limitations on the current implementation of CHaiDNN. Firstly, the performance evaluation API does not support max pooling running on a standalone engine, thus the latency is modelled to be 2× faster than those running on the convolution engine. Secondly, the memory interface width cannot be configured independently. It is related to the DIET_CHAI_Z configuration which includes a set of parameters, and the memory interface width depends on the AXI bus which has reduced width when DIET_CHAI_Z is enabled. Without bringing all the parameters to the accelerator design space, the model assumes that the latency increases by 4% when the parameter “mem_interface_width” reduces from 512 bits to 256 bits. Lastly, the approach used in the model does not consider operation fusing which is used by the runtime of the accelerator to optimize latency.
As shown in
As
Having established that dual specialized engines can be a useful accelerator compute core, we take a closer look at the actual ratio of DSPs allocated to 1×1 and 3×3 convolutions. In a realistic NAS search scenario, we may constrain area for a specific FPGA device, and look for the fastest model that beats a certain accuracy threshold.
A machine-learning task (e.g. image classification) can be represented as a DNN search space, and the hardware accelerator can be expressed through its parameters (forming an FPGA search space). As shown in
As described above, there is a fundamental trade-off between the three metrics and thus, there is no trivial solution to the optimization problem. Additional steps must thus be taken in order to be able to define “better” and “worse” codesigns. Ultimately, we want a function which would take the metrics in interest and return a scalar value, interpreted as quality of the related codesign. We will use this function as our reward function R from the Algorithm REINFORCE shown above.
Two standard approaches to the MOO problem are considered. The first one is to combine the three metrics using a weighted sum into one objective function as described in “Multiobjective Optimization, Interactive and Evolutionary Approaches” by Branke et al published by Springer 2008, which is incorporated by reference herein in its entirety. The second one is to only consider the set of points which have all but one metric below/above a certain threshold and later optimize for the remaining metric (·—constraint method). We then also consider hybrid approaches where either fewer metrics are constrained and/or we also consider the constrained metrics when calculating the reward function. Formally, a generic MOO reward function we use in this work can be defined as Equation 6:
:{m|∈
n∧∀i[mi≤thi]}→
(m)=w·m [Equation 6]
where m is the vector of metrics we want to optimize for, w is the vector of their weights and is the vector of thresholds used to constrain the function's domain.
For cases where at least two metrics are summed together we normalize their values to make them more comparable between each other, as different metrics use different units and have values from different ranges. A similar effect could be achieved by adjusting their weights relatively to their absolute values but we found normalized values easier to reason about. That being said, even after normalization it is still not apparent how different metrics contribute to the objective function for a given set of weights.
A small technicality we had to face is that the RL algorithms work by maximizing the reward function, but different metrics require different types of optimization (max for accuracy and min for area and latency). We deal with that by taking negative area and latency as our inputs to the reward function. Whenever we do a weighted sum, we also take care to produce positive values for all the metrics by handling negative values during their normalization.
We explore three different normalization strategies which are described in more detail in “Function-Transformation Methods for multi-objective optimization” by Marlez et al published in Engineering Optimization 37, 6 (2005), 551-570, the disclosure of which is incorporated by reference herein in its entirety. The first is max normalization which is one of the most common methods and normalizes values with respect to their achievable maximum. For negative values, we consider their absolute value and process them analogically. In that case, our normalization function can be formally defined as Equation 7.
Another common normalization method is min-max normalization in which both the minimum and maximum of a metric are considered. This range is then mapped linearly to the [0,1] range. The specific function can be defined as Equation 8
The third normalization method is standard deviation normalization in which values are normalized using their standard deviation. The equation can be defined as Equation 9
By combining the generic weighted sum equation (equation 6) with the chosen normalization function (one of equations 7 to 9, for example equation 8), the MOO problem can be defined as Equation 10.
where ar is area, lat is latency, acc is accuracy), w1, w2, w3 are the set of weights for each of area, latency and accuracy and the optimisation is performed over the search space s·S such that the evaluation model output·(s)=m satisfies given constraints (e.g. latency below a certain value).
If a search point does not meet a specified constraint, a punishment function Rv is used as feedback for the processor to deter it from searching for similar points that fall below our requirements. Since the standard reward function is positive and we want to discourage the processor from selecting invalid points, a simple solution is to make the punishment function negative. We use the same function as the standard reward function R but with two changes: 1) instead of (ar, lat, acc), we take (ar-arth, lat-latth, acc-accth) and 2) we take its opposite to make Rv negative thus informing the processor that this was a bad selection.
Different weights for the MOO problem may also be considered to explore how their selection affects the outcome of the search. For example, the weights may be set to be equal for each metric, e.g. ⅓, or the weights may be set to prioritise one metric, e.g. by setting w1 to 0.5 and w2 and w3 1 to 0.25 to prioritise area when solving the optimization problem. Each weight may be in the range [0,1] with the sum of the weights equal to 1.
There are two approaches for updating the selection of the CNN and FPGA (S410). In a first approach, both sub-search spaces may be considered together so that the algorithm is implemented directly on both spaces. Such an approach may be termed a combined search. This strategy has the ability to update both the CNN and the accelerator in each step, and is therefore able to make faster changes to adapt to the reward function. However, the combined search space (e.g., SNN×SFPGA) is much larger, which may make it more difficult to find the best points (e.g., best selections). Accordingly, each experiment is run for a maximum number of steps, e.g. 10,000 steps and the metrics are evaluated so that the reward function may be calculated.
When running an actual search, it is important to consider invalid and constrained points which can be selected by the processor(s) as well as the appropriate reaction when such points are identified. This behavior does not fit within the standard MOO formulation because MOO does not have the notion of exploration; rather it simply provides means of qualifying multi-dimensional points in a comparable way. However, when running a search, the reward function has additional meaning because it is directly used to guide the processor(s) towards desired outcomes. Therefore, simply ignoring invalid and constrained points can potentially lead to the situations when the processor's feedback is related to only one metric, which can later lead to the processor selecting more points which maximise it without considering the other two. Thus, it is preferred to provide a complementary reward function to use with invalid and constrained points whenever we use weights equal to zero for some of the metrics within the standard reward function. Otherwise, we risk the situation when the processor(s) simply does not consider some of the metrics when learning to navigate the space.
As described above, the method co-designs the FPGA and CNN, for example by use of a combined search. As an alternative to a combined search, the search may have explicitly defined specialized phases during which one part (e.g. the FPGA design) is fixed or frozen so that the search focusses on the other part (e.g. the CNN design) or vice versa.
When running such a search, the number of steps for each CNN phase may be greater than the number of steps for each FPGA phase, e.g. 1000 compared to 200 steps. The two phases are interleaved and repeated multiple times, until we hit the total number of steps (e.g. 10,000 steps). This phased solution is used to find a globally optimal solution. This divide-and-conquer technique considers the two search spaces separately which may make it easier to find better locally-optimal points (per search space). However, mutual impact between the phases is limited, which may make it more difficult to adapt the CNN and accelerator to each other optimally, e.g. to perform a particular task.
More generally, the phased search is slower to converge compared to the combined search. This is highlighted in
As explained above with reference to
All the discovered CNNs must be trained from scratch to perform such a task. Nevertheless, the same search space SCNN which is described above may still be used. Training such as that described in “NAS-Bench-101: Towards Reproducible Neural Architecture Search” by Ying et al published in February 2019 in arXiv e-prints, which is incorporated by reference herein in its entirety. There are 108 epochs of training using standard data augmentation (padding, random crop and flipping), an initial learning rate of 0.1 with cosine decaying and weights decay of 10-4. Training each new CNN takes approximately 1-GPU hour, so to be able to train many models, we parallelize co-design NAS over six machines, each with eight Nvidia-1080 GPUs each allowing 48 models to be trained in parallel.
The co-design search is run with two constraints combined into one. Specifically, latency and area are combined into a metric termed performance per area (perf/area) and this metric is constrained to a threshold value. Accuracy is then maximised under this constraint. The performance per area threshold is gradually increased according to (2, 8, 16, 30, 40) and the search is run for approximately 2300 valid points in total, starting with 300 points at the first threshold value and increasing to 1000 points for the last threshold value. This appeared to make it easier for the processor to learn the structure of high-accuracy CNNs. The combined search strategy described above is used because it is faster to converge on a solution.
The best two points are labelled Cod-1 and Cod-2 respectively. Their performance is shown in the table 2 below:
Cod-1 improves upon ResNet by 1.8% accuracy while simultaneously improving perf/area by 41%. These are considerable gains on both accuracy and efficiency. Cod-2 shows more modest improvements over GoogLeNet but still beats it on both efficiency and accuracy while running 4.2% faster in terms of absolute latency.
indicates data missing or illegible when filed
Cod-1 manages to beat ResNet accuracy but use an important ResNet feature: skip connections and element-wise addition as shown by the rightmost branch of the cell in
It is possible that there are better points than Cod-1 and Cod-2 because the search space has approximately 3.7 billion points int total. Only approximately 1000 points were explored before finding Cod-1 and approximately 2000 points before finding Cod-2. This highlights the speed of convergence at the processor when using the combined search. It is also effective at finding good designs, especially when properly tuned with representative reward functions and search strategies as described above.
The cut-off model 1312 may be dynamic so that the hardware metrics may change as the search progresses to improve the models which are located by the search. For example, if the initial latency threshold is 100 ms but many models have a latency equal to 50 ms, the latency threshold may be updated on the fly (e.g. in real-time) to e.g. 60 ms. In this 30 way, more models will be excluded from the search and the overall searching process will be expedited.
As schematically illustrated, the cut-off model may simultaneously use a plurality of hardware devices, H/W 1, H/W 2, . . . H/W N, to search for models that fit all devices.
The hardware runtime estimator 1430 comprises a statistical model module 1440, a discriminator 1442, a theoretical hardware model module 1444 and a deployment module 1446. The statistical model module 1440 is used to predict (e.g., estimate) the hardware metrics and send these to the discriminator 1442. Initially, the statistical model is based on a theoretical model which is computed in the theoretical hardware model module 1444 to give a baseline prediction which is sent to the statistical model module 1440. The models may suffer from poor prediction quality, particularly the initial models. Accordingly, the discriminator 1442 monitors the confidence of the results from the statistical model.
When the confidence in the estimated hardware metrics is low (e.g. below a confidence threshold), the proposed architecture may be sent to a deployment module 1446 for deployment on the target hardware, e.g. one of hardware devices, H/W 1, H/W 2, . . . H/W N. The latency (or other hardware metric) is measured and this measurement is sent to the statistical model module 1440 to update the statistical model. This measurement is also sent to the discriminator 1442 to update the monitoring process within the discriminator. The actual measurement rather than the estimated value is then sent with the model to the validator 1432. When the confidence in the estimated hardware metrics is good (e.g. above a threshold), the model is sent straight to the validator 1432.
Once the validator 1432 has received the model with its estimated hardware value(s) or measured hardware value(s), the validator 1432 checks if the proposed architecture meets all the hardware metrics. In other words, the validator 1432 may compare the hardware value(s) to the defined thresholds to determine if the hardware constraints are met. If the proposed model does meet the hardware criteria, the model is sent to the evaluation model 1422 for a more detailed evaluation, e.g. to generate a reward function, as described above. Accordingly, it is clear that in this arrangement, the processor 1400 sends all proposed model architectures for the CNN to the hardware runtime estimator 1430. Specifically, as shown in the Figure, the proposed model architectures are sent to the statistical model module 1440 and the discriminator 1442.
The method described in
If there have already been more than N-iterations of the statistical model (“Yes” in S1502), the proposed model is run on actual hardware, e.g. using the deployment module and one of the plurality of hardware modules shown in
Such a method allows scaling and improves run times when compared to a method which always uses actual hardware to determine performance. For example, multiple threads or processes may use the statistical model to search for new CNN models, whilst a single actual hardware device is used to update the statistical model infrequently. The statistical model is likely to be more accurate and up-to-date using the regular measurements. A statistical model only performs as well as the training data from which it was created. As the searches for new CNN models are carried out, they may move into different search spaces including data on which the original model was not trained. Therefore, updating the statistical model with measurements helps to ensure that the statistical model continues to predict representative hardware metrics which in turn are used to guide the search. Any error between the predicted and measured hardware metrics may also be used to tune the number of iterations between implementing the CNN model on the hardware. For example, when the error increases, the number of iterations between polling the hardware may be reduced and vice versa.
As shown in steps S1600 and S1602, the discriminator receives the proposed model, e.g. from the processor, and the predicted hardware metrics, e.g. from the statistical model. These steps are shown in a particular order but it is appreciated that the information may be received simultaneously or in a different order. The discriminator determines whether the predicted hardware metrics may be trusted (step S1604) and in this method, when the discriminator determines that the predicted metrics can be trusted (“Yes” in S1604), there is an optional additional step of the discriminator determining whether the predicted metrics need to be verified (step S1606). The verification decision may be made according to different policies, e.g. after a fixed number of iterations, at random intervals or by assessing outputs of the system. If no verification is required (“No” in S1606), the predicted HW parameters are output (step S1608), e.g. to the validator to determine whether to pass the model to the evaluation model as described above.
When the discriminator determines that the predicted metrics cannot be trusted (“No” in S1604), the proposed model is run on actual hardware to obtain measurements of the hardware metrics (e.g. latency) which are of interest (step S1610). As described above in
In the description above, the terms hardware metrics and hardware parameters may be used interchangeably. It may be difficult to estimate or measure certain metrics, e.g. latency, and thus proxy metrics such as FLOPs and model size may be used as estimates for the desired metrics. The statistical models described above may be trained using hardware measurements which have been previously captured for particular types of CNN. The statistical models may be built using theoretical models which approximate hardware metrics (such as latency) from model properties (such as number of parameters, FLOPs, connectivity between layers, types of operations etc.). The theoretical models may have distinct equations for each layer type (e.g. convolution, maxpool, relu, etc.) with varying accuracy/fidelity for each layer. Theoretical models may be used instead of statistical models.
In the description above, reference has been made to co-designing or designing a CNN and an FPGA processor. However, it will be appreciated that the method is not just applicable to CNNs but is readily extendable to any neural network using the techniques described above. The method is also more broadly applicable to any parametrizable algorithm which is beneficially implemented in hardware, e.g. compression algorithms and cryptographic algorithms. It is will be appreciated that for the method to work, it is necessary to be able to have a well-defined algorithm search space, e.g. the parametrizable algorithm must be definable by virtue of at least one configurable parameter. For example, in the method described above, the search space is defined by the use of the model described in relation to
The processor(s), evaluation model and other modules may include any suitable processing unit capable of accepting data as input, processing the input data in accordance with stored computer-executable instructions, and generating output data. The processor(s), evaluation model and other modules may include any type of suitable processing unit including, but not limited to, a central processing unit, a microprocessor, a Reduced Instruction Set Computer (RISC) microprocessor, a Complex Instruction Set Computer (CISC) microprocessor, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), a System-on-a-Chip (SoC), a digital signal processor (DSP), and so forth. In addition, any of the functionality described as being supported by the processor(s), evaluation model and other modules may be implemented, at least partially, in hardware and/or firmware across any number of devices.
Certain aspects of the disclosure are described above with reference to block and flow diagrams of systems, methods, apparatuses, and/or computer program products according to example embodiments. It will be understood that one or more blocks of the block diagrams and flow diagrams, and combinations of blocks in the block diagrams and the flow diagrams, respectively, may be implemented by execution of computer-executable program instructions. Likewise, some blocks of the block diagrams and flow diagrams may not necessarily need to be performed in the order presented, or may not necessarily need to be performed at all, according to some embodiments. Further, additional components and/or operations beyond those depicted in blocks of the block and/or flow diagrams may be present in certain embodiments.
However, it may be understood that the disclosure is not limited to the various example embodiments described, but also includes various modifications, equivalents, and/or alternatives of the embodiments of the disclosure. In relation to explanation of the drawings, similar drawing reference numerals may be used for similar constituent elements.
In this specification, the expressions “have,” “may have,” “include,” or “may include” or the like represent presence of a corresponding feature (for example: components such as numbers, functions, operations, or parts) and does not exclude the presence of additional feature.
In this document, expressions such as “at least one of A [and/or] B,” or “one or more of A [and/or] B,” include all possible combinations of the listed items. For example, “at least one of A and B,” or “at least one of A or B” includes any of (1) at least one A, (2) at least one B, or (3) at least one A and at least one B.
As used herein, the terms “first,” “second,” or the like may denote various components, regardless of order and/or importance, and may be used to distinguish one component from another, and does not limit the components.
If it is described that a certain element (e.g., first element) is “operatively or communicatively coupled with/to” or is “connected to” another element (e.g., second element), it should be understood that the certain element may be connected to the other element directly or through still another element (e.g., third element). On the other hand, if it is described that a certain element (e.g., first element) is “directly coupled to” or “directly connected to” another element (e.g., second element), it may be understood that there is no element (e.g., third element) between the certain element and the another element.
Also, the expression “configured to” used in the disclosure may be interchangeably used with other expressions such as “suitable for,” “having the capacity to,” “designed to,” “adapted to,” “made to,” and “capable of,” depending on cases. Meanwhile, the term “configured to” does not necessarily refer to a device being “specifically designed to” in terms of hardware. Instead, under some circumstances, the expression “a device configured to” may refer to the device being “capable of” performing an operation together with another device or component. For example, the phrase “a processor configured to perform A, B, and C” may refer, for example, to a dedicated processor (e.g., an embedded processor) for performing the corresponding operations, or a generic-purpose processor (e.g., a central processing unit (CPU) or an application processor) that can perform the corresponding operations by executing one or more software programs stored in a memory device.
In this disclosure, the term user may refer to a person who uses an electronic apparatus or an apparatus (example: artificial intelligence electronic apparatus) that uses an electronic apparatus.
Meanwhile, various embodiments of the disclosure may be implemented in software, including instructions stored on machine-readable storage media readable by a machine (e.g., a computer). An apparatus may call instructions from the storage medium, and execute the called instruction, including an electronic device (for example, electronic device 100) according to the disclosed embodiments. When the instructions are executed by a processor, the processor may perform a function corresponding to the instructions directly or using other components under the control of the processor. The instructions may include a code generated by a compiler or a code executable by an interpreter. A machine-readable storage medium may be provided in the form of a non-transitory storage medium. Herein, the “non-transitory” storage medium may not include a signal but is tangible, and does not distinguish the case in which a data is semi-permanently stored in a storage medium from the case in which a data is temporarily stored in a storage medium. For example, “non-transitory storage medium” may include a buffer in which data is temporarily stored.
According to an embodiment, the method according to the above-described embodiments may be included in a computer program product. The computer program product may be traded as a product between a seller and a consumer. The computer program product may be distributed online in the form of machine-readable storage media (e.g., compact disc read only memory (CD-ROM)) or through an application store (e.g., Play Store) or distributed online directly. In the case of online distribution, at least a portion of the computer program product may be at least temporarily stored or temporarily generated in a server of the manufacturer, a server of the application store, or a machine-readable storage medium such as memory of a relay server.
According to various embodiments, the respective elements (e.g., module or program) of the elements mentioned above may include a single entity or a plurality of entities. According to the embodiments, at least one element or operation from among the corresponding elements mentioned above may be omitted, or at least one other element or operation may be added. Alternatively or additionally, a plurality of components (e.g., module or program) may be combined to form a single entity. In this case, the integrated entity may perform functions of at least one function of an element of each of the plurality of elements in the same manner as or in a similar manner to that performed by the corresponding element from among the plurality of elements before integration. The module, a program module, or operations executed by other elements according to variety of embodiments may be executed consecutively, in parallel, repeatedly, or heuristically, or at least some operations may be executed according to a different order, may be omitted, or the other operation may be added thereto.
While the disclosure has been illustrated and described with reference to various example embodiments thereof, it will be understood that the various example embodiments are intended to be illustrative, not limiting. It will be further understood by one of ordinary skill in the art that various changes in form and detail may be made without departing from the true spirit and full scope of the disclosure, including the appended claims and equivalents thereof.
Number | Date | Country | Kind |
---|---|---|---|
1913353.7 | Sep 2019 | GB | national |
10-2020-0034093 | Mar 2020 | KR | national |