Streamline processing graph to enhance performance of neural network execution on hardware accelerator
By streamlining the processing graph of DNNs through merging activation functions in hardware accelerators, the framework addresses inefficiencies in DNN computation, enhancing performance and accuracy.
Patent Information
- Application Number
- PCT/CN2024/121525
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-24
- Filing Date
- 2024-09-26
- Publication Date
- 2026-01-02
AI Technical Summary
Deep neural networks (DNNs) face significant computation costs due to high computing demands and inefficient data processing in neural network hardware accelerators, particularly in handling activation functions, leading to high latency and overhead in memory accesses.
A framework is introduced to streamline the processing graph of DNNs by identifying and merging contiguous or branch nodes in the neural network model definition, using a software programmable look-up table to approximate composite functions, reducing overhead and improving parallel processing efficiency.
This approach achieves performance improvements of up to 47% and accuracy improvements of up to 3X by merging activation functions, optimizing resource utilization and reducing latency in DNN hardware accelerators.
Smart Images

Figure CN2024121525_02012026_PF_FP_ABST
Abstract
Description
STREAMLINE PROCESSING GRAPH TO ENHANCE PERFORMANCE OF NEURAL NETWORK EXECUTION ON HARDWARE ACCELERATOR
[0001] Cross-reference to Related Applications
[0002] This application claims benefit of priority of International Patent Application Serial No. PCT / CN2024 / 100864, filed June 24, 2024, and entitled “ACTIVATION FUNCTION-BASED PREPROCESSOR FOR COMPILER, ” the disclosure of which is considered part of (and is incorporated by reference herein) the disclosure of the present application.Background
[0003] Deep neural networks (DNNs) are used extensively for a variety of artificial intelligence applications ranging from computer vision to speech recognition and natural language processing due to their ability to achieve high accuracy. However, the high accuracy comes at the expense of significant computation cost. DNNs have extremely high computing demands as there can be a large number of operations as well as a large amount of data to read and write.Brief Description of the Drawings
[0004] Embodiments will be readily understood by the following detailed description in conjunction with the accompanying drawings. To facilitate this description, like reference numerals designate like structural elements. Embodiments are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings.
[0005] FIGS. 1A-B illustrate serial activation functions in neural network model definitions, according to some embodiments of the disclosure.
[0006] FIG. 2 illustrates activation functions in respective parallel paths following a node, according to some embodiments of the disclosure.
[0007] FIG. 3 illustrates a DNN system, according to some embodiments of the disclosure.
[0008] FIG. 4 illustrates a DNN module, according to some embodiments of the disclosure.
[0009] FIG. 5 illustrates a processing engine, according to some embodiments of the disclosure.
[0010] FIG. 6 illustrates a post-processing engine, according to some embodiments of the disclosure.
[0011] FIG. 7 illustrates a compiler, according to some embodiments of the disclosure.
[0012] FIG. 8 illustrates a sigmoid function and a composite function combining a sigmoid function and a square root function, according to some embodiments of the disclosure.
[0013] FIG. 9 is a flowchart showing a method for merging serial activation functions, according to some embodiments of the disclosure.
[0014] FIG. 10 is a flowchart showing a method for merging parallel activation functions, according to some embodiments of the disclosure.
[0015] FIG. 11 is a block diagram of an exemplary computing device, according to some embodiments of the disclosure.Detailed Description
[0016] Overview
[0017] DNNs are used in a variety of applications in the domains such as computer vision, speech recognition, image generation, video generation, etc. DNNs can achieve high accuracy, and in some cases, perform at superhuman-level accuracy. DNNs have interconnected neurons (or operations) that process data, and the layered structure of neural networks enable complex machine learning tasks to be performed. Neural network hardware accelerators with specialized circuitry can perform the operations in an efficient manner.
[0018] In some neural network hardware accelerators, multiple data processing units (DPUs) can be provided in the neural network hardware accelerator to enable fast, specialized, and parallel data processing. In a DPU, a data processing pipeline may be implemented to include a processing engine and a post-processing engine (PPE) . The processing engine may be tasked to perform neural network operations such as matrix multiplications and convolutions, while the PPE following the processing engine may be tasked to apply operations such as scaling, adding a bias, and applying an activation function. A data processing workload can be scheduled and initiated onto the DPU to be executed by the data processing pipeline.
[0019] Activation functions are a common part of the DNN, and activation functions decide whether a neuron should or should not be activated by computing the weighted sum activations and adding bias. The main purpose of activation functions is to introduce non-linearity to the output of neurons. A neural network hardware accelerator that implements a DNN preferably includes an efficient implementation of the activation functions of the DNN. In some cases, a vector processing engine may be included in the PPE. An exemplary vector processing engine may include a (very long) instruction word processor that can perform multiple 512-bit vector operations in parallel with multiple load / store, scalar floating-point, integer and control-flow operations in a single clock cycle. The vector processing engine can require specialized kernel implementation to execute an activation function, so alternative hardware implementations to carry out an activation function in the PPE have been contemplated. Considering the complexity of some of the non-linear activation functions used in latest DNNs, hardware implementation may involve approximation within certain level of accuracy. Some neural network hardware accelerators have a software programmable look up table in the PPE of a DPU that can be used to efficiently apply an approximation of an activation function to a tensor. The look up table can be loaded with suitable look up table values. The look up table offers a flexible and programmable solution for implementing an activation function in the pipeline within the DPU.
[0020] There is an opportunity to introduce a framework that can add additional flexibility and efficiency on top of the look up table in the PPE. In particular, the look up table can be utilized in innovative ways to streamline the processing graph of the neural network. DNN model definitions can specify interconnected nodes (or operations) or layers of nodes that process information. A compiler for a neural network hardware accelerator can generate a processing graph based on the DNN model definition. The neural network hardware accelerator may process data node by node, or perform operation by operation, according to the processing graph. To improve performance of the neural network hardware accelerator, it is possible to apply a criterion and a process of pre-processing a neural network model definition (or the processing graph) to identify nodes or operations that could be merged. Specifically, the pre-processing process may identify activation functions that could be merged. Applying a criterion and pre-processing neural network model definitions to identify nodes (e.g., activation functions) that could be merged can achieve performance boost and accuracy improvement. Merging operations can streamline the processing graph of the neural network and obtain a streamlined processing graph. Utilizing a streamlined processing graph can lead to more efficient scheduling and execution of workloads by the DPUs of a neural network hardware accelerator. The streamlined processing graph can achieve one or more technical benefits, e.g., reduce latency or number of cycles, reduce overhead, reduce switching, increase accuracy, and increase opportunities for parallel processing in a neural network hardware accelerator. In some experiments, performance boost and accuracy improvement can be achieved, specifically in computing the activation functions. The pre-processing can achieve around 47%performance improvement at layer level for some neural networks. Up to 3X improvement can be achieved in some cases by merging certain nodes of those neural networks.
[0021] Besides streamlining the processing graph, the merged activation functions can be implemented in the software programmable look up table effectively in the PPE of a DPU. In some embodiments, the software programmable look up table can be used to store parameters that can be used to approximate a composite function that combines two or more activation functions. In some embodiments, the software programmable look up table can be used to store two or more sets of parameters that can be used to approximate different two or more activation functions. In some embodiments, the software programmable look up table can be used to store parameters that can be used to approximate a composite function and one or more sets of parameters that can be used to approximate one or more activation functions. In some embodiments, the software programmable look up table may include one or more sub-look up tables to store the one or more sets of parameters that can be used to approximate the one or more activation functions.
[0022] A composite function is a function that combines two or more functions, where the output of one function becomes the input of a further function. Consider two functions, f (x) and g (x) . The composite function of the two functions is denoted by (x) or g composed with f or g of f of x. To evaluate (x) , function f is applied to the input x, then function g is applied to the result of applying function f to the input x, (x) = g (f (x) ) . Starting with an input x, x is fed into function f, producing an output f (x) . This output f (x) becomes the input for function g. Function g processes f (x) , producing the final output g (f (x) ) . For example, if f (x) = x + 1 and g (x) = x2, then: (x) = g (f (x) ) = g (x + 1) = (x + 1) 2. This process of combining functions can be extended to more than two functions, creating longer chains of composite functions.
[0023] According to one aspect, the neural network model definition is pre-processed to identify contiguous nodes, such as two or more sequential or serial activation functions in neural network model definition, that could be implemented as a composite function. The contiguous nodes, e.g., the serial activation functions, can be merged into a composite function. Performance gains can be achieved by loading look up table values that can approximate a composite function onto the programmable look up table of a PPE. For example, the composite function implemented onto the programmable look up table of a PPE of a DPU in a neural network hardware accelerator can achieve network level performance improvement. In some experiments, performance improvement of 47%compared to implementing the nodes without the pre-processing solution can be achieved. In some scenarios, accuracy improvement can be achieved when the programmable look up table is used to approximate a composite function as opposed to approximating the individual activation functions in separate programmable look up tables. In one example, a sigmoid function and a square root function could be combined into a composite function and approximated using the programmable look up table. The composite function could be implemented with a unit of least precision (ULP) of 1, and up to 3X improvement of accuracy could be achieved when merging the sigmoid function and the square root function into a composite function. The pre-processing process may identify a number of contiguous nodes as candidates for merging to achieve a certain expected amount of performance gain. The pre-processing process may identify certain types of contiguous nodes as candidates for merging to achieve a certain expected amount of accuracy improvement. When merging some types of contiguous nodes, there is a performance-to-accuracy trade-off. If the accuracy degradation due to merging of the particular type of contiguous nodes is more than the desired or tolerated amount, the performance gains of merging the contiguous nodes could be given up for the additional accuracy of implementing the contiguous nodes separately.
[0024] According to one aspect, the neural network model definition is pre-processed to identify a branching or splitting location in the neural network model that split the data into two or more parallel paths, where the data is forwarded or copied to the two or more parallel paths for further processing. The parallel paths following the location may have respective branch nodes, e.g., parallel activation functions in respective parallel paths, to process the data from the location. The branch nodes, e.g., respective activation functions in the parallel paths can be merged. These merged branch nodes could be approximated within the (same) programmable look up table, or a group of programmable look up tables in the PPE of a DPU, to implement a multi-function operation. Performance gains can be achieved by loading look up table values that can approximate an activation function and further look up table values that can approximate a further activation function onto the (same) programmable look up table of a PPE, or respective programmable look up tables in a group of look up tables of the PPE. In some cases, a look up table has multiple (sub-) look up tables, or a group of look up tables. For example, branch nodes, such as activation functions in the parallel paths, identified using the pre-processing process and implemented onto the (same) programmable look up table of a PPE of a DPU in a neural network hardware accelerator can achieve network level performance improvement. In some experiments, performance improvement of 36%can be achieved when the activation functions in the parallel paths are merged and the programmable look up table is used to approximate the activation functions as opposed to approximating the individual activation functions in separate programmable look up tables of separate PPEs. The pre-processing process may identify a number of branch nodes, e.g., parallel activation functions, as candidates for merging to achieve a certain expected amount of performance gain. The size of the programmable look up table or a group of programmable look up tables in the PPE, e.g., the number of look up table values the look up table can store, is limited. Therefore, there is an accuracy-to-area trade-off when identifying and merging branch nodes. Merging branch nodes onto the (same) programmable look up table or group of programmable look up tables can mean that fewer look up table values can be used to approximate an activation function, which can impact accuracy of the approximation. The pre-processing process may identify certain types of branch nodes as candidates for merging to meet a maximum amount of tolerated accuracy loss. The branch nodes identified using the pre-processing process can trade-off accuracy to meet area requirements. For the cases where the programmable look up table values for two or more activation functions may fit within hardware area budget (e.g., the size of the programmable look up table or group of programmable look up tables of a PPE) , there is no penalty on accuracy. However, when the programmable look up table values for two or more activation functions do not fit with the hardware area budget, accuracy could be traded-off for performance gain. In addition, there is a performance-to-accuracy trade-off. If the accuracy degradation due to merging of branch nodes into the same programmable look up table is more than the desired or tolerated amount, the performance gains of implementing merging the branch nodes could be given up for the additional accuracy of implementing the branch nodes separately.
[0025] Candidate nodes for merging
[0026] In some implementations, a DPU’s data processing pipeline can execute a data processing workload involving a compute operation followed by a post-processing operation such as applying an activation function. To initiate the DPU’s data processing pipeline, a configuration descriptor having configuration information for the processing engine to perform the compute operation and configuration information for the PPE to apply the activation function can be loaded onto the DPU. To execute the data processing workload, the data processing pipeline of the DPU can cause input data of the data processing workload to be passed to the processing engine, and the processing engine can generate output data by performing the specified compute operation. The output data generated by the processing engine is then passed to the PPE (the next operation in the data processing pipeline) , and the PPE can generate output data by applying the specified activation function. The output data generated by the PPE is passed onwards as the output data of the data processing workload. The data processing pipeline of a DPU that can execute data processing workloads is described further in FIGS. 4 and 5-6.
[0027] DPUs of a neural network hardware accelerator have highly specialized hardware that can execute data processing workloads for a neural network very efficiently. Also, DPUs can execute data processing workloads in parallel to achieve high throughput processing. However, the architecture of the DPU and the way data processing workloads are scheduled and initiated onto the DPUs based on a processing graph of a neural network have some limitations or opportunities for optimization and improvement.
[0028] If a neural network model definition specifies a compute operation followed by an activation function, followed by a further activation function, a compiler may schedule and initiate two sequential data processing workloads to be executed by the DPU, where one of the data processing workloads would cause the DPU to execute the compute operation and the following activation function, and the other one of the data processing workloads would cause the DPU to perform an identity / pass-through operation (as the compute operation) and the following further activation function. Scheduling and initiating two sequential data processing workloads can have high overhead in memory accesses to load different configuration descriptors and in switching between operations for the two data processing workloads. Performing the two data processing workloads serially can have high latency. This issue may be worse if there are more further activation function (s) that follow.
[0029] In a comprehensive review of 2500 neural network models, 141 neural network models were identified to have sequential node patterns, such as contiguous activation functions. The sequential node patterns signify common modeling practices, and potential areas for optimization. The review revealed a variety of sequential operations, with a notable sequential node pattern being the "Clamp+Exp" (e.g., a clamping function followed by an exponential function) sequence, occurring in 412 models. FIG. 1A illustrates serial activation functions in a neural network model definition, according to some embodiments of the disclosure. In FIG. 1A, a subset of nodes / operations in a neural network model definition is depicted. Compute operation 102 may be followed by an activation function, e.g., clamp 104, that applies a clamping function to the output of compute operation 102. Clamp 104 may be followed by a further activation function, e.g., exp 106, that applies an exponential function to the output of clamp 104. This pattern suggests a prevalent use of normalization or pre-processing steps followed by exponential activation functions. Other significant sequences include "Sigmoid+Power" (e.g., a sigmoid function followed by a power function) indicating specific computational patterns that might serve distinct purposes in model architecture. FIG. 1B illustrates serial activation functions in a neural network model definition, according to some embodiments of the disclosure. In FIG. 1B, a subset of nodes / operations in a neural network model definition is depicted. Compute operation 102 may be followed by an activation function, e.g., sigmoid 112, that applies a sigmoid function to the output of compute operation 102. Sigmoid 112 may be followed by a further activation function, e.g., power / sqrt 110, that applies a power function or a square root function (equivalent to a power of 0.5) to the output of sigmoid 112.
[0030] To address this inefficiency, two or more contiguous, sequential, or serial activation functions can be identified as candidates to be merged. When the two or more serial activation functions are merged, a streamlined processing graph for the neural network may specify a compute operation followed by a composite function that combines the merged serial activation functions. A compiler may schedule and initiate a single data processing workload to be executed by the DPU, where the data processing workload would cause the DPU to execute the compute operation and the composite function. Overhead is reduced since only one configuration descriptor is used to initiate the DPU. Latency is reduced since only one data processing workload is executed.
[0031] If neural network model definition specifies a compute operation followed by multiple parallel paths to perform respective activation functions, a processing graph may include multiple parallel paths, where each parallel path includes the compute operation followed by a respective activation function. A compiler may schedule and initiate multiple data processing workloads to be executed by multiple DPUs in parallel, where each data processing workload may perform a compute operation and a respective activation function for a respective parallel path. In practice, the data processing workloads may not always get executed in parallel to achieve high throughput (e.g., there may not be sufficient free DPUs to execute all the data processing workloads in parallel, cost of memory accesses to distribute data across multiple DPUs may be too high, etc. ) . Executing some of the data processing workloads serially can lead to high overhead in memory accesses to load different configuration descriptors and switching between operations for the two data processing workloads.
[0032] Branch nodes can be less common compared to sequential nodes in neural network model definitions. Branch nodes are indicative of architectures that may involve parallel processing, conditional computations, or feature complex connections such as skip connections or residual blocks. For example, sigmoid and hyperbolic tangent (tanh) functions are indicative of neural network architectures that have parallel processing paths or complex transformations involving both functions. FIG. 2 illustrates activation functions in respective parallel paths following a node, according to some embodiments of the disclosure. In FIG. 2, a subset of nodes / operations in a neural network model definition is depicted. Compute operation 102 may be split or branched to have parallel paths that follow compute operation 102. An activation function, e.g., tanh 204 which applies a hyperbolic tangent function to the output of compute operation 102, may be part of a parallel path that followed compute operation 102. A further activation function, e.g., sigmoid 212 which applies a sigmoid function to the output of compute operation 102, may be part of a further parallel path that followed compute operation 102. There may be one or more additional parallel paths with one or more respective activation functions processing the output of compute operation 102. These types of branch nodes, such as sigmoid and tanh functions illustrated as sigmoid 212 and tanh 204 can be found in the models that incorporate attention mechanisms, such as the transformer architecture, may use sigmoid and tanh functions in parallel to compute different components of the attention scores or to process the query, key, and value vectors differently.
[0033] To address this inefficiency, two or more branch nodes, e.g., different activation functions in parallel paths can be identified as candidates to be merged. When the two or more branch nodes or parallel activation functions are merged, the streamlined processing graph may specify parallel paths, where each parallel path may include a compute operation followed by a multi-function operation able to perform the different parallel activation functions. A compiler may schedule and initiate multiple data processing workloads to be executed by one or more DPUs, where each data processing workload would cause a DPU to execute the compute operation and a selected one of the activation functions in the multi-function operation. Suppose a DPU is scheduled to execute two data processing workloads, one after another, only a portion of the configuration descriptor corresponding to the selection of the activation function in the multi-function operation has to be loaded onto the DPU when switching from the first data processing workload to the second, following data processing workload. Therefore, overhead is reduced since at least a portion of the configuration descriptor corresponding to the multi-function operation is reused (not loaded again) to initiate the DPU to execute the next data processing workload, regardless of which activation function is selected to be applied for the next data processing workload. As a result, fewer memory accesses and less significant switching are needed to execute the data processing workloads on a DPU in some cases. In some scenarios, having multiple parallel DPUs loaded with the portion of the configuration descriptor corresponding to the multi-function operation may make it easier to schedule the data processing workloads to be executed in parallel or serially since the switching overhead is significantly reduced.
[0034] The overall processing graph can become more streamlined as a result merging serial activation functions and merging activation functions in parallel paths. Fusing or merging operations can potentially increase the efficiency of the DPU, as the DPU can execute complex operations in a single step. Streamlining the processing graph could lead to faster processing times for data processing workloads. By identifying and combining contiguous operations into a composite function and / or identifying and combining parallel operations into a multi-function operation, the pre-processing process in the compiler can optimize the utilization of DPU resources, ensuring that the hardware is used more effectively to execute the neural network model.
[0035] Implementing DNNs on processors or neural network hardware accelerators
[0036] The significant improvements in DNN model size and accuracy coupled with the rapid increase in computing power of execution platforms have led to the adoption of DNN applications even within resource constrained mobile and edge devices that have limited power availability. DNN models may be executed, e.g., for training or inference, by DNN accelerators, or referred to herein as neural network hardware accelerators. A DNN accelerator may be or include one or more data processing units, or DPUs. A DPU may also be referred to as a compute block or compute tile. A DPU has highly specialized hardware circuitry to perform neural network operations. A DPU may include one or more processing engines that can carry out neural network operations or compute operations. A processing engine may include one or more processing cells to perform arithmetic operations associated with neural network operations, such as multiplication and multiplication and accumulate. A DPU may include one or more PPEs that can carry out neural network operations such as scaling, adding a bias, and applying an activation function.
[0037] FIG. 3 illustrates DNN system 300, according to some embodiments of the disclosure. The whole DNN system 300 or a part of DNN system 300 may be implemented in one or more computing devices, such as the computing device 1100 in FIG. 11. DNN system 300 can generate and execute DNNs, such as transformer-based neural networks, convolutional neural networks, and so on. As shown in FIG. 3, DNN system 300 includes DNN module 301 and DNN accelerator 302. In other embodiments, alternative configurations, different or additional components may be included in DNN system 300. For instance, DNN system 300 may include multiple DNN modules or multiple DNN accelerators. Further, functionality attributed to a component of the DNN system 300 may be accomplished by a different component included in the DNN system 300 or a different system. In some embodiments, DNN module 301 and DNN accelerator 302 may include or be implemented by different types of processing units. In an example, the DNN module 301 may be implemented by one or more central processing units (CPUs) . The DNN accelerator 302 may also be referred to as a neural network hardware accelerator, a neural processing unit, artificial intelligence (AI) accelerator, or AI processor. The DNN module 301 and DNN accelerator 302 may be implemented in the same chip or as separate chips.
[0038] DNN module 301 facilitates generation and deployment of DNNs. In some embodiments, the DNN module 301 may generate and train DNNs. For instance, the DNN module 301 can define the layered architecture of a DNN. The DNN module 301 can also determine the internal parameters of the DNN through a DNN training process. The DNN module 301 may also determine one or more hyperparameters that define how the DNN is trained. An example hyperparameter is a sparsity ratio that defines the sparsity level of one or more deep learning tensors for the DNN.
[0039] DNN module 301 may compress DNNs, e.g., during or after training. In some embodiments, DNN module 301 may prune weights in one or more layers of a DNN by changing nonzero valued weight to zeros. DNN module 301 may prune weights based on a target weight sparsity ratio. A weight sparsity ratio may be the ratio of the number of zero-valued weights to the total number of weights. In an example where the DNN module 301 prunes weight during DNN training, the DNN module 301 may prune weight of a layer to achieve a target sparsity ratio after one or more epochs. DNN module 301 may prevent the pruned weights from changing values during the rest of the training process. Alternatively, DNN module 301 may allow the pruned weights to change values so that a pruned, zero-valued weight may have a nonzero value after further training. DNN module 301 may prune weights of the layer again after one or more additional epochs.
[0040] DNN module 301 may deploy trained, compressed, or validated DNNs for use in deep learning applications. In some embodiments, DNN module 301 may distribute trained, compressed, or validated DNNs to devices or systems which may use the DNNs to perform tasks (e.g., image classification, motion planning, etc. ) for which the DNNs were trained. In other embodiments, DNN module 301 may facilitate deployment of the DNNs using the DNN accelerator 302. For instance, DNN module 301 may receive data from a device or system coupled with DNN system 300 and input the received data (or data generated by DNN module 301, e.g., based on the received data) into a DNN. DNN module 301 may compile instructions executable by DNN accelerator 302 to perform operations of a DNN in accordance with a model definition of the DNN. DNN module 301 may generate instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) that control the operation of the DNN accelerator 302 during the DNN execution. The instructions may correspond to one or more data processing workloads sent from DNN module 301 to DNN accelerator 302, where the one or more data processing workloads are to be executed by DNN accelerator 302. DNN module 301 may receive an output of the DNN from the DNN accelerator 302. DNN module 301 may transmit the output of the DNN (or a result of processing the output of the DNN by DNN module 301) to the device or system. In some embodiments, DNN module 301 may control execution processes of trained, compressed, or validated DNNs. DNN module 301 may function as a compiler for DNNs executed by DNN accelerator 302. DNN module 301 may perform compilation of DNNs and generate configuration descriptors and / or low-level machine instructions, based on which the DNNs may be executed. Certain aspects of the DNN module 301 are described and illustrated in FIGS. 4 and 7.
[0041] DNN accelerator 302 executes DNNs provided by DNN module 301. For instance, DNN accelerator 302 can execute a DNN by running deep learning operations in the DNN. The process of carrying out a deep learning operation is also referred to as a process of executing the deep learning operation or a process of performing the deep learning operation. The execution of the DNN may be for training the DNN or for using the DNN to perform AI and / or inference tasks.
[0042] As shown in FIG. 3, DNN accelerator 302 includes memory 310, direct memory access (DMA) engine 320, and data processing units 330 (individually referred to as “data processing unit 330” ) . In other embodiments, alternative configurations, different or additional components may be included in DNN accelerator 302. For example, DNN accelerator 302 may include more than one memory 310 or DMA engine 320. As another example, DNN accelerator 302 may include a single data processing unit 330. Further, functionality attributed to a component of DNN accelerator 302 may be accomplished by a different component included in DNN accelerator 302 or by a different system. A component of DNN accelerator 302 may be implemented in hardware, software, firmware, or some combination thereof.
[0043] Memory 310 stores data associated with deep learning operations performed by DNN accelerator 302. In some embodiments, memory 310 may store data to be used by the data processing units 330 for DNN execution. memory 310 may store weights, such as weights of convolutional layers, which are determined by training DNNs. The memory 310 may further store inputs to DNN layers and / or outputs of DNN layers, such as data generated by the data processing units 330 from performing deep learning operations in DNNs.
[0044] Example deep learning operations include convolutions (also referred to as “convolutional operations” ) , layer normalization operations, SoftMax operations, matrix multiplication operations, pooling operations, elementwise operations, activation functions, other types of deep learning operations, or some combination thereof.
[0045] Memory 310 may store instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) executable by DNN accelerator 302, such as instructions executable by data processing unit 330. Memory 310 may be a main memory of DNN accelerator 302. In some embodiments, memory 310 includes one or more dynamic random-access memories (DRAMs) .
[0046] DMA engine 320 facilitates data transfer between memory 310 and local memories 340 of the data processing units 330. For example, DMA engine 320 can read data from memory 310 and write data into local memory 340 of data processing unit 330. As another example, DMA engine 320 can read data from local memory 340 of data processing unit 330 and write data into memory 310. DMA engine 320 provides a DMA feature that allows data processing unit 330 to initiate data transfer between memory 310 and local memories 340 of the data processing units 330 and to perform other operations while the data transfer is being conducted. In some embodiments, DMA engine 320 may read tensors from memory 310, modify the tensors in a way that is optimized for data processing unit 330 before it writes the tensors into local memories 340 of data processing units 330.
[0047] Data processing units 330 perform deep learning operations in DNNs. For instance, data processing unit 330 may execute a DNN layer by running one or more deep learning operations in the DNN layer. Data processing unit 330 may execute a layer, or a portion of a layer, at a time. In some embodiments, the operations of the DNN layers may be run by multiple data processing units 330 in parallel. For instance, multiple data processing units 330 may each perform a data processing workload, or a portion of a data processing workload workload for a deep learning operation. Data may be shared between data processing units 330. Data processing unit 330 may also be referred to as a compute block, or a compute tile.
[0048] Data processing units 330 may be capable of running various types of deep learning operations, such as convolution, layer normalization, SoftMax operation, pooling, elementwise operation, linear operation, non-linear operation, and so on. Deep learning operations performed by the data processing units 330 include tensor operations, i.e., operations whose inputs are tensors or operations whose outputs are tensors. In an example, data processing unit 330 receives an input tensor and one or more convolutional kernels and performs a convolution with the input tensor and convolutional kernels. The result of the convolution may be an output tensor, which can be further computed, e.g., by data processing unit 330 or another data processing unit 330.
[0049] In the embodiments of FIG. 3, each data processing unit 330 includes local memory 340, load module 360, processing engine 370, post-processing engine 380, and output module 390. Data processing unit 330 may include a data processing pipeline that includes load module 360, processing engine 370, post-processing engine 380, and output module 390 (the arrows depict the flow of data in the data processing pipeline) . Some or all the components of the data processing unit 330 can be implemented on the same chip. In other embodiments, alternative configurations, different or additional components may be included in the data processing unit 330. Further, functionality attributed to a component of data processing unit 330 may be accomplished by a different component included in the data processing unit 330, a different data processing unit 330, another component of the DNN accelerator 302, or a different system. A component of the data processing unit 330 may be implemented in hardware, software, firmware, or some combination thereof.
[0050] Local memory 340 is local to the corresponding data processing unit 330. In the embodiments of FIG. 3, local memory 340 is inside the data processing unit 330. In other embodiments, local memory 340 may be outside the data processing unit 330. Data in local memory 340 may be transferred to or from memory 310, e.g., through DMA engine 320. In some embodiments, data in local memory 340 may be transferred to or from local memory 340 of another data processing unit 330. Local memory 340 may store data received, used, or generated by load module 360, processing engine 370, post-processing engine 380, or output module 390. Examples of the data may include input activations, weights, output activations, low-level machine instructions, configuration descriptors, and so on.
[0051] In some embodiments, local memory 340 may store tensors to be processed by the processing engine 370 or the post-processing engine 380. The tensors may be input tensors of deep learning operations. Local memory 340 may also store tensors generated by processing engine 370 or post-processing engine 380. The tensors may be output tensors of deep learning operations. The layout of data points of a tensor in local memory 340 may depend on the format in which the tensor is stored. In some embodiments, local memory 340 may store tensors in various formats, including Z-major format, X-major format, and Y-major format. For a tensor with Z-major format, the local memory 340 may store data points having the same (x, y) coordinate contiguously. For instance, the data points having the same (x, y) coordinate may be stored at a sequence of memory addresses the local memory 340. For a tensor with the ZXY format or ZYX format, local memory 340 may store data points having the same (x, y) coordinate contiguously. For instance, the data points having the same (x, y) coordinate may be stored at a sequence of memory addresses in local memory 340. For a tensor with X-major format, local memory 340 may store data points having the same (y, z) coordinate contiguously. For a tensor with Y-major format, local memory 340 may store data points having the same (x, z) coordinate contiguously.
[0052] In some embodiments, local memory 340 may store dense tensors (e.g., dense activation tensors, dense weight tensors, etc. ) , sparse tensors (e.g., sparse activation tensors, sparse weight tensors, etc. ) , and so on. A dense tensor may be a tensor from which zero-valued elements (if any) are not removed. A dense tensor may be converted to a sparse tensor by removing one or more zero-valued elements in the dense tensor. A sparse tensor may also be referred to as a compressed tensor or packed tensor. The process of converting a dense tensor to a sparse tensor may be referred to as sparsity encoding. Sparsity encoding may also generate a sparsity tensor. Each element in the sparsity tensor may correspond to a different element in the dense tensor and indicate whether the element in the dense tensor is zero or not. The sparsity tensor may indicate positions of elements of the sparse tensor in the dense tensor. The sparsity tensor may include a sparsity bitmap, each element of which is a bit. A sparse tensor may be converted to a dense tensor through a densifying process, in which one or more zeros may be added to the sparse tensor based on the sparsity tensor.
[0053] In some embodiments, local memory 340 includes one or more static random-access memories (SRAMs) . Local memory 340 may be byte-addressable, and each memory address identifies a single byte (eight bits) of storage. In some embodiments, local memory 340 may include memory banks. The number of data banks in the local memory 340 may be 16, 64, 128, 356, 512, 1024, 2048, or other numbers. A memory bank may include a plurality of storage units. In an example, a data bank may include 8, 16, 64, or a different number of storage units. A memory bank or a storage unit in a memory bank may have a memory address. In an example, a storage unit may store a single byte, and data larger than a single byte may be stored in storage units with consecutive memory addresses, i.e., adjacent storage units. For instance, a storage unit can store an integer number in the INT8 format, versus two storage units may be needed to store a number in the FP16 or BF16 format, which has 16 bits. In some embodiments, 16 bits can be transferred from local memory 340 in a single read cycle. In other embodiments, 16 bits can be transferred from local memory 340 in multiple read cycles, such as two cycles.
[0054] Load module 360 loads data from local memory 340 to the processing engine 370 or to post-processing engine 380. Load module 360 may read tensors from the local memory 340. The tensors may include sparse activation tensors, sparse weight tensors, activation sparsity tensors, weight sparsity tensors, and so on. In some embodiments, load module 360 may load data based on a sparsity mode. Load module 360 may select different data to transmit to the processing engine 370 in different sparsity modes.
[0055] Load module 360 loads instructions, e.g., configuration descriptors and / or low-level machine instructions, from local memory 340 to the processing engine 370. The instructions may be used to configure or control processing cells of processing engine 370 to perform one or more deep neural network operations.
[0056] Processing engine 370 performs neural network operations of DNNs. An exemplary processing engine 370 is described and illustrated in FIG. 5.
[0057] Post-processing engine 380 processes outputs of processing engine 370. The post-processing engine 380 may include one or more post-processing elements. In some embodiments, the post-processing elements in the post-processing engine 380 may be arranged in an arrangement (e.g., in an array arrangement) that has rows and columns. In some embodiments, post-processing engine 380 computes activation functions. Post-processing engine 380 may receive outputs of processing engine 370 as inputs to the activation functions. In addition or alternative to activation functions, post-processing engine 380 may perform other types of post-processing on outputs of processing engine 370. For instance, post-processing engine 380 may apply a bias on an output of processing engine 370. For instance, post-processing engine 380 may perform scaling on an output of processing engine 370. In some embodiments, post-processing engine 380 may be bypassed for certain neural network operations. In some embodiments, post-processing engine 380 may include a vector processing engine 372. Vector processing engine 372 may include a very long instruction word processor able to perform multiple 512-bit vector operations in parallel with multiple load / store, scalar floating-point, integer and control-flow operations in a single clock cycle. Vector processing engine 372 may receive one or more low-level machine instruction (e.g., from local memory 340 and / or memory 310) , and be configured to perform vector processing on the output of processing engine 370. The vector processing may include execution of one or more operations associated with post-processing engine 380, such as applying an activation function, scaling, and adding a bias, etc. Vector processing engine 372 may be configured through specialized kernel implementation to carry out specific activation functions. In some embodiments, post-processing engine 380 may include a software programmable look up table (LUT) 388. LUT 388 may include one or more sub-look up tables. LUT 388 may include a look up table. LUT 388 may be loaded with look up table values provided in a configuration descriptor (e.g., from local memory 340 and / or memory 310) , making LUT 388 software configurable. The look up table values include parameters for approximating a function, such as an activation function. An exemplary post-processing engine 380 is described and illustrated in FIG. 6.
[0058] Output module 390 drains data from processing engine 370 and / or from post-processing engine 380. Output module 390 may write the data to local memory 340. The drained data may be tensors, such as output tensors of neural network operations. In some embodiments, output module 390 may drain data on a cell level of processing engine 370. For each processing cell, output module 390 may drain outputs of processing elements in the processing cell based on a row index or column index of each processing element. For instance, output module 390 may use a sequence of cycles to drain data from a processing cell. Output module 390 may drain the output of some of the processing elements in each cycle. The sequence of the cycles may be configured based on a configuration parameter indicating the operation mode of load module 360. The drained data, e.g., tensors, may be further loaded to memory 310, e.g., through the DMA engine 320. Additionally or alternatively, the drained data may be loaded by the load module 360 to the processing engine 370 for further computation, e.g., for performing a deep learning operation in the next layer.
[0059] FIG. 4 illustrates DNN module 301, according to some embodiments of the disclosure. DNN module 301 includes interface module 410, training module 420, validating module 440, compiler 450, and datastore 460. In other embodiments, alternative configurations, different or additional components may be included in the DNN module 301. Further, functionality attributed to a component of DNN module 301 may be accomplished by a different component included in DNN module 301 or a different module or system.
[0060] Interface module 410 facilitates communications of DNN module 301 with other modules or systems. For example, interface module 410 establishes communications between DNN module 301 with an external datastore to receive data that can be used to train DNNs or input into DNNs to perform tasks. As another example, interface module 410 supports DNN module 301 to distribute DNNs to other systems, e.g., computing devices configured to apply DNNs to perform tasks.
[0061] Training module 420 trains DNNs by using a training dataset. Training module 420 forms the training dataset. In an example where training module 420 trains an DNN to recognize objects in images, the training dataset includes training images and training labels. The training labels describe ground-truth classifications of objects in the training images. In some embodiments, each label in the training dataset corresponds to an object in a training image. In an example where training module 420 trains a transformer-based neural network to predict the next token, the training data set may include a large library of sequences of tokens. In some embodiments, a part of the training dataset may be used to initially train the DNN, and the rest of the training dataset may be held back as a validation subset used by validating module 440 to validate performance of a trained DNN. The portion of the training dataset not including the tuning subset and the validation subset may be used to train the DNN.
[0062] Training module 420 also determines hyperparameters for training the DNN. Hyperparameters are variables specifying the DNN training process. Hyperparameters are different from parameters inside the DNN (e.g., weights of filters) . In some embodiments, hyperparameters include variables determining the architecture of the DNN, such as number of hidden layers, etc. Hyperparameters also include variables which determine how the DNN is trained, such as batch size, number of epochs, etc. A batch size defines the number of training samples to work through before updating the parameters of the DNN. The batch size is the same as or smaller than the number of samples in the training dataset. The training dataset can be divided into one or more batches. The number of epochs defines how many times the entire training dataset is passed forward and backwards through the entire network. The number of epochs defines the number of times that the deep learning algorithm works through the entire training dataset. One epoch means that each training sample in the training dataset has had an opportunity to update the parameters inside the DNN. An epoch may include one or more batches. The number of epochs may be 1, 5, 10, 50, 100, 500, 1000, or even larger.
[0063] Training module 420 can define the architecture of the DNN, e.g., based on some of the hyperparameters. In some cases, training module 420 may receive a model definition that defines or specifies the architecture of the DNN. The architecture of the DNN can include a plurality of layers. Examples of layers may include convolutional layers, pooling layers, fully connected layers, normalization layers, SoftMax or logit layers, and so on. After training module 420 defines the architecture of the DNN, training module 420 inputs a training dataset into the DNN. The training dataset includes a plurality of training samples. The training module 420 modifies the parameters inside the DNN ( “internal parameters of the DNN” ) to minimize the error between labels of the training objects that are generated by the DNN and the ground-truth labels of the objects. The internal parameters include weights used in layers of the DNN. In some embodiments, the training module 420 uses a cost function to minimize the error.
[0064] Training module 420 may train the DNN for a predetermined number of epochs. The number of epochs is a hyperparameter that defines the number of times that the deep learning algorithm will work through the entire training dataset. One epoch means that each sample in the training dataset has had an opportunity to update internal parameters of the DNN. After training module 420 finishes the predetermined number of epochs, training module 420 may stop updating the parameters in the DNN. The DNN having the updated parameters is referred to as a trained DNN.
[0065] Validating module 440 verifies accuracy of trained DNNs. In some embodiments, validating module 440 inputs samples in a validation dataset into a trained DNN and uses the outputs of the DNN to determine the model accuracy. In some embodiments, a validation dataset may be formed of some or all the samples in the training dataset. Additionally or alternatively, the validation dataset includes additional samples, other than those in the training sets. In some embodiments, validating module 440 may determine an accuracy score measuring the precision, recall, or a combination of precision and recall of the DNN. The validating module 440 may use the following metrics to determine the accuracy score: Precision = TP / (TP + FP) and Recall = TP / (TP + FN) , where precision may be how many the DNN correctly predicted (TP or true positives) out of the total it predicted (TP + FP or false positives) , and recall may be how many the DNN correctly predicted (TP) out of the total number of objects that did have the property in question (TP + FN or false negatives) . The F-score (F-score = 2 *PR / (P + R) ) unifies precision and recall into a single measure.
[0066] Validating module 440 may compare the accuracy score with a threshold score. In an example where validating module 440 determines that the accuracy score of the DNN is less than the threshold score, validating module 440 instructs th training module 420 to re-train the DNN. In one embodiment, training module 420 may iteratively re-train the DNN until the occurrence of a stopping condition, such as the accuracy measurement indication that the DNN may be sufficiently accurate, or a number of training rounds having taken place.
[0067] Compiler 450 compiles information associated with DNNs which can be used to cause DNN accelerator 302 of FIG. 3 to carry out neural network operations for DNNs. The information may include the model definition, one or more processing graphs, one or more data processing workloads produced from the one or more processing graphs, and executable instructions (e.g., configuration descriptors and / or low-level machine instructions) that can be executed by DNN accelerator 302. The model definition may include one or more neural network operations to be performed by the DNN. In some embodiments, compiler 450 may generate a processing graph representing a DNN. The graph may include nodes and edges. A node may represent a specific neural network operation in the DNN. An edge may connect two nodes and represent a connection between the two corresponding neural network operations. In an example, an edge may encode a tensor that flows from one of the neural network operations to the other neural network operation. The tensor may be an output tensor of the first neural network operation and an input tensor of the second neural network operation. The edge may encode one or more attributes of the tensor, such as size, shape, storage format, and so on. Compiler 450 may pre-process the processing graph to identify opportunities to streamline the processing graph so that DNN accelerator 302 may be used more efficiently and effectively. Compiler 450 may use the processing graph, such as the streamlined processing graph, to generate instructions (e.g., configuration descriptors and / or low-level machine instructions) . The instructions can be used and executed by components of the DNN accelerator 302 (e.g., processing engine 370 and post-processing engine 380 of FIG. 3) to perform one or more neural network operations of the DNN according to the streamlined processing graph. A configuration descriptor may include configuration values to be stored in one or more register files that can be used to configure one or more components of the DNN accelerator 302 (e.g., processing engine 370 and post-processing engine 380 of FIG. 3) . A configuration descriptor may include a look up table descriptor that includes one or more look up table values to be programmed onto LUT 388 of post-processing engine 380. A configuration descriptor may include a selection descriptor that specifies a portion of LUT 388 of post-processing engine 380 to be used (e.g., an address range, or an address offset / calculation) . The low-level machine instructions may be in a binary format, which may be loaded onto DNN accelerator 302 and executed by components of the DNN accelerator 302 (e.g., processing engine 370, post-processing engine 380, and / or vector processing engine 372 of FIG. 3) . An exemplary compiler 450 is described and illustrated in FIG. 7.
[0068] Datastore 460 stores data received, generated, used, or otherwise associated with the DNN module 301. For example, datastore 460 stores the datasets used by training module 420 and validating module 440. Datastore 460 may also store data generated by training module 420 and validating module 440, such as the hyperparameters for training DNNs, internal parameters of trained DNNs (e.g., weights, etc. ) , data for sparsity acceleration (e.g., sparsity bitmap, etc. ) , and so on. Datastore 460 may store configuration parameters, configuration descriptors, instructions generated by compiler 450, etc. The datastore 460 may include one or more memories. In the embodiment of FIG. 4, datastore 460 is a component of DNN module 301. In other embodiments, datastore 460 may be external to DNN module 301 and communicate with the DNN module 301 through a network.
[0069] FIG. 5 illustrates processing engine 370, according to some embodiments of the disclosure. Processing engine 370 may be included as part of a data processing unit, such as data processing unit 330 of FIG. 3. Processing engine 370 may include one or more processing cells 502. In some embodiments, processing cells 502 may be arranged in one or more rows and / or one or more columns in the processing engine 370. In some embodiments, processing cells 502 may be arranged as one or more sets or arrays of processing cells 502 performing different operations. Processing engine 370 may have one or more arrays of multiply and accumulate circuity (e.g., processing cells 502) optimized to perform compute operations such as matrix multiplication and convolution.
[0070] Each processing cell may include one or more processing elements. In some cases, a processing cell includes a single processing element. In some cases, a processing cell includes a plurality of processing elements. The processing elements may be arranged as an array. The processing elements may be arranged in rows and / or columns. In some cases, a processing cell may include processing element (s) that perform the same operation. In some cases, a processing cell may include processing element (s) that perform different operations. In some cases, at least some of the processing element (s) in a processing cell may be arranged to perform operations in parallel. In some cases, at least some of the processing element (s) in a processing cell may be arranged to perform operations serially.
[0071] A processing element may perform an arithmetic operation associated with neural network operations or DNN operations. In some cases, the one or more processing elements that may be arranged in an array that includes rows and columns. Examples of processing elements may include a multiply unit, a division unit, a scaling unit, an adding unit, an accumulator unit a subtractor unit, a logarithmic unit, an exponentiation unit, a multiply-accumulate (MAC) unit, a bit shift unit, a square root unit, etc. The processing elements in processing cells may be arranged to perform an arithmetic operation on a vector of inputs to generate a vector of outputs (in parallel) , sometimes referred to as vector processing. The processing elements in processing cells may perform scalar operations.
[0072] Processing engine 370 may include controller 504, which may configure circuitry of one or more processing cells 502 to perform the arithmetic operations. In some cases, controller 504 may configure one or more processing cells 502 (or individual processing elements in a processing cell 502) to perform operations in a particular sequence or manner. In some cases, controller 504 may configure one or more processing cells 502 (or individual processing elements in a processing cell 502) according to instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 506. Controller 504 may include a program counter to determine the instructions loaded in instruction buffer 506 to be executed by one or more processing cells 502 (or individual processing elements in a processing cell 502) . Instruction buffer 506 may include one or more register files.
[0073] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 506 may signal which processing cells 502 (or individual processing elements in a processing cell 502) is to execute or carry out one or more operations.
[0074] Data may be loaded in data buffers 508 by load module 360 of FIG. 3. The data may be used by processing cells 502. Data produced by processing cells 502 may be drained from data buffers 508 by output module 390 to local memory 340 of FIG. 3.
[0075] Data buffers 508 may include one or more of: one or more input data buffers, and one or more output data buffers. Data buffers 508 may include one or more weights / parameters buffers. Data buffers 508 may store operands for one or more processing elements of processing cell 502. Data buffers 508 may store generated outputs of one or more processing elements of processing cell 502. Data buffers 508 may include one or more register files.
[0076] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 506 may signal which data stored in data buffers 508 is to be processed by processing cells 502 (or individual processing elements in a processing cell 502) . In some cases, the processing cells 502 (or individual processing elements in a processing cell 502) may read data from data buffers 508 at a default location for the processing cell 502 or an individual processing element in the processing cell 502.
[0077] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 506 may signal where to store output data in data buffers 508 after processing cells 502 produces the output data. In some cases, the processing cells 502 (or individual processing elements in a processing cell 502) may write data to data buffers 508 at a default location for the processing cell 502 or an individual processing element in the processing cell 502.
[0078] Load module 360 of FIG. 3 may load data to certain locations in data buffers 508. Output module 390 of FIG. 3 may drain data from data buffers 508 to be stored in local memory 340 and / or memory 310 of FIG. 3.
[0079] FIG. 6 illustrates post-processing engine 380, according to some embodiments of the disclosure. As discussed previously with FIGURE 3, post-processing engine 380 may process the output (e.g., a tensor) produced by processing engine 370. Some exemplary components in post-processing engine 380 are depicted. In some embodiments, post-processing engine 380 may include bias 602 to add a bias to the output produced by processing engine 370. In some embodiments, post-processing engine 380 may include scale 604 to scale (e.g., multiply by a number) the output produced by processing engine 370. In some embodiments, post-processing engine 380 may include output conversion 660, which may convert the data to different precisions such as integer precision, floating-point precision, etc. Output conversion 660 may convert data between precisions such as INT8, FP16, FP32, etc. Output conversion 660 may perform quantization according to a quantization specified in a configuration descriptor.
[0080] In some embodiments, post-processing engine 380 may apply an approximated version (e.g., using linear approximation) of an activation function to the output produced by processing engine 370. Post-processing engine 380 may include address logic 606, LUT 388, and computation unit 610, to apply the approximated version of the activation function. Specifically, LUT 388 may store one or more look up table values provided in a configuration descriptor that configures post-processing engine 380. The look up table values may approximate a function, such as an activation function or another suitable function. Specifically, the look up table values includes parameters for linear segments that approximate the activation function. The linear segments may correspond to different portions of the input range. In some cases, the look up table values may include parameters for other types of segments, such as saturation segments or fixed segments. At different addresses of LUT 388, LUT 388 may store one or more look up table values that specify the segments corresponding to a particular portion of the input range. Parameters for a linear segment can include a slope of a line and an intercept of the line corresponding to the linear segment.
[0081] When post-processing engine 380 receives an input data element, address logic 606 may identify the segment to which the input data element belongs, and therefore the location (e.g., address of LUT 388) where parameters for the segments would be stored. Address logic 606 may determine the address of LUT 388 that is storing one or more look up table values that can be used to calculate an approximation of the function being applied to the input data element (e.g., one or more parameters that specify the segment) . The one or more look up table values may be retrieved from LUT 388 and provided to computation unit 610. Computation unit 610 may compute an output of a linear function corresponding to the linear segment using the one or more look up table values, e.g., the one or more parameters that specify the linear segment. Computation unit 610 may perform multiplication and adding to determine the output of the linear function. Specifically, computation unit 610 may multiply the input data element by a slope of the linear function and add the result of the multiplication by an intercept of the linear function (where both the slope and the intercept may be stored in LUT 388 at the address determined by address logic 606. The output of the linear function calculated by computation unit 610 serves as the approximated output of the function being approximated by LUT 388. In another example where the input data element corresponds to a saturation segment, computation unit 610 may be bypassed. A saturation value may be retrieved from LUT 388 and used as the approximated output of the function being approximated by LUT 388.
[0082] The approximation of activation functions with linear segments and saturation segments though the use of LUT 388 may include approximation of sign, exponent, and mantissa parts of each output data element. An activation function may be approximated using other functions (e.g., reciprocal function or inverse square root function) , in which the mantissa part of each output data element may be approximated while the exponent part may be a configuration parameter in the configuration descriptor and may be approximated without further computation by computation unit 610.
[0083] A configuration descriptor may include one or more look up table values for LUT 388. The configuration descriptor may be provided to post-processing engine 380 of a DPU to load the one or more look up table values for LUT 388. The one or more look up table values may be determined by a compiler (e.g., compiler 450 of FIG. 4 and 7) or a DNN module (e.g., DNN module 301 of FIGS. 3 and 4) .
[0084] In some cases, LUT 388 may have multiple sub-look up tables, or sections of address ranges of LUT 388 may be dedicated to storing one or more look up table values for approximating different functions. If configured to use an address offset, or an address calculation / mapping function, address logic 606 may apply the address offset or the address calculation / mapping function when determining the address of LUT 388 that is storing the segment to which the input data element belongs and which sub-look up table or section of LUT 388 to use to calculate an approximated output. An address offset can specify a constant shift to be applied to the addresses of LUT 388 so that a shifted address range (or section) of LUT 388 is accessed. An address calculation / mapping function can specify a transformation to be applied to the addresses of LUT 388 so that a certain shifted address range (or section) of LUT 388 is accessed. The address offset or the address calculation / mapping function can cause different sub-look up tables or sections of LUT 388 to be selected and applied.
[0085] A configuration descriptor may include an address offset value or an address calculation / mapping function to be applied by address logic 606 in determining the address in LUT 388 to which an input data element belongs. The configuration descriptor may be provided to post-processing engine 380 of a DPU to cause address logic 606 to apply the address offset value or the address calculation / mapping function when calculating an address of LUT 388 for an input data element. The address offset value or the address calculation / mapping function may be determined by a compiler (e.g., compiler 450 of FIGS. 4 and 7) or a DNN module (e.g., DNN module 301 of FIGS. 3 and 4) .
[0086] One or more outputs produced by post-processing engine 380 may be provided to local memory 340 of data processing unit 330 via output module 390 of FIG. 3.
[0087] A compiler to pre-process a neural network definition to identify opportunities to streamline a processing graph
[0088] FIG. 7 illustrates compiler 450, according to some embodiments of the disclosure. Compiler 450 includes neural network analyzer 702, configuration descriptors generator 708, and scheduler 710. Compiler 450 implements one or more features that enable DPUs of neural network hardware accelerator to be utilized more efficiently and fully when executing DNNs.
[0089] Neural network analyzer 702 may perform the pre-processing process as described and illustrated herein to streamline a processing graph of DNN to be executed by one or more DPUs of a neural network hardware accelerator. Neural network analyzer 702 may receive a neural network model definition of a DNN. A neural network model definition may specify one or more layers of a neural network. For example, a neural network model definition may specify layers of the neural network and how the data should flow through the layers. A layer can be specified by the neural network operation that the layer performs. Examples of layers can include fully connected (linear) layer, convolutional layer, recurrent layer, long short-term memory network, gated recurrent unit layer, max pooling layer, average pooling layer, batch normalization layer, normalization layer, dropout layer, activation layer, embedding layer, etc. The layer can be specified by one or more of: input size, hidden size, output size, etc. The layer can be specified by one or more parameters of the neural network operation (e.g., for a convolutional layer, one or more parameters may include kernel size, padding, stride, etc. ) .
[0090] In some cases, neural network analyzer 702 may determine a processing graph based on the neural network model definition. A processing graph may include connected nodes. The connected nodes can represent neural network operations to be executed by one or more data processing units and an order of execution of the neural network operations. The edges connecting the nodes can represent the flow of data between the neural network operations. An edge connecting a node and a further node that follows the node may represent that an output generated by the node is to be provided as an input to the further node. Thus, the further node following the node can mean that the neural network operation corresponding to the further node is to be executed after the neural network operation corresponding to the node, or equivalently, that the neural network operation corresponding to the node is to be executed before the neural network operation corresponding to the further node. The neural network operations can be executed by a data processing pipeline of a data processing unit, such as a processing engine of a data processing unit, or a post-processing engine of a data processing unit. The neural network operations can be executed by one or more data processing units or one or more parts of a data processing unit, according to the order of execution represented by the processing graph. Examples of neural network operations can include: a compute operation, convolution, filtering, pooling, matrix multiplication, applying an activation function (clamping function, exponential function, sigmoid function, power function, square root function, a function illustrated in TABLE 1, etc. ) . In some cases, the neural network model definition includes the processing graph. Neural network analyzer 702 may examine a neural network model definition (or the processing graph) to identify nodes (e.g., nodes presenting activation functions) which can be merged. In some cases, neural network analyzer 702 may include one or more of serial merge 704 and branch merge 706.
[0091] As illustrated by FIGS. 1A-B and discussed in the overview, there are opportunities for streaming a processing graph of a neural network model definition by identifying and merging serial activation functions. Serial merge 704 of neural network analyzer 702 may determine whether an activation function follows a further activation function in a neural network model definition. In some cases, serial merge 704 may determine whether a node representing the activation function leads a further node representing the further activation function in the processing graph. In some cases, serial merge 704 may determine whether the further node representing the further activation function follows a node representing the activation function in the processing graph. In some cases, serial merge 704 may determine whether the activation function is to be executed before the further activation function according to the processing graph. In some cases, serial merge 704 may determine whether an output of the activation function is to be provided as an input to the further activation function according to the processing graph (e.g., an output of the activation function is an input to the further activation function) . In some cases, serial merge 704 may determine whether the further activation function to the processing graph is to be executed after / subsequent to the activation function according to processing graph. In some cases, serial merge 704 may determine whether the further activation function receives and processes the output of the activation function according to the processing graph. Serial merge 704 may determine whether the neural network model definition specifies two or more serial activation functions. Serial merge 704 may combine the contiguous / serial / sequential activation functions into a composite function. Serial merge 704 may combine or merge the contiguous nodes into a single node in the neural network definition and / or the processing graph, where the single node can perform the merged contiguous / serial / sequential activation functions. Serial merge 704 can streamline the processing graph to address the inefficiencies illustrated in FIGS. 1A-B. In some scenarios, two or more data processing workloads would be sent to be executed by a DPU without merging. With merging and a more streamlined processing graph, a single data processing workload can be sent to be executed by the DPU.
[0092] As illustrated by FIG. 2 and discussed in the overview, there are opportunities for streaming a processing graph of a neural network model definition by identifying and merging parallel activation functions. Branch merge 706 may determine whether an activation function and a further activation function are in respective parallel paths following a node in a neural network model definition or in a processing graph. Branch merge 706 may determine whether the neural network model definition specifies two or more parallel activation functions (e.g., two or more branch nodes) off the node. In some cases, branch merge 706 may determine whether the activation function and the further activation function processes an output of a node in the processing graph (e.g., the same output of the node in the processing graph is processed by the activation function and the further activation function in parallel) . In some cases, branch merge 706 may determine whether an output of the node in the processing graph is an input of the activation function and is an input of the further activation function according to the processing graph. In some cases, branch merge 706 may determine whether the activation function and the further activation function can be executed in parallel to process the output of the node. Branch merge 706 may merge the parallel activation functions of the parallel branch nodes to implement a multi-function node in place of an individual branch node. The multi-function node can be configured to execute a selected one of the merged parallel activation functions. Branch merge 706 may update one or more branch nodes of the parallel branch nodes in the neural network definition and / or the processing graph to implement one or more multi-function nodes. Branch merge 706 can streamline the processing graph to address the inefficiencies illustrated in FIG. 2. In some scenarios, high overhead would be incurred to load different configuration descriptors onto the DPU to execute the parallel activation functions without merging. With merging and a more streamlined processing graph, overhead is reduced by loading the configuration descriptors that configure the DPUs to execute a selected one of the merged parallel activation functions. Streamlining the processing graph to include multi-function nodes may facilitate scheduling data processing workloads to be executed in parallel or serially.
[0093] Configuration descriptors generator 708 may generate one or more configuration descriptors that can cause one or more DPUs to execute the operations in the streamlined processing graph. The one or more configuration descriptors may correspond to one or more data processing workloads to be executed by the one or more DPUs. As discussed previously, a configuration descriptor includes information which can configure the data processing pipeline of a DPU to execute a data processing workload. A configuration descriptor may include a portion that can configure the processing engine of a DPU to carry out one or more compute operations of the data processing workload. The configuration descriptor may include a portion that has one or more look up table values which can be loaded onto one or more programmable look up tables of a PPE of a DPU to carry out one or more post-processing operations (e.g., a composite function, an activation function, etc. ) of the data processing workload, or a selected activation function among a plurality of activation functions corresponding to the data processing workload. Configuration descriptors generator 708 may be tasked to generate configuration descriptors that can be used by neural network hardware accelerator to execute data processing workloads of a streamlined processing graph of a neural network definition.
[0094] Scheduler 710 may coordinate, based on the streamlined processing graph, when and which DPUs should have the configuration descriptors loaded to execute the data processing workloads. The data processing workloads may be allocated by scheduler 710 to the DPUs in a neural network hardware accelerator, and scheduler 710 may coordinate to have the corresponding configuration descriptors (or one or more parts of a configuration descriptor) provided to the DPUs. In some cases, scheduler 710 may determine a plan that can load balance execution of the data processing workloads. Scheduler 710 may determine a plan that ensures the data processing workloads are being executed according to the streamlined processing graph. Scheduler 710 may determine a plan to cause a configuration descriptor or a portion of a configuration descriptor to be loaded onto a DPU at an appropriate time. In some cases, scheduler 710 may be a part of compiler 450. In some cases, scheduler 710 may be a part of DNN module 301 of FIGS. 3-4.
[0095] In response to serial merge 704 determining that the activation function follows the further activation function (the activation function and the further activation function are contiguous / serial / sequential nodes) , configuration descriptors generator 708 may determining one or more look up table values that approximate a composite function that combines the activation function and the further activation function. Scheduler 710 may provide, to a data processing unit of a neural network hardware accelerator, a configuration descriptor having the one or more look up table values.
[0096] The one or more look up table values are included in a configuration descriptor, which configures the data processing unit to load the one or more look up table values onto a programmable look up table of the data processing unit (e.g., LUT 388 of FIGS. 3 and 6) .
[0097] Configuration descriptors generator 708 may determine the one or more look up table values that approximate the composite function by determining one or more parameters of a linear segment that approximates a portion of the composite function. The portion of the composite function corresponds to an input range of the composite function. The one or more parameters of a linear segment may include a slope and an intercept of a linear function. Configuration descriptors generator 708 may determine the one or more look up table values that approximate the composite function by determining one or more parameters of a saturation segment that approximates a portion of the composite function that corresponds to an input range of the composite function. The one or more parameters of a saturation segment may include a saturation value.
[0098] In response to branch merge 706 in response to determining that the whether the activation function and the further activation function are in the respective parallel paths (the activation function and the further activation function are branch nodes) , configuration descriptors generator 708 may determine one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function. Scheduler 710 may provide, to a data processing unit of the neural network hardware accelerator, a configuration descriptor having the one or more look up table values and the one or more further look up table values.
[0099] The one or more further look up table values that approximate the activation function and the one or more yet further look up table values that approximate the further activation function are included in a further configuration descriptor, which configures a further data processing unit to load the one or more further look up table values and the one or more yet further look up table values onto a further programmable look up table of the further data processing unit. The further programmable look up table thus has separate sections or multiple sub-look up tables that have the one or more further look up table values that approximate the activation function, and the one or more yet further look up table values that that approximate the further activation function. The further programmable look up table may be multi-functional and includes look up table values that separately approximate multiple functions.
[0100] During execution, only a section of the further programmable look up table or a sub-look up table is used for applying a function. Configuration descriptors generator 708 determining the further configuration descriptor may include information that specifies which section or sub-look up table to use. In some embodiments, the further configuration descriptor specifies one or more of: an address range for the activation function, and a further address range for the further activation function. In some embodiments, the further configuration descriptor specifies an address offset and / or an address calculation / mapping function, which can be used to configure an address logic (e.g., address logic 606 of FIG. 6) to utilize a specific section or sub-look up table to apply a selected function among multiple functions supported by the further programmable look up table.
[0101] Configuration descriptors generator 708 may determine the one or more further look up table values that approximate the activation function by determining one or more further parameters of a further linear segment that approximates a further portion of the activation function that corresponds to a further input range of the activation function. The one or more further parameters of the further linear segment may include a slope and an intercept of a linear function. Configuration descriptors generator 708 may determine the one or more further look up table values by determining one or more further parameters of a saturation segment that approximates a portion of the activation function that corresponds to an input range of the activation function. The one or more parameters of a saturation segment may include a saturation value.
[0102] Configuration descriptors generator 708 may determine the one or more yet further look up table values that approximate the further activation function by determining one or more yet further parameters of a yet further linear segment that approximates a yet further portion of the further activation function that corresponds to a yet further input range of the further activation function. The one or more yet further parameters of the yet further linear segment may include a slope and an intercept of a linear function. Configuration descriptors generator 708 may determine the one or more yet further look up table values by determining one or more yet further parameters of a saturation segment that approximates a portion of the further activation function that corresponds to an input range of the further activation function. The one or more parameters of a saturation segment may include a saturation value.
[0103] Referring to FIGS. 3-7, DNN system 300 illustrates one implementation of a processor designed to accelerate execution of DNNs. The architecture design of a processor can vary depending on the application requirements of the processor. The architecture design can vary based on the number of DPUs, the number of processing engines, the number of processing cells, the number of post-processing engines, structure of the data processing pipeline in a DPU, support for vector processing, support for sparsity modes, the types or collection of processing elements, amount of memory and buffer size, etc.
[0104] Global optimization in the neural network analyzer of the compiler
[0105] In some cases, neural network analyzer 702 of FIG. 7 may selectively apply operations associated with serial merge 704 and / or operations associated with branch merge 706 based on one or more criteria and / or one or more trade-offs. Neural network analyzer 702 may perform optimization based on an objective function that may balance latency and accuracy. Associated latency reduction and / or accuracy impact associated with different candidates for serial merge and / or branch merge may be tabulated to determine the set of serial merging and / or branch merging that optimally maximizes or minimizes the objective function. Neural network analyzer 702 may perform optimization based to reach one or more of: target latency and target accuracy. Associated latency reduction and / or accuracy impact associated with different candidates for serial merge and / or branch merge may be tabulated to determine the set of serial merging and / or branch merging that meets one or more of: target latency and target accuracy.
[0106] Neural network analyzer 702 may identify a number of contiguous nodes as candidates for merging to achieve a certain expected amount of performance gain. Because the performance gain (e.g., reduction in latency) is directly correlated with the number of nodes which are merged, neural network analyzer 702 may analyze to determine which contiguous nodes are frequently appearing in the neural network definition, and target merging those frequently appearing contiguous nodes. In some cases, neural network analyzer 702 may merge any and all contiguous nodes.
[0107] Neural network analyzer 702 may identify certain types of contiguous nodes as candidates for merging to achieve a certain expected amount of accuracy improvement. When merging some types of contiguous nodes, there is a performance-to-accuracy trade-off. If the accuracy degradation due to merging of the particular type of contiguous nodes is more than the desired or tolerated amount, the performance gains of merging the contiguous nodes could be given up for the additional accuracy of implementing the contiguous nodes separately.
[0108] Neural network analyzer 702 may identify a number of branch nodes, e.g., parallel activation functions, as candidates for merging to achieve a certain expected amount of performance gain. Because performance gain is directly related to the number of branch nodes that can be merged, neural network analyzer 702 may analyze to determine which branch nodes are frequently appearing in the neural network definition, and target merging those frequently appearing branch nodes. In some cases, neural network analyzer 702 may merge any and all branch nodes.
[0109] Neural network analyzer 702 may identify certain types of branch nodes as candidates for merging to not exceed a certain expected amount of accuracy degradation. Neural network analyzer 702 may identify certain types of branch nodes as candidates for merging to meet a maximum amount of tolerated accuracy loss. The size of the programmable look up table or a group of programmable look up tables in the PPE, e.g., the number of look up table values the look up table can store, is limited. Therefore, there is an accuracy-to-area trade-off neural network analyzer 702 identifies and merges branch nodes. Merging branch nodes onto the (same) programmable look up table or group of programmable look up tables can mean that fewer look up table values can be used to approximate an activation function, which can impact accuracy of the approximation. The branch nodes identified using the pre-processing process can trade-off accuracy to meet area requirements. For the cases where the programmable look up table values for two or more activation functions may fit within hardware area budget (e.g., the size of the programmable look up table or group of programmable look up tables of a PPE) , there is no penalty on accuracy. However, when the programmable look up table values for two or more activation functions do not fit with the hardware area budget, accuracy could be traded-off for performance gain. In addition, there is a performance-to-accuracy trade-off. If the accuracy degradation due to merging of branch nodes into the same programmable look up table is more than the desired or tolerated amount, the performance gains of implementing merging the branch nodes could be given up for the additional accuracy of implementing the branch nodes separately.
[0110] Simulated results
[0111] In one simulation, a neural network definition includes three nodes in this order: convolution, sigmoid function, and square root function. A processing graph, without applying operations associated with serial merge 704 of FIG. 7, may include a first data processing workload to perform convolution and sigmoid, and a second data processing workload following the first data processing workload to perform max pooling (or identity) and square root. Serial merge 704 may identify sigmoid function and the square root function as candidates to be merged. A streamlined processing graph, after applying operations with serial merge 704, may include a data processing workload to perform convolution and a composite function that combines the sigmoid function and the square root function. The reduction to one data processing workload to be executed by a DPU lead to a significant decrease in computation time (in the simulation, a 47%improvement was demonstrated) . In addition, decrease in computation time may linearly increase with more streamlining of the processing graph to merge additional serial activation functions.
[0112] In one simulation, a neural network definition includes four branch nodes after a convolution node, the four branch nodes include a hyperbolic tangent function, a sigmoid function, a sigmoid function, and a sigmoid function, respectively. A processing graph, without applying operations associated with branch merge 706 of FIG. 7, may in the worst case scenario, include performing four data processing workloads to complete the convolution node followed by the four branch nodes. Branch merge 706 may identify the hyperbolic tangent function and the sigmoid function as candidates to be merged. A streamlined processing graph, after applying operations with branch merge 706, may include data processing workloads to perform convolution and a selected function using a programmable look up table that supports hyperbolic tangent function and the sigmoid function merged by branch merge 706. In the simulation, a neural network hardware accelerator executing the processing graph achieved a performance of 108 frames per second (FPS) , and a latency of 9.26 milliseconds. FPS can indicate how many inference operations can be processed per second. Latency can measure the time taken to process a single inference operation. In the simulation, a neural network hardware accelerator executing the streamlined processing graph achieved a performance of 169 frames per second, and a latency of 5.93 milliseconds. The performance improvement can be attributed to the efficient fusion of branched nodes into multi-function nodes (and implementing multiple functions onto a look up table or respective sub-look up tables) , which likely reduced the overhead associated with memory accesses and enabled more parallel execution of data processing workloads. The streamlined processing graph resulted in a significant increase in frames per second and a significant decrease in latency (in the simulation, a 56.5%increase in FPS and a 35.96%reduction in latency were demonstrated) . Merging branch nodes accelerated inference speed and reduced processing time for each frame.
[0113] Performance improvements achieved by serial merge 704 and / or branch merge 706 can enable real-time applications with low latency and high throughput to be carried out using the neural network hardware accelerator.
[0114] Exemplary activation functions and exemplary composite functions
[0115] Serial merge 704 and / or branch merge 706 may be used to merge two or more activation functions. As discussed previously, the area or size of the programmable look up table is limited. Accuracy of the approximation of a function, such as a non-linear function, generally increases when more LUT entries are used to approximate more segments of the function. When a function has more linear-like or flat / straight segments, fewer LUT entries may be used to linearly approximate the function to achieve a certain level of accuracy.
[0116] When determining which activation functions to merge, serial merge 704 may take into account whether a composite function can achieve better, the same, or worse accuracy than individual activation functions separately.
[0117] When determining which activation functions to merge, branch merge 706 may take into account whether look up table values for the individual activation functions can fit within the area budget of the programmable look up table to achieve a certain level of accuracy for the individual activation functions. Branch merge 706 may allocate specific number of LUT entries for the individual activation functions to achieve certain levels of accuracy for the individual activation functions.
[0118] Exemplary activation functions, a number of LUT entries to approximate an activation function, and a corresponding worst case accuracy (in ULP) are shown in the following table.
[0119] TABLE 1
[0120] FIG. 8 illustrates a sigmoid function and a composite function combining a sigmoid function and a square root function, according to some embodiments of the disclosure. As seen in the table above, the sigmoid function can be implemented using 198 LUT entries with a worst case accuracy of 2 ULP. The square root function can be implemented using 239 LUT entries with a worst case accuracy of 1 ULP. The composite function depicted on the plot of FIG. 8 is flatter than the sigmoid function. The square root function is mathematically equivalent to a power function raising an input data element to a power of 0.5.
[0121] The sigmoid function, in the positive input region, may use many linear segments (e.g., 32) to approximate the region around input = 3 considering the shape of the sigmoid function. The sigmoid function, in the negative input region, may use many linear segments (e.g., 96) to approximate the region around input = -2 for ULP = 2.
[0122] The composite function, in the positive input region, may use fewer linear segments (e.g., 16) to approximate the region around input = 3 considering the shape of the composite function. The composite function, in the negative input region, may use many linear segments (e.g., 96) to approximate the region around input = -2 for a higher accuracy of ULP = 1. The square root function, when merged with the sigmoid function to form the composite function, linearizes the shape of the curve and allows for piecewise linear approximation of the function with better accuracy (e.g., lower ULP) . Accuracy can be improved 3X by using the composite function.
[0123] Another example of a composite function combining two activation functions that can achieve better accuracy is a composite function that combines a clamping function and an exponential function. As seen in the table above, the exponential function can be implemented using 238 LUT entries with a worst case accuracy of 4 ULP. The composite function combining the clamping function and the exponential function can achieve a worst case accuracy of 1 ULP. The clamping function, when merged with the exponential function to form the composite function, reduces the range and allows for piecewise linear approximation of the function with saturation segments with better accuracy (e.g., lower ULP) and fewer LUT entries.
[0124] Branch nodes performing a hyperbolic tangent function and a sigmoid function (which is one of the more common branch nodes in neural network model definitions surveyed) can be merged and loaded together onto a single programmable look up table (or multiple sub-look up tables) with only minor accuracy degradation. As seen in the table above, the hyperbolic tangent function can be implemented using 64 LUT entries with a worst case accuracy of 1 ULP, and the sigmoid function can be implemented using 198 LUT entries with a worst case accuracy of 2 ULP. If the area or size of the programmable LUT is limited to, e.g., 256 LUT entries, it is not possible to fit 64+198=262 LUT entries (for both the hyperbolic tangent function and the sigmoid function) into the programmable LUT. However, with slight degradation in accuracy for approximating the hyperbolic tangent function with a worse case accuracy of 2 ULP, both the hyperbolic tangent function and the sigmoid function LUT entries can fit onto the programmable LUT and achieve the performance benefits described herein.
[0125] Determining look up table values for activation functions and composite functions
[0126] Configuration descriptors generator 708 of FIG. 7 may determine look up table values having parameters that allow for piecewise approximation, or piecewise linear approximation of a function, such as an activation function, or a composite function. Examples of functions for approximating non-linear activation functions may include linear function, saturation function, reciprocal function, inverse square root function, and so on. A linear function may be denoted as y=ax+b, where a denotes the slope of the linear function, b denotes the intercept of the linear function, x denotes the input of the linear function, and y denotes the output of the linear function. A saturation function may be denoted as y=c, x∈(a, b) , where c denotes a saturation value that is a fixed value (e.g., a constant) , x denotes the input of the saturation function that falls into a range from a minimum value a to a maximum value b, and y denotes the output of the saturation function.
[0127] In some embodiments, configuration descriptors generator 708 may facilitate programmable piecewise linear approximation of non-linear activation functions. Configuration descriptors generator 708 may identify one or more linear segments in the input range. For instance, configuration descriptors generator 708 may identify a segment in the input range. Configuration descriptors generator 708 may determine a linear function for the segment and evaluate the accuracy of the linear function. Configuration descriptors generator 708 may measure the accuracy of the linear function by comparing outputs of the linear function with real outputs of the non-linear activation function for inputs falling into the segment. Configuration descriptors generator 708 may determine whether the accuracy of the linear function meets a desired accuracy, e.g., whether the accuracy is no less than the desired accuracy. In embodiments where the accuracy meets the desired accuracy, configuration descriptors generator 708 may store parameters of the linear function (e.g., slope and intercept) as look up table values for a look up table. In embodiments where the accuracy does not meet the desired accuracy, configuration descriptors generator 708 may divide the segment into multiple smaller segments and determine whether any of the smaller segment is a linear segment. Configuration descriptors generator 708 may store the parameters of all identified linear segments as look up table values for a look up table.
[0128] In addition to the look up table values, configuration descriptors generator 708 may also generate LUT configuration parameters, which may be stored in a LUT configuration table. The LUT configuration parameters may be used to search for or address intercepts and slopes of linear segments corresponding to different input ranges in the look up table. For instance, the LUT configuration parameters may include information indicating addresses or address ranges of entries in the LUT that correspond to different input ranges. An entry in the LUT may encode the intercept and slope of a linear segment. The LUT configuration parameters may be used to determine addresses of the entries for the linear functions that are to be used for approximating the non-linear activation function.
[0129] In some embodiments, configuration descriptors generator 708 may also determine whether a segment of the input range is a saturation segment. For instance, configuration descriptors generator 708 may determine whether outputs of the non-linear activation function may be approximated by a fixed value within a segment of the input range. In embodiments where configuration descriptors generator 708 determines that outputs of the non-linear activation function may be approximated by a single value within the segment, configuration descriptors generator 708 may classify the segment as a saturation segment. Configuration descriptors generator 708 may compute parameters of the saturation segment (e.g., the saturation value, the minimum value of the segment, the maximum value of the segment, etc. ) in a saturation table. The saturation table may also store one or more values for one or more other saturation segments.
[0130] In embodiments where configuration descriptors generator 708 determines to use other functions to approximate a non-linear activation function, configuration descriptors generator 708 may generate other configuration parameters. In some embodiments, configuration descriptors generator 708 generates a configuration description for each to-be-approximated non-linear activation function. The configuration descriptor may include all the configuration parameters determined by configuration descriptors generator 708 for the non-linear activation function.
[0131] Exemplary methods for enhancing performance and / or accuracy of neural networks on a neural network hardware accelerator
[0132] FIG. 9 is a flowchart showing a method for merging serial activation functions, according to some embodiments of the disclosure. Method 900 can be performed using a computing device, such as computing device 1100 in FIG. 11. Method 900 may be performed using one or more parts illustrated FIGS. 3-7. Method 900 may be an exemplary method performed by DNN module 301 or compiler 450 as illustrated in FIGS. 4 and 7. Method 900 may be used for executing a neural network. The neural network may be executed on, e.g., one or more of: a hardware processor, a DNN accelerator, a neural network hardware accelerator having one or more data processing units, field programmable gate array, hardware logic, hardware circuitry, application-specific integrated circuit, etc.
[0133] In 902, a processing graph is determined based on a neural network model definition. The neural network model definition specifies one or more layers of the neural network. The processing graph has connected nodes representing neural network operations to be executed by the one or more data processing units. The processing graph may represent an order of execution of the neural network operations.
[0134] In 904, whether an output of an activation function is an input of a further activation function according to the processing graph is determined.
[0135] In 906, in response to determining that the output of the activation function is the input of the further activation function, one or more look up table values that approximate a composite function are determined. The composite function combines the activation function and the further activation function.
[0136] In 908, (in response to determining that the output of the activation function is the input of the further activation function) a configuration descriptor having the one or more look up table values is provided to a data processing unit of the neural network hardware accelerator
[0137] In 910, (in response to determining that the output of the activation function is the input of the further activation function) the one or more look up table values are loaded onto a programmable look up table of the data processing unit.
[0138] In some embodiments, the activation function is a clamping function and the further activation function is an exponential function.
[0139] In some embodiments, the activation function is a sigmoid function and the further activation function is a power function.
[0140] In some embodiments, the activation function is a sigmoid function and the further activation function is a square root function.
[0141] In some embodiments, the activation function and the further activation function are a combination of activation functions illustrated in TABLE 1.
[0142] FIG. 10 is a flowchart showing a method for merging parallel activation functions, according to some embodiments of the disclosure. Method 1000 can be performed using a computing device, such as computing device 1100 in FIG. 11. Method 1000 may be performed using one or more parts illustrated FIGS. 3-7. Method 1000 may be an exemplary method performed by DNN module 301 or compiler 450 as illustrated in FIGS. 4 and 7. Method 1000 may be used for executing a neural network. The neural network may be executed on, e.g., one or more of: a hardware processor, a DNN accelerator, a neural network hardware accelerator having one or more data processing units, field programmable gate array, hardware logic, hardware circuitry, application-specific integrated circuit, etc.
[0143] In 1002, a processing graph is determined based on a neural network model definition. The neural network model definition specifies one or more layers of the neural network. The processing graph has connected nodes representing neural network operations to be executed by the one or more data processing units. The processing graph may represent an order of execution of the neural network operations.
[0144] In 1004, whether an output of a node in the processing graph is an input of an activation function and is an input of a further activation function according to the processing graph is determined.
[0145] In 1006, in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, one or more look up table values that approximate the activation function and one or more further look up table values that approximate the further activation function are determined.
[0146] In 1008, (in response to determining that the output of the node is the input of the activation function and is the input of the further activation function) a configuration descriptor having the one or more look up table values and the one or more further look up table values is provided to a data processing unit of the neural network hardware accelerator.
[0147] In 1010, the one or more look up table values and the one or more further look up table values are loaded onto a programmable look up table of the data processing unit.
[0148] In some embodiments, the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.
[0149] In some embodiments, the activation function and the further activation function are a combination of activation functions illustrated in TABLE 1.
[0150] Exemplary computing device
[0151] FIG. 11 is a block diagram of an apparatus or a system, e.g., an exemplary computing device 1100, according to some embodiments of the disclosure. One or more computing devices 1100 may be used to implement the functionalities described with the FIGS. and herein. A number of components illustrated in FIG. 11 can be included in the computing device 1100, but any one or more of these components may be omitted or duplicated, as suitable for the application. In some embodiments, some or all of the components included in the computing device 1100 may be attached to one or more motherboards. In some embodiments, some or all of these components are fabricated onto a single system on a chip (SoC) die. Additionally, in various embodiments, the computing device 1100 may not include one or more of the components illustrated in FIG. 11, and the computing device 1100 may include interface circuitry for coupling to the one or more components. For example, the computing device 1100 may not include a display device 1106, and may include display device interface circuitry (e.g., a connector and driver circuitry) to which a display device 1106 may be coupled. In another set of examples, the computing device 1100 may not include an audio input device 1118 or an audio output device 1108 and may include audio input or output device interface circuitry (e.g., connectors and supporting circuitry) to which an audio input device 1118 or audio output device 1108 may be coupled.
[0152] The computing device 1100 may include a processing device 1102 (e.g., one or more processing devices, one or more of the same types of processing device, one or more of different types of processing device) . The processing device 1102 may include electronic circuitry that process electronic data from data storage elements (e.g., registers, memory, resistors, capacitors, quantum bit cells) to transform that electronic data into other electronic data that may be stored in registers and / or memory. Examples of processing device 1102 may include a CPU, a graphical processing unit (GPU) , a quantum processor, a machine learning processor, an artificial intelligence processor, a neural network processor, an artificial intelligence accelerator, an application-specific integrated circuit (ASIC) , an analog signal processor, an analog computer, a microprocessor, a digital signal processor, a field programmable gate array (FPGA) , a tensor processing unit (TPU) , a neural network hardware accelerator, a DNN accelerator (e.g., DNN accelerator 302 as illustrated in FIGS. 3, and 5-6) , etc.
[0153] The computing device 1100 may include a memory 1104, which may itself include one or more memory devices such as volatile memory (e.g., DRAM) , nonvolatile memory (e.g., read-only memory (ROM) ) , high bandwidth memory (HBM) , flash memory, solid state memory, and / or a hard drive. Memory 1104 includes one or more non-transitory computer-readable storage media. In some embodiments, memory 1104 may include memory that shares a die with the processing device 1102.
[0154] In some embodiments, memory 1104 includes one or more non-transitory computer-readable media storing instructions executable to perform operations described with the FIGS. and herein, such as the methods and operations illustrated in FIGS. 3-7 and 9-10. In some embodiments, memory 1104 includes one or more non-transitory computer-readable media storing instructions executable to perform operations of method 900 of FIG. 9 and method 1000 OF FIG. 10. Exemplary parts that may be encoded as instructions and stored in memory 1104 are depicted. Memory 1104 may store instructions that encode one or more exemplary parts, such as DNN module 301, one or more parts of DNN module 301, and / or compiler 450. The instructions stored in the one or more non-transitory computer-readable media may be executed by processing device 1102.
[0155] In some embodiments, memory 1104 may store data, e.g., data structures, binary data, bits, metadata, files, blobs, etc., as described with the FIGS. and herein. Exemplary data that may be stored in memory 1104 are depicted.
[0156] In some embodiments, memory 1104 may store one or more DNNs (and or parts thereof) . Memory 1104 may store training data for training (trained) a DNN. Memory 1104 may store instructions that perform operations associated with training a DNN. Memory 1104 may store input data, output data, intermediate outputs, intermediate inputs of one or more DNNs. Memory 1104 may store one or more parameters used by the one or more DNNs. Memory 1104 may store information that encodes how nodes of the one or more DNNs are connected with each other. Memory 1104 may store instructions to perform one or more operations of the one or more DNNs. Memory 1104 may store a model definition that specifies one or more operations of a DNN. Memory 1104 may store instructions, such as configuration descriptors, that are generated by a compiler based on the model definition.
[0157] In some embodiments, the computing device 1100 may include a communication device 1112 (e.g., one or more communication devices) . For example, the communication device 1112 may be configured for managing wired and / or wireless communications for the transfer of data to and from the computing device 1100. The term "wireless" and its derivatives may be used to describe circuits, devices, systems, methods, techniques, communications channels, etc., that may communicate data through the use of modulated electromagnetic radiation through a nonsolid medium. The term does not imply that the associated devices do not contain any wires, although in some embodiments they might not. The communication device 1112 may implement any of a number of wireless standards or protocols, including but not limited to Institute for Electrical and Electronic Engineers (IEEE) standards including Wi-Fi (IEEE 802.10 family) , IEEE 802.16 standards (e.g., IEEE 802.16-2005 Amendment) , Long-Term Evolution (LTE) project along with any amendments, updates, and / or revisions (e.g., advanced LTE project, ultramobile broadband (UMB) project (also referred to as "3GPP2" ) , etc. ) . IEEE 802.16 compatible Broadband Wireless Access (BWA) networks are generally referred to as WiMAX networks, an acronym that stands for worldwide interoperability for microwave access, which is a certification mark for products that pass conformity and interoperability tests for the IEEE 802.16 standards. The communication device 1112 may operate in accordance with a Global System for Mobile Communication (GSM) , General Packet Radio Service (GPRS) , Universal Mobile Telecommunications System (UMTS) , High Speed Packet Access (HSPA) , Evolved HSPA (E-HSPA) , or LTE network. The communication device 1112 may operate in accordance with Enhanced Data for GSM Evolution (EDGE) , GSM EDGE Radio Access Network (GERAN) , Universal Terrestrial Radio Access Network (UTRAN) , or Evolved UTRAN (E-UTRAN) . The communication device 1112 may operate in accordance with Code-division Multiple Access (CDMA) , Time Division Multiple Access (TDMA) , Digital Enhanced Cordless Telecommunications (DECT) , Evolution-Data Optimized (EV-DO) , and derivatives thereof, as well as any other wireless protocols that are designated as 3G, 4G, 5G, and beyond. The communication device 1112 may operate in accordance with other wireless protocols in other embodiments. The computing device 1100 may include an antenna 1122 to facilitate wireless communications and / or to receive other wireless communications (such as radio frequency transmissions) . The computing device 1100 may include receiver circuits and / or transmitter circuits. In some embodiments, the communication device 1112 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication device 1112 may include multiple communication chips. For instance, a first communication device 1112 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication device 1112 may be dedicated to longer-range wireless communications such as global positioning system (GPS) , EDGE, GPRS, CDMA, WiMAX, LTE, EV-DO, or others. In some embodiments, a first communication device 1112 may be dedicated to wireless communications, and a second communication device 1112 may be dedicated to wired communications.
[0158] The computing device 1100 may include power source / power circuitry 1114. The power source / power circuitry 1114 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 1100 to an energy source separate from the computing device 1100 (e.g., DC power, AC power, etc. ) .
[0159] The computing device 1100 may include a display device 1106 (or corresponding interface circuitry, as discussed above) . The display device 1106 may include any visual indicators, such as a heads-up display, a computer monitor, a projector, a touchscreen display, a liquid crystal display (LCD) , a light-emitting diode display, or a flat panel display, for example.
[0160] The computing device 1100 may include an audio output device 1108 (or corresponding interface circuitry, as discussed above) . The audio output device 1108 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.
[0161] The computing device 1100 may include an audio input device 1118 (or corresponding interface circuitry, as discussed above) . The audio input device 1118 may include any device that generates a signal representative of a sound, such as microphones, microphone arrays, or digital instruments (e.g., instruments having a musical instrument digital interface (MIDI) output) .
[0162] The computing device 1100 may include a GPS device 1116 (or corresponding interface circuitry, as discussed above) . The GPS device 1116 may be in communication with a satellite-based system and may receive a location of the computing device 1100, as known in the art.
[0163] The computing device 1100 may include a sensor 1130 (or one or more sensors) . The computing device 1100 may include corresponding interface circuitry, as discussed above) . Sensor 1130 may sense physical phenomenon and translate the physical phenomenon into electrical signals that can be processed by, e.g., processing device 1102. Examples of sensor 1130 may include: capacitive sensor, inductive sensor, resistive sensor, electromagnetic field sensor, light sensor, camera, imager, microphone, pressure sensor, temperature sensor, vibrational sensor, accelerometer, gyroscope, strain sensor, moisture sensor, humidity sensor, distance sensor, range sensor, time-of-flight sensor, pH sensor, particle sensor, air quality sensor, chemical sensor, gas sensor, biosensor, ultrasound sensor, a scanner, etc.
[0164] The computing device 1100 may include another output device 1110 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 1110 may include an audio codec, a video codec, a printer, a wired or wireless transmitter for providing information to other devices, haptic output device, gas output device, vibrational output device, lighting output device, home automation controller, or an additional storage device.
[0165] The computing device 1100 may include another input device 1120 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 1120 may include an accelerometer, a gyroscope, a compass, an image capture device, a keyboard, a cursor control device such as a mouse, a stylus, a touchpad, a bar code reader, a Quick Response (QR) code reader, any sensor, or a radio frequency identification (RFID) reader.
[0166] The computing device 1100 may have any desired form factor, such as a handheld or mobile computer system (e.g., a cell phone, a smart phone, a mobile internet device, a music player, a tablet computer, a laptop computer, a netbook computer, a personal digital assistant (PDA) , a personal computer, a remote control, wearable device, headgear, eyewear, footwear, electronic clothing, etc. ) , a desktop computer system, a server or other networked computing component, a printer, a scanner, a monitor, a set-top box, an entertainment control unit, a vehicle control unit, a digital camera, a digital video recorder, an Internet-of-Things device, or a wearable computer system. In some embodiments, the computing device 1100 may be any other electronic device that processes data.
[0167] Select examples
[0168] Example 1 provides a method for executing a neural network (on a neural network hardware accelerator having one or more data processing units) , including determining a processing graph based on a neural network model definition specifying one or more layers of the neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units and optionally an order of execution of the neural network operations; determining whether an output of an activation function is an input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determining one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; providing, to a data processing unit, a configuration descriptor having the one or more look up table values; and loading the one or more look up table values onto a programmable look up table of the data processing unit.
[0169] Example 2 provides the method of example 1, where determining the one or more look up table values that approximate the composite function includes determining one or more parameters of a linear segment, where the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.
[0170] Example 3 provides the method of example 1 or 2, further including determining whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determining one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function; providing, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values; and loading the one or more further look up table values and the one or more yet further look up table values onto a further programmable look up table of the further data processing unit.
[0171] Example 4 provides the method of example 3, where the further configuration descriptor specifies one or more of: an address range for the activation function, and a further address range for the further activation function.
[0172] Example 5 provides the method of example 3 or 4, where determining the one or more further look up table values that approximate the activation function includes determining one or more further parameters of a further linear segment, where the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.
[0173] Example 6 provides the method of any one of examples 3-5, where determining the one or more yet further look up table values that approximate the further activation function includes determining one or more yet further parameters of a yet further linear segment, where the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.
[0174] Example 7 provides the method of any one of examples 1-6, where the activation function is a clamping function and the further activation function is an exponential function.
[0175] Example 8 provides the method of any one of examples 1-6, where the activation function is a sigmoid function and the further activation function is a power function.
[0176] Example 9 provides the method of any one of examples 1-6, where the activation function is a sigmoid function and the further activation function is a square root function.
[0177] Example 10 provides the method of any one of examples 1-6, where the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.
[0178] Example 11 provides a method for executing a neural network (on a neural network hardware accelerator having one or more data processing units) , including determining a processing graph based on a neural network model definition specifying one or more layers of the neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units and optionally an order of execution of the neural network operations; determining whether an output of a node in the processing graph is an input of an activation function and is an input of a further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determining one or more look up table values that approximate the activation function and one or more further look up table values that approximate the further activation function; providing, to a data processing unit, a configuration descriptor having the one or more look up table values and the one or more further look up table values; and loading the one or more look up table values and the one or more further look up table values onto a programmable look up table of the data processing unit.
[0179] Example 12 provides the method of example 11, further including determining whether an output of an activation function is the input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determining one or more yet further look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; providing, to a further data processing unit, a configuration descriptor having the one or more yet further look up table values; and loading the one or more yet further look up table values onto a further programmable look up table of the further data processing unit.
[0180] Example 13 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to: determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units (of a neural network hardware accelerator) and optionally an order of execution of the neural network operations; determine whether an output of an activation function is an input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determine one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; provide, to a data processing unit, a configuration descriptor having the one or more look up table values; and cause the one or more look up table values to be loaded onto a programmable look up table of the data processing unit.
[0181] Example 14 provides the one or more non-transitory computer-readable media of example 13, where determining the one or more look up table values that approximate the composite function includes determining one or more parameters of a linear segment, where the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.
[0182] Example 15 provides the one or more non-transitory computer-readable media of example 13 or 14, where the instructions further cause the one or more processors to: determine whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function; provide, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values; and cause the one or more further look up table values and the one or more yet further look up tables to be loaded onto a further programmable look up table of the further data processing unit.
[0183] Example 16 provides the one or more non-transitory computer-readable media of example 15, where the further configuration descriptor specifies one or more of: an address range for the activation function, and a further address range for the further activation function.
[0184] Example 17 provides the one or more non-transitory computer-readable media of example 15 or 16, where determining the one or more further look up table values that approximate the activation function includes determining one or more further parameters of a further linear segment, where the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.
[0185] Example 18 provides the one or more non-transitory computer-readable media of any one of examples 15-17, where determining the one or more yet further look up table values that approximate the further activation function includes determining one or more yet further parameters of a yet further linear segment, where the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.
[0186] Example 19 provides the one or more non-transitory computer-readable media of any one of examples 13-18, where the activation function is a clamping function and the further activation function is an exponential function.
[0187] Example 20 provides the one or more non-transitory computer-readable media of any one of examples 13-18, where the activation function is a sigmoid function and the further activation function is a power function.
[0188] Example 21 provides the one or more non-transitory computer-readable media of any one of examples 13-18, where the activation function is a sigmoid function and the further activation function is a square root function.
[0189] Example 22 provides the one or more non-transitory computer-readable media of any one of examples 13-18, where the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.
[0190] Example 23 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to: determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units (of a neural network hardware accelerator) and optionally an order of execution of the neural network operations; determine whether an output of a node in the processing graph is an input of an activation function and is an input of a further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more look up table values that approximate the activation function and one or more further look up table values that approximate the further activation function; provide, to a data processing unit, a configuration descriptor having the one or more look up table values and the one or more further look up table values; and cause the one or more look up table values and the one or more further look up tables to be loaded onto a programmable look up table of the data processing unit.
[0191] Example 24 provides the one or more non-transitory computer-readable media of example 23, where the instructions further cause the one or more processors to: determine whether an output of an activation function is the input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determine one or more yet further look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; provide, to a further data processing unit, a configuration descriptor having the one or more yet further look up table values; and cause the one or more yet further look up table values to be loaded onto a further programmable look up table of the further data processing unit.
[0192] Example 25 provides an apparatus, including one or more processors; and one or more non-transitory computer-readable memories to store instructions, where the instructions, when executed by the one or more processors, cause the one or more processors to: determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units (of a neural network hardware accelerator) and optionally an order of execution of the neural network operations; determine whether an output of an activation function is an input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determine one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; and provide, to a data processing unit, a configuration descriptor having the one or more look up table values, where the one or more look up table values are to be loaded onto a programmable look up table of the data processing unit.
[0193] Example 26 provides the apparatus of example 25, where determining the one or more look up table values that approximate the composite function includes determining one or more parameters of a linear segment, where the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.
[0194] Example 27 provides the apparatus of example 25 or 26, where the instructions further cause the one or more processors to: determine whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function; and provide, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values, where the one or more further look up table values and the one or more yet further look up table values are to be loaded onto a further programmable look up table of the further data processing unit.
[0195] Example 28 provides the apparatus of example 27, where the further configuration descriptor specifies one or more of: an address range for the activation function, and a further address range for the further activation function.
[0196] Example 29 provides the apparatus of example 27 or 28, where determining the one or more further look up table values that approximate the activation function includes determining one or more further parameters of a further linear segment, where the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.
[0197] Example 30 provides the apparatus of any one of examples 27-29, where determining the one or more yet further look up table values that approximate the further activation function includes determining one or more yet further parameters of a yet further linear segment, where the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.
[0198] Example 31 provides the apparatus of any one of examples 25-30, where the activation function is a clamping function and the further activation function is an exponential function.
[0199] Example 32 provides the apparatus of any one of examples 25-30, where the activation function is a sigmoid function and the further activation function is a power function.
[0200] Example 33 provides the apparatus of any one of examples 25-30, where the activation function is a sigmoid function and the further activation function is a square root function.
[0201] Example 34 provides the apparatus of any one of examples 25-30, where the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.
[0202] Example 35 provides an apparatus, including one or more processors; and one or more non-transitory computer-readable memories to store instructions, where the instructions, when executed by the one or more processors, cause the one or more processors to: determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units (of a neural network hardware accelerator) and optionally an order of execution of the neural network operations; determine whether an output of a node in the processing graph is an input of an activation function and is an input of a further activation function according to the processing graph; in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more look up table values that approximate the activation function and one or more further look up table values that approximate the further activation function; and provide, to a data processing unit, a configuration descriptor having the one or more look up table values and the one or more further look up table values, where the one or more look up table values and the one or more further look up table values are to be loaded onto a programmable look up table of the data processing unit.
[0203] Example 36 provides the apparatus of example 35, where the instructions further cause the one or more processors to: determine whether an output of an activation function is the input of a further activation function according to the processing graph; in response to determining that the output of the activation function is the input of the further activation function, determine one or more yet further look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; and provide, to a further data processing unit, a configuration descriptor having the one or more yet further look up table values, where the one or more yet further look up table values are to be loaded onto a further programmable look up table of the further data processing unit.
[0204] Example A is an apparatus comprising means for carrying out any one of the methods according to examples 1-12.
[0205] Example B includes a DNN module as described and illustrated herein.
[0206] Example C includes a DNN module to carry out any one of the methods according to examples 1-12.
[0207] Example D includes a compiler as described and illustrated herein.
[0208] Example E includes a compiler to carry out any one of the methods according to examples 1-12.
[0209] Example F includes a DNN accelerator as described and illustrated herein.
[0210] Example G includes one or more data processing units as described and illustrated herein.
[0211] Example H includes one or more post-processing engines as described and illustrated herein.
[0212] Example I includes a DNN system comprising a DNN module according to example B or C and a DNN accelerator according to example F.
[0213] Variations and other notes
[0214] Although the operations of the example method shown in and described with reference to FIGS. 9-10 are illustrated as occurring once each and in a particular order, it will be recognized that the operations may be performed in any suitable order and repeated as desired. Additionally, one or more operations may be performed in parallel. Furthermore, the operations illustrated in FIGS. 9-10 may be combined or may include more or fewer details than described.
[0215] The various implementations described herein may refer to artificial intelligence, machine learning, and deep learning. Deep learning may be a subset of machine learning. Machine learning may be a subset of artificial intelligence. In cases where a deep learning model is mentioned, if suitable for a particular application, a machine learning model may be used instead. In cases where a deep learning model is mentioned, if suitable for a particular application, a digital signal processing system may be used instead.
[0216] The above description of illustrated implementations of the disclosure, including what is described in the Abstract, is not intended to be exhaustive or to limit the disclosure to the precise forms disclosed. While specific implementations of, and examples for, the disclosure are described herein for illustrative purposes, various equivalent modifications are possible within the scope of the disclosure, as those skilled in the relevant art will recognize. These modifications may be made to the disclosure in light of the above detailed description.
[0217] For purposes of explanation, specific numbers, materials and configurations are set forth in order to provide a thorough understanding of the illustrative implementations. However, it will be apparent to one skilled in the art that the present disclosure may be practiced without the specific details and / or that the present disclosure may be practiced with only some of the described aspects. In other instances, well known features are omitted or simplified in order not to obscure the illustrative implementations.
[0218] Further, references are made to the accompanying drawings that form a part hereof, and in which are shown, by way of illustration, embodiments that may be practiced. It is to be understood that other embodiments may be utilized, and structural or logical changes may be made without departing from the scope of the present disclosure. Therefore, the following detailed description is not to be taken in a limiting sense.
[0219] Various operations may be described as multiple discrete actions or operations in turn, in a manner that is most helpful in understanding the disclosed subject matter. However, the order of description should not be construed as to imply that these operations are necessarily order dependent. In particular, these operations may not be performed in the order of presentation. Operations described may be performed in a different order from the described embodiment. Various additional operations may be performed or described operations may be omitted in additional embodiments.
[0220] For the purposes of the present disclosure, the phrase “A or B” or the phrase "A and / or B" means (A) , (B) , or (A and B) . For the purposes of the present disclosure, the phrase “A, B, or C” or the phrase "A, B, and / or C" means (A) , (B) , (C) , (A and B) , (A and C) , (B and C) , or (A, B, and C) . The term "between, " when used with reference to measurement ranges, is inclusive of the ends of the measurement ranges.
[0221] The description uses the phrases "in an embodiment" or "in embodiments, " which may each refer to one or more of the same or different embodiments. The terms "comprising, " "including, " "having, " and the like, as used with respect to embodiments of the present disclosure, are synonymous. The disclosure may use perspective-based descriptions such as "above, " "below, " "top, " "bottom, " and "side" to explain various features of the drawings, but these terms are simply for ease of discussion, and do not imply a desired or required orientation. The accompanying drawings are not necessarily drawn to scale. Unless otherwise specified, the use of the ordinal adjectives “first, ” “second, ” and “third, ” etc., to describe a common object, merely indicates that different instances of like objects are being referred to and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking or in any other manner.
[0222] In the following detailed description, various aspects of the illustrative implementations will be described using terms commonly employed by those skilled in the art to convey the substance of their work to others skilled in the art.
[0223] The terms “substantially, ” “close, ” “approximately, ” “near, ” and “about, ” generally refer to being within + / -20%of a target value as described herein or as known in the art. Similarly, terms indicating orientation of various elements, e.g., “coplanar, ” “perpendicular, ” “orthogonal, ” “parallel, ” or any other angle between the elements, generally refer to being within + / -5-20%of a target value as described herein or as known in the art.
[0224] In addition, the terms “comprise, ” “comprising, ” “include, ” “including, ” “have, ” “having” or any other variation thereof, are intended to cover a non-exclusive inclusion. For example, a method, process, or device, that comprises a list of elements is not necessarily limited to only those elements but may include other elements not expressly listed or inherent to such method, process, or device. Also, the term “or” refers to an inclusive “or” and not to an exclusive “or. ”
[0225] The systems, methods and devices of this disclosure each have several innovative aspects, no single one of which is solely responsible for all desirable attributes disclosed herein. Details of one or more implementations of the subject matter described in this specification are set forth in the description and the accompanying drawings.
Claims
1.A method for executing a neural network, comprising:determining a processing graph based on a neural network model definition specifying one or more layers of the neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units;determining whether an output of an activation function is an input of a further activation function according to the processing graph;in response to determining that the output of the activation function is the input of the further activation function, determining one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function;providing, to a data processing unit, a configuration descriptor having the one or more look up table values; andloading the one or more look up table values onto a programmable look up table of the data processing unit.2.The method of claim 1, wherein determining the one or more look up table values that approximate the composite function comprises:determining one or more parameters of a linear segment, wherein the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.3.The method of claim 1, further comprising:determining whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph;in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determining one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function;providing, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values; andloading the one or more further look up table values and the one or more yet further look up table values onto a further programmable look up table of the further data processing unit.4.The method of claim 3, wherein determining the one or more further look up table values that approximate the activation function comprises:determining one or more further parameters of a further linear segment, wherein the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.5.The method of claim 3, wherein determining the one or more yet further look up table values that approximate the further activation function comprises:determining one or more yet further parameters of a yet further linear segment, wherein the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.6.The method of claim 1, wherein the activation function is a clamping function and the further activation function is an exponential function.7.The method of claim 1, wherein the activation function is a sigmoid function and the further activation function is a power function.8.The method of claim 1, wherein the activation function is a sigmoid function and the further activation function is a square root function.9.One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to:determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units;determine whether an output of an activation function is an input of a further activation function according to the processing graph;in response to determining that the output of the activation function is the input of the further activation function, determine one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function;provide, to a data processing unit, a configuration descriptor having the one or more look up table values; andcause the one or more look up table values to be loaded onto a programmable look up table of the data processing unit.10.The one or more non-transitory computer-readable media of claim 9, wherein determining the one or more look up table values that approximate the composite function comprises:determining one or more parameters of a linear segment, wherein the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.11.The one or more non-transitory computer-readable media of claim 9, wherein the instructions further cause the one or more processors to:determine whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph;in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function;provide, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values; andcause the one or more further look up table values and the one or more yet further look up tables to be loaded onto a further programmable look up table of the further data processing unit.12.The one or more non-transitory computer-readable media of claim 11, wherein the further configuration descriptor specifies one or more of: an address range for the activation function, and a further address range for the further activation function.13.The one or more non-transitory computer-readable media of claim 11, wherein determining the one or more further look up table values that approximate the activation function comprises:determining one or more further parameters of a further linear segment, wherein the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.14.The one or more non-transitory computer-readable media of claim 11, wherein determining the one or more yet further look up table values that approximate the further activation function comprises:determining one or more yet further parameters of a yet further linear segment, wherein the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.15.The one or more non-transitory computer-readable media of claim 11, wherein the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.16.An apparatus, comprising:one or more processors; andone or more non-transitory computer-readable memories to store instructions, wherein the instructions, when executed by the one or more processors, cause the one or more processors to:determine a processing graph based on a neural network model definition specifying one or more layers of a neural network, the processing graph having connected nodes representing neural network operations to be executed by one or more data processing units;determine whether an output of an activation function is an input of a further activation function according to the processing graph;in response to determining that the output of the activation function is the input of the further activation function, determine one or more look up table values that approximate a composite function, the composite function combining the activation function and the further activation function; andprovide, to a data processing unit, a configuration descriptor having the one or more look up table values, wherein the one or more look up table values are to be loaded onto a programmable look up table of the data processing unit.17.The apparatus of claim 16, wherein determining the one or more look up table values that approximate the composite function comprises:determining one or more parameters of a linear segment, wherein the linear segment approximates a portion of the composite function, and the portion of the composite function corresponds to an input range of the composite function.18.The apparatus of claim 16, wherein the instructions further cause the one or more processors to:determine whether an output of a node in the processing graph is an input of the activation function and is the input of the further activation function according to the processing graph;in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determine one or more further look up table values that approximate the activation function and one or more yet further look up table values that approximate the further activation function; andprovide, to a further data processing unit, a further configuration descriptor having the one or more further look up table values and the one or more yet further look up table values, wherein the one or more further look up table values and the one or more yet further look up table values are to be loaded onto a further programmable look up table of the further data processing unit.19.The apparatus of claim 18, wherein determining the one or more further look up table values that approximate the activation function comprises:determining one or more further parameters of a further linear segment, wherein the further linear segment approximates a further portion of the activation function, and the further portion of the activation function corresponds to a further input range of the activation function.20.The apparatus of claim 18, wherein determining the one or more yet further look up table values that approximate the further activation function comprises:determining one or more yet further parameters of a yet further linear segment, wherein the yet further linear segment approximates a yet further portion of the further activation function, and the yet further portion of the further activation function corresponds to a yet further input range of the further activation function.21.A method for executing a neural network on a neural network hardware accelerator having one or more data processing units, comprising:determining a processing graph based on a neural network model definition specifying one or more layers of the neural network, the processing graph having connected nodes representing neural network operations to be executed by the one or more data processing units and an order of execution of the neural network operations;determining whether an output of a node in the processing graph is an input of an activation function and is an input of a further activation function according to the processing graph;in response to determining that the output of the node is the input of the activation function and is the input of the further activation function, determining one or more look up table values that approximate the activation function and one or more further look up table values that approximate the further activation function;providing, to a data processing unit, a configuration descriptor having the one or more look up table values and the one or more further look up table values; andloading the one or more look up table values and the one or more further look up tables onto a programmable look up table of the data processing unit.22.The method of claim 21, further comprising:determining whether an output of an activation function is the input of a further activation function according to the processing graph;in response to determining that the output of the activation function is the input of the further activation function, determining one or more yet further look up table values that approximate a composite function, the composite function combining the activation function and the further activation function;providing, to a further data processing unit, a configuration descriptor having the one or more yet further look up table values; andloading the one or more yet further look up table values onto a further programmable look up table of the further data processing unit.23.The method of claim 22, wherein the activation function is a clamping function and the further activation function is an exponential function.24.The method of claim 22, wherein the activation function is a sigmoid function and the further activation function is a power function.25.The method of claim 21, wherein the activation function is a hyperbolic tangent function and the further activation function is a sigmoid function.
Citation Information
Patent Citations
Neural network activation function calculation circuit
CN110610235A
Activation function acceleration processing unit for neural network online learning
CN113935480A
Activation functions for deep neural networks
EP3480742A1
Hardware accelerator method and device
US20220383103A1
Approximating activation function in neural network with look-up table having hybrid architecture
US20240160695A1