Optimized rotary positional embedding on neural network accelerator

By replacing inefficient RoPE operations with convolution operators on DNN accelerators, the compiler enhances the execution efficiency of LLMs, addressing performance bottlenecks and improving user experience.

WO2026157016A1PCT designated stage Publication Date: 2026-07-30INTEL CORP +8
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
INTEL CORP
Filing Date
2025-03-27
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

The implementation of rotational positional embedding (RoPE) on some neural network accelerators is inefficient due to the nature of the algorithm, leading to performance bottlenecks, especially when compared to graphical processing units (GPUs) in performing vector multiplication and vector additions.

Method used

A compiler is enhanced to identify inefficient operations in RoPE and replace them with convolution operators, which can be efficiently executed on DNN accelerators, optimizing the execution of RoPE by generating configuration descriptors for data processing units to perform reshaping, concatenating, and convolution operations.

Benefits of technology

This optimization significantly speeds up the execution of large language models (LLMs) on DNN accelerators, improving user experience and performance by making RoPE execution more efficient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025085216_30072026_PF_FP_ABST
    Figure CN2025085216_30072026_PF_FP_ABST
Patent Text Reader

Abstract

Rotary positional embedding (RoPE) execution on some DNN accelerators can be a bottleneck of performance. To address this issue, inefficient operations in RoPE are identified by a compiler and replaced by convolution operators. Executing RoPE can involve performing a reshaping operation, a concatenating operation, and a convolution operation. These operations can be executed efficiently on DNN accelerators optimized to perform convolutions.
Need to check novelty before this filing date? Find Prior Art

Description

OPTIMIZED ROTARY POSITIONAL EMBEDDING ON NEURAL NETWORK ACCELERATORCross-reference to Related Application (s)

[0001] This application claims priority to and / or receives benefit from International Application No. PCT / CN2025 / 074734, filed on 24 January 2025, titled, OPTIMIZED ROTARY POSITIONAL EMBEDDING ON NEURAL NETWORK ACCELERATOR. The International Application is hereby incorporated by reference in its entirety.Background

[0002] 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

[0003] 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.

[0004] FIG. 1 illustrates a DNN system, according to some embodiments of the disclosure.

[0005] FIG. 2 illustrates a processing engine, according to some embodiments of the disclosure.

[0006] FIG. 3 illustrates a post-processing engine, according to some embodiments of the disclosure.

[0007] FIG. 4 illustrates a DNN module, according to some embodiments of the disclosure.

[0008] FIG. 5 illustrates calculating rotational positional embedding, according to some embodiments of the disclosure.

[0009] FIG. 6 illustrates a half-half form of rotational positional embedding (RoPE) , according to some embodiments of the disclosure.

[0010] FIG. 7 illustrates a processing graph for the half-half form of RoPE, according to some embodiments of the disclosure.

[0011] FIG. 8 illustrates operations to calculate the half-half form of RoPE, according to some embodiments of the disclosure.

[0012] FIG. 9 illustrates a modified half-half form of RoPE, according to some embodiments of the disclosure.

[0013] FIG. 10 illustrates normal convolution, group convolution, and depth-wise convolution, according to some embodiments of the disclosure.

[0014] FIG. 11 illustrates an optimized processing graph for the half-half form of RoPE using depth-wise convolution, according to some embodiments of the disclosure.

[0015] FIG. 12 illustrates efficient operations to calculate the half-half form of RoPE using depth-wise convolution, according to some embodiments of the disclosure.

[0016] FIG. 13 illustrates a compiler, according to some embodiments of the disclosure.

[0017] FIG. 14 depicts a flow diagram illustrating a method for calculating RoPE embeddings, according to some embodiments of the disclosure.

[0018] FIG. 15 depicts a flow diagram illustrating a method for compiling instructions for a neural network hardware accelerator to calculate RoPE embeddings, according to some embodiments of the disclosure.

[0019] FIG. 16 is a block diagram of an exemplary computing device, according to some embodiments of the disclosure.Detailed DescriptionOverview

[0020] 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 (referred to herein as DNN accelerators) with specialized circuitry can perform the operations in an efficient manner.

[0021] 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 (e.g., MatMul) and convolutions, while the PPE following the processing engine may be tasked to apply neural network 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. To configure the DPU to perform a data processing workload, a configuration descriptor can be used and loaded onto the DPU to cause the DPU to perform one or more neural network operations of the data processing workload. The configuration descriptor can include instructions and / or register configurations that would configure the hardware circuitry, including registers, of the data processing pipeline to perform the one or more neural network operations on input data and produce output data. In some contexts, a configuration descriptor may be referred to as a workload descriptor.

[0022] Prior to deployment of a neural network model onto a neural network hardware accelerator, a compiler can receive a neural network definition that includes neural network operations associated with a neural network model. Based on the neural network definition, the compiler can identify one or more data processing workloads to be executed by the DPUs of the neural network hardware accelerator. The compiler can produce a processing graph having the one or more data processing workloads. Based on the one or more data processing workloads, the compiler can produce configuration descriptors that can be used to configure the data processing units of the neural network hardware accelerator to carry out the one or more data processing workloads. Data processing units of a neural network hardware accelerator may be configured to perform neural network operations of the neural network model using configuration descriptors generated by the compiler.

[0023] DNNs have grown, in the era of using DNNs such as transformer-based DNNs to implement large language models (LLMs) , from having millions of parameters to billions of parameters. Larger models have caused 1000X growth in computing demand in just a few years, as the community develop larger models for higher accuracy. LLMs are a type of DNN that has been used for processing and generating data to support a variety of artificial intelligence (AI) tasks. LLMs leverage complex neural networks, typically based on transformer architectures, to capture intricate patterns in language, enabling them to perform tasks such as text completion, question answering, translation, and even creative writing. The scale of these models, often comprising billions of parameters, allows them to exhibit remarkable linguistic capabilities and a degree of general knowledge that was previously unattainable in machine learning systems. Transformer architectures can also be used for other modalities including computer vision and audio.

[0024] As LLMs models grow in size and complexity, managing their positional information effectively can be crucial for maintaining performance across varying sequence lengths. The rotational positional embedding (RoPE) or rotary positional embedding technique represents a breakthrough in how positional information is encoded in transformer architectures. Unlike traditional positional embeddings, RoPE uniquely incorporates position-dependent rotation matrices into the token embedding space, allowing for better extrapolation to sequences longer than those seen during training. Its mathematical elegance lies in how the embedding preserves the relative distances between tokens while being computationally efficient, making it super popular in modern LLMs.

[0025] However, the RoPE implementation on some DNN accelerators is not as efficient as it is intended to due to the nature of the algorithm. Some DNN accelerators are not as efficient as some graphical processing units (GPUs) in performing vector multiplication and vector additions. And sometimes, RoPE execution even becomes a bottleneck of performance for some DNN accelerators.

[0026] To address this issue, inefficient operations in RoPE are identified by a compiler and replaced by convolution operators (e.g., workloads for performing convolution ns) , which can be efficiently executed on some DNN accelerators. Executing RoPE can involve performing a reshaping operation, a concatenating operation, and a convolution operation. These operations can be executed efficiently on DNN accelerators optimized to perform convolutions.

[0027] The compiler is improved to include the ability to identify opportunities to utilize the improved RoPE implementation and generate a data processing graph accordingly. The compiler can generate configuration descriptors based on the data processing graph. When the configuration descriptors are used on a DNN accelerator, the execution of RoPE can be made significantly more efficient. An exemplary method performed by the compiler is illustrated in FIG. 14.

[0028] In some embodiments, a DNN accelerator having one or more data processing units may execute instructions (e.g., workload descriptors or compiled instructions produced by the compiler) to carry out operations to transform a tensor x having a number of elements into a positional tensor y that uses RoPE. The one or more data processing units may be configured by the instructions to obtain an expanded tensor x′ having twice the number of elements. The expanded tensor x′ can be obtained by reshaping the tensor x and concatenating the reshaped tensor with the reshaped tensor. The one or more data processing units may be configured by the instructions to obtain a rotational tensor r, which has the same shape as the expanded tensor x′. The rotational tensor r can include cosines and sines of rotational angles or positional angles. The rotational tensor r corresponds to a mathematical reformulation and rearrangement of a half-half form of RoPE. The one or more data processing units may be configured by the instructions to perform a convolution operation on the expanded tensor x′ using rotational tensor r to obtain one or more rotational positional embeddings. In some embodiments, the convolution operation is a depth-wise convolution operation. In some embodiments, the convolution operation involves performing element-wise multiplication and summing the products along a dimension. The one or more rotational positional embeddings can encode positional information of the tensor x.

[0029] This solution enables the DNN accelerator to drastically speed up the execution of LLM models and improve user experience of running cutting-edge AI models.Implementing DNNs on processors or neural network hardware accelerators

[0030] 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.

[0031] Herein and as understood by one skilled in the art, a tensor is a mathematical object that includes scalars, vectors, and matrices, and even data structures in higher dimensions. At its most basic level, a tensor can be a single number, known as a scalar. When extended to one dimension, a tensor can be vector, which is an array of numbers. Further extending to two dimensions, a tensor can be a matrix, which is a grid of numbers. Beyond these, tensors can exist in multiple dimensions, representing complex data structures that can be manipulated and transformed in various ways by a DNN accelerator. In the context of neural networks, tensors can be used to store multidimensional data. A neural network involves operations on tensors. Examples of operations may include addition, subtraction, multiplication, convolution, reshaping, transposition, slicing and indexing, broadcasting, etc. The operations manipulate and transform tensors to perform neural network tasks such as training and inference.

[0032] FIG. 1 illustrates DNN system 100, according to some embodiments of the disclosure. The whole DNN system 100 or a part of DNN system 100 may be implemented in one or more computing devices, such as the computing device 1600 in FIG. 12. DNN system 100 can generate and execute DNNs, such as transformer-based neural networks, convolutional neural networks, and so on. As shown in FIG. 1, DNN system 100 includes DNN module 101 and DNN accelerator 102. In other embodiments, alternative configurations, different or additional components may be included in DNN system 100. For instance, DNN system 100 may include multiple DNN modules or multiple DNN accelerators. Further, functionality attributed to a component of DNN system 100 may be accomplished by a different component included in DNN system 100 or a different system. In some embodiments, DNN module 101 and DNN accelerator 102 may include or be implemented by different types of processing units. In an example, DNN module 101 may be implemented by one or more central processing units (CPUs) . DNN accelerator 102 may also be referred to as a neural network hardware accelerator, a neural processing unit, AI accelerator, or AI processor. DNN module 101 and DNN accelerator 102 may be implemented in the same chip or as separate chips.

[0033] DNN module 101 facilitates generation and deployment of DNNs. In some embodiments, the DNN module 101 may generate and train DNNs. For instance, the DNN module 101 can define the layered architecture of a DNN. The DNN module 101 can also determine the internal parameters of the DNN through a DNN training process. The DNN module 101 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.

[0034] DNN module 101 may compress DNNs, e.g., during or after training. In some embodiments, DNN module 101 may prune weights in one or more layers of a DNN by changing nonzero valued weight to zeros. DNN module 101 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 101 prunes weight during DNN training, the DNN module 101 may prune weight of a layer to achieve a target sparsity ratio after one or more epochs. DNN module 101 may prevent the pruned weights from changing values during the rest of the training process. Alternatively, DNN module 101 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 101 may prune weights of the layer again after one or more additional epochs.

[0035] DNN module 101 may deploy trained, compressed, or validated DNNs for use in deep learning applications. In some embodiments, DNN module 101 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 101 may facilitate deployment of the DNNs using the DNN accelerator 102. For instance, DNN module 101 may receive data from a device or system coupled with DNN system 100 and input the received data (or data generated by DNN module 101, e.g., based on the received data) into a DNN. In some embodiments, DNN module 101 may control execution processes of trained, compressed, or validated DNNs.

[0036] DNN module 101 may compile instructions executable by DNN accelerator 102 to perform operations of a DNN in accordance with a model definition of the DNN. DNN module 101 may generate instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) that control the operation of the DNN accelerator 102 during the DNN execution. The instructions may correspond to one or more data processing workloads sent from DNN module 101 to DNN accelerator 102, where the one or more data processing workloads are to be executed by DNN accelerator 102. DNN module 101 may function as a compiler for DNNs to be deployed onto and executed by DNN accelerator 102. DNN module 101 may perform compilation of DNNs and generate configuration descriptors and / or low-level machine instructions, based on which the DNNs may be executed. The instructions may be used to configure or control processing cells of processing engine 170 to perform one or more deep neural network operations. The instructions may be used to configure or control post-processing engine 180 to perform one or more operations such as applying an activation function. Certain aspects of the DNN module 101 are described and illustrated in FIGS. 4 and 10.

[0037] DNN module 101 may receive an output of the DNN from the DNN accelerator 102. DNN module 101 may transmit the output of the DNN (or a result of processing the output of the DNN by DNN module 101) to the device or system.

[0038] DNN accelerator 102 executes operations of DNNs, based on instructions (configuration descriptors and / or low-level machine instructions) provided by DNN module 101. For instance, DNN accelerator 102 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.

[0039] As shown in FIG. 1, DNN accelerator 102 includes memory 110, direct memory access (DMA) engine 120, and data processing units 130 (individually referred to as “data processing unit 130” ) . In other embodiments, alternative configurations, different or additional components may be included in DNN accelerator 102. For example, DNN accelerator 102 may include more than one memory 110 or DMA engine 120. As another example, DNN accelerator 102 may include a single data processing unit 130. Further, functionality attributed to a component of DNN accelerator 102 may be accomplished by a different component included in DNN accelerator 102 or by a different system. A component of DNN accelerator 102 may be implemented in hardware, software, firmware, or some combination thereof.

[0040] Memory 110 stores data associated with deep learning operations performed by DNN accelerator 102. Example deep learning operations include convolutions (also referred to as “convolutional operations” ) , layer normalization operations, SoftMax operations, matrix multiplication operations, pooling operations, element-wise operations, activation functions, other types of deep learning operations, or some combination thereof.

[0041] In some embodiments, memory 110 may store data to be used by the data processing units 130 for DNN execution. memory 110 may store weights, such as weights of convolutional layers, which are determined by training DNNs. Memory 110 may further store inputs to DNN layers and / or outputs of DNN layers, such as data generated by the data processing units 130 from performing deep learning operations in DNNs.

[0042] Memory 110 may store instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) executable by DNN accelerator 102, such as instructions executable by data processing unit 130. Memory 110 may be a main memory of DNN accelerator 102. In some embodiments, memory 110 includes one or more dynamic random access memories (DRAMs) . In some embodiments, cache 112 may serve as a cache for memory 110. Cache 112 may include one or more static random access memories (SRAMs) . Cache 112 may offer faster data / memory accesses than memory 110. Cache 112 may store data that is frequently accessed. Capacity of cache 112 is smaller than the capacity of memory 110.

[0043] DMA engine 120 facilitates data transfer between memory 110 and local memories 140 of the data processing units 130. For example, DMA engine 120 can read data from memory 110 and write data into local memory 140 of data processing unit 130. As another example, DMA engine 120 can read data from local memory 140 of data processing unit 130 and write data into memory 110. DMA engine 120 provides a DMA feature that allows data processing unit 130 to initiate data transfer between memory 110 and local memories 140 of the data processing units 130 and to perform other operations while the data transfer is being conducted. In some embodiments, DMA engine 120 may read tensors from memory 110, modify the tensors in a way that is optimized for data processing unit 130 before it writes the tensors into local memories 140 of data processing units 130.

[0044] Data processing units 130 perform deep learning operations in DNNs. For instance, data processing unit 130 may execute a DNN layer by running one or more deep learning operations in the DNN layer. Data processing unit 130 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 130 in parallel. For instance, multiple data processing units 130 may each perform a data processing workload, or a portion of a data processing workload for a deep learning operation. Data may be shared between data processing units 130. Data processing unit 130 may also be referred to as a compute block, or a compute tile.

[0045] Data processing units 130 may be capable of running various types of deep learning operations, such as convolution, layer normalization, SoftMax operation, pooling, element-wise operation, linear operation, non-linear operation, MatMul, and so on. Deep learning operations performed by the data processing units 130 include tensor operations, i.e., operations whose inputs are tensors or operations whose outputs are tensors. In an example, data processing unit 130 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 130 or another data processing unit 130.

[0046] In the embodiments of FIG. 1, each data processing unit 130 includes local memory 140, load module 160, processing engine 170, post-processing engine 180, and output module 190. Data processing unit 130 may include a data processing pipeline that includes load module 160, processing engine 170, post-processing engine 180, and output module 190. Some or all the components of the data processing unit 130 can be implemented on the same chip. In other embodiments, alternative configurations, different or additional components may be included in the data processing unit 130. Further, functionality attributed to a component of data processing unit 130 may be accomplished by a different component included in the data processing unit 130, a different data processing unit 130, another component of the DNN accelerator 102, or a different system. A component of the data processing unit 130 may be implemented in hardware, software, firmware, or some combination thereof.

[0047] Local memory 140 is local to the corresponding data processing unit 130. In the embodiments of FIG. 1, local memory 140 is inside the data processing unit 130. In other embodiments, local memory 140 may be outside the data processing unit 130. Local memory 140 may include one or more SRAMs. The capacity of local memory 140 (e.g., 1.5-2 Megabytes) may be far smaller than the capacity of memory 110. Data in local memory 140 may be transferred to or from memory 110, or cache 112, e.g., through DMA engine 120. In some embodiments, data in local memory 140 may be transferred to or from local memory 140 of another data processing unit 130. Local memory 140 may store data received, used, or generated by load module 160, processing engine 170, post-processing engine 180, or output module 190. Examples of the data may include input activations, weights, output activations, low-level machine instructions, configuration descriptors, and so on.

[0048] In some embodiments, local memory 140 may store tensors to be processed by the processing engine 170 or the post-processing engine 180. The tensors may be input tensors of deep learning operations. Local memory 140 may also store tensors generated by processing engine 170 or post-processing engine 180. The tensors may be output tensors of deep learning operations. The layout of data points of a tensor in local memory 140 may depend on the format in which the tensor is stored. In some embodiments, local memory 140 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 140 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 140. For a tensor with the ZXY format or ZYX format, local memory 140 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 140. For a tensor with X-major format, local memory 140 may store data points having the same (y, z) coordinate contiguously. For a tensor with Y-major format, local memory 140 may store data points having the same (x, z) coordinate contiguously.

[0049] In some embodiments, local memory 140 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.

[0050] In some embodiments, local memory 140 includes one or more SRAMs. Local memory 140 may be byte-addressable, and each memory address identifies a single byte (eight bits) of storage. In some embodiments, local memory 140 may include memory banks. The number of data banks in the local memory 140 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 140 in a single read cycle. In other embodiments, 16 bits can be transferred from local memory 140 in multiple read cycles, such as two cycles.

[0051] Load module 160 loads data from local memory 140 to the processing engine 170 or to post-processing engine 180. Load module 160 may load data from local memory 140 to one or more data buffers of the processing engine 170. Load module 160 may read tensors from the local memory 140. The tensors may include sparse activation tensors, sparse weight tensors, activation sparsity tensors, weight sparsity tensors, and so on. In some embodiments, load module 160 may load data based on a sparsity mode. Load module 160 may select different data to transmit to the processing engine 170 in different sparsity modes.

[0052] Processing engine 170 performs neural network operations of DNNs. An exemplary processing engine 170 is described and illustrated in FIG. 2.

[0053] Post-processing engine 180 processes outputs of processing engine 170. The post-processing engine 180 may include one or more post-processing elements. In some embodiments, the post-processing elements in the post-processing engine 180 may be arranged in an arrangement (e.g., in an array arrangement) that has rows and columns. In some embodiments, post-processing engine 180 computes activation functions. Post-processing engine 180 may receive outputs of processing engine 170 as inputs to the activation functions. In addition or alternative to activation functions, post-processing engine 180 may perform other types of post-processing on outputs of processing engine 170. For instance, post-processing engine 180 may apply a bias on an output of processing engine 170. For instance, post-processing engine 180 may perform scaling on an output of processing engine 170. In some embodiments, post-processing engine 180 may be bypassed for certain neural network operations.

[0054] Output module 190 drains data from processing engine 170 and / or from post-processing engine 180. Output module 190 may write the data to local memory 140. The drained data may be tensors, such as output tensors of neural network operations. In some embodiments, output module 190 may drain data on a cell level of processing engine 170. For each processing cell, output module 190 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 190 may use a sequence of cycles to drain data from a processing cell. Output module 190 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 160. The drained data, e.g., tensors, may be further loaded to memory 110, e.g., through the DMA engine 120. Additionally or alternatively, the drained data may be loaded by the load module 160 to the processing engine 170 for further computation, e.g., for performing a deep learning operation in the next layer.

[0055] FIG. 2 illustrates processing engine 170, according to some embodiments of the disclosure. Processing engine 170 may be included as part of a data processing unit, such as data processing unit 130 of FIG. 1. Processing engine 170 may include one or more processing cells 202. In some embodiments, processing cells 202 may be arranged in one or more rows and / or one or more columns in the processing engine 170. In some embodiments, processing cells 202 may be arranged as one or more sets or arrays of processing cells 202 performing different operations. Processing engine 170 may have one or more arrays of multiply and accumulate circuity (e.g., processing cells 202) optimized to perform compute operations such as MatMul and convolution.

[0056] Each processing cell (e.g., processing cell 202) 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.

[0057] 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.

[0058] Processing engine 170 may include controller 204, which may configure circuitry of one or more processing cells 202 to perform the arithmetic operations. In some cases, controller 204 may configure one or more processing cells 202 (or individual processing elements in a processing cell 202) to perform operations in a particular sequence or manner. In some cases, controller 204 may configure one or more processing cells 202 (or individual processing elements in a processing cell 202) according to instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206. Controller 204 may include a program counter to determine the instructions loaded in instruction buffer 206 to be executed by one or more processing cells 202 (or individual processing elements in a processing cell 202) .

[0059] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal which processing cells 202 (or individual processing elements in a processing cell 202) is to execute or carry out one or more operations. Instruction buffer 206 may include one or more register files, or one or more arrays of memory cells.

[0060] Data may be loaded in data buffers 208 by controller 204 and / or load module 160 of FIG. 1. The data may be used by processing cells 202. Data produced by processing cells 202 may be drained from data buffers 208 by output module 190 to local memory 140 of FIG. 1. Data buffers 208 may include one or more register files, or one or more arrays of memory cells.

[0061] Data buffers 208 may include one or more of: one or more input data buffers, and one or more output data buffers. Data buffers 208 may include one or more weights / parameters buffers. Data buffers 208 may store operands for one or more processing elements of processing cell 202. Data buffers 208 may store generated outputs of one or more processing elements of processing cell 202.

[0062] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal which data stored in data buffers 208 is to be processed by processing cells 202 (or individual processing elements in a processing cell 202) . In some cases, the processing cells 202 (or individual processing elements in a processing cell 202) may read data from data buffers 208 at a default location for the processing cell 202 or an individual processing element in the processing cell 202.

[0063] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal where to store output data in data buffers 208 after processing cells 202 produces the output data. In some cases, the processing cells 202 (or individual processing elements in a processing cell 202) may write data to data buffers 208 at a default location for the processing cell 202 or an individual processing element in the processing cell 202.

[0064] Load module 160 of FIG. 1 may load data to certain locations in data buffers 208. Output module 190 of FIG. 1 may drain data from data buffers 208 to be stored in local memory 140 and / or memory 110 of FIG. 1.

[0065] FIG. 3 illustrates post-processing engine 180, according to some embodiments of the disclosure. As discussed previously with FIG. 1, post-processing engine 180 may process the output (e.g., a tensor) produced by processing engine 170. Some exemplary components in post-processing engine 180 are depicted. In some embodiments, post-processing engine 180 may include bias 302 to add a bias to the output produced by processing engine 170. In some embodiments, post-processing engine 180 may include scale 304 to scale (e.g., multiply by a number) the output produced by processing engine 170. In some embodiments, post-processing engine 180 may include output conversion 360, which may convert the data to different precisions such as integer precision, floating-point precision, etc. Output conversion 360 may convert data between precisions such as INT8, FP16, FP32, etc. Output conversion 360 may perform quantization according to a quantization specified in a configuration descriptor.

[0066] In some embodiments, post-processing engine 180 may include a software programmable look up table (LUT) 388. LUT 388 may be loaded with look up table values provided in a configuration descriptor (e.g., from local memory 140 and / or memory 110) , making LUT 388 software configurable. The look up table values include parameters for approximating a function, such as an activation function.

[0067] In some embodiments, post-processing engine 180 may apply an approximated version (e.g., using linear approximation) of an activation function to the output produced by processing engine 170 using LUT 388. Post-processing engine 180 may include address logic 306, LUT 388, and computation unit 310, 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 180. The look up table values may approximate a function, such as an activation function or another suitable function. Specifically, the look up table values include 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.

[0068] When post-processing engine 180 receives an input data element, address logic 306 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 306 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 310. Computation unit 310 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 310 may perform multiplication and adding to determine the output of the linear function. Specifically, computation unit 310 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 306. The output of the linear function calculated by computation unit 310 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 310 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.

[0069] One or more outputs produced by post-processing engine 180 may be provided to local memory 140 of data processing unit 130 via output module 190 of FIG. 1.

[0070] FIG. 4 illustrates DNN module 101, according to some embodiments of the disclosure. DNN module 101 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 101. Further, functionality attributed to a component of DNN module 101 may be accomplished by a different component included in DNN module 101 or a different module or system.

[0071] Interface module 410 facilitates communications of DNN module 101 with other modules or systems. For example, interface module 410 establishes communications between DNN module 101 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 101 to distribute DNNs to other systems, e.g., computing devices configured to apply DNNs to perform tasks.

[0072] 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.

[0073] 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.

[0074] 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.

[0075] Training module 420 may train the DNN for a pre-determined 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 pre-determined 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.

[0076] 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.

[0077] 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.

[0078] Compiler 450 compiles information associated with DNNs which can be used to cause or configure DNN accelerator 102 of FIG. 1 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., workload descriptors, configuration descriptors, and / or low-level machine instructions) that can be executed by DNN accelerator 102. 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.

[0079] Compiler 450 may pre-process and / or modify the processing graph to identify opportunities to streamline the processing graph to reduce overhead of the compiled configuration descriptors. Due to the specific nature of the data processing pipeline in a DPU, compiler 450 may follow a set of rules or patterns when producing one or more configuration descriptors for one or more nodes of the processing graph. Compiler 450 may traverse through the processing graph to produce configuration descriptors according to the set of rules or patterns. The configuration descriptors can be used and executed by components of the DNN accelerator 102 (e.g., processing engine 170 and post-processing engine 180 of FIG. 1) to execute the DNN. An exemplary compiler 450 is described and illustrated in FIG. 13.

[0080] Datastore 460 stores data received, generated, used, or otherwise associated with the DNN module 101. 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 101. In other embodiments, datastore 460 may be external to DNN module 101 and communicate with the DNN module 101 through a network.

[0081] Referring back to FIGS. 1-4, DNN system 100 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.Executing RoPE on DPUs

[0082] RoPE applies rotation to every element in the input. Rotation is done by multiplying with rotary, rotation, or rotational matrix. Given a point on 2-D space x (x0, x1) , rotate by angle of θ:

[0083] θ is the rotation or rotational angle for a particular position. The rotational matrix can be parameterized by the position and a frequency term. FIG. 5 illustrates calculating RoPE, according to some embodiments of the disclosure. Give a vector of x, the RoPE algorithm first rearranges the vector (e.g., tensor 502) to 2-element groups and multiply every 2-element group with a rotation matrix, as shown in the top part of FIG. 5. An exemplary 2-element group is boxed by dotted line box 510. An exemplary rotation matrix is boxed by dotted line box 512.

[0084] The formulation 520 can be further extended to the calculation shown in the bottom part of FIG. 5. Calculations 530 in the bottom part of FIG. 5 are a slightly more efficient implementation where most zeros multiplications are removed. In practice, this form of RoPE implementing calculations 530 without modification introduces tensor de-interleaving and interleaving to obtain tensor 540, and de-interleaving and interleaving of tensors can be memory inefficient.

[0085] In some LLMs, an optimized variation of RoPE is used, called a half-half form of RoPE. FIG. 6 illustrates a half-half form of RoPE, according to some embodiments of the disclosure. This variation removes the de-interleaving and interleaving as previously seen in FIG. 5. Instead, the half-half-form of RoPE switches the first and second half of the tensor. The variant form is not mathematically equivalent to the original form, but in model training, they can both be effective.

[0086] PyTorch or equivalent can be used to source code an LLM, where the code to apply RoPE can be as follows:

[0087] Graph tracing can be used to get a computational graph or processing graph from the source code. FIG. 7 illustrates a processing graph for the half-half form of RoPE, according to some embodiments of the disclosure. The processing graph can be obtained using graph tracing. The processing graph has operators (e.g., workloads or operations) such as split 702, concatenate (concat) 704, multiply 706, and add 708. These operators, on a DNN accelerator (such as the DNN accelerator illustrated in FIGS. 1-4) may not be as efficient as convolution and MatMul operators.

[0088] FIG. 8 illustrates operations to calculate the half-half form of RoPE, according to some embodiments of the disclosure. Given a tensor x (illustrated by tensor 802) , with a tensor shape [bz, nh, seq, h] , the operations depicted transform the tensor x into rotational positional embeddings shown as tensor y (illustrated by tensor 880) . bz stands for batch size (number of samples processed simultaneously) . nh stands for number of attention heads. Seq stands for sequence length (number of tokens in the input) . h stands for hidden dimension size per head.

[0089] Tensor 802 may be split into two equal halves along axis h, into tensor 804. One half of tensor 804 (half of the elements / values of tensor 804) is depicted as xh with a dimension h / 2. The other half of tensor 804 (the other half of the elements / values of tensor 804) is depicted as xl with a dimension h / 2. Tensor 802 corresponds to tensor 602 in FIG. 6.

[0090] A switching operation is applied to tensor 804 to switch the order of one half xh and the other half xl. A negative one (-1) is multiplied to elements of the other half xl. Tensor 806 is obtained, where one half of tensor 806 is depicted as -xl and the other half of tensor 806 is depicted as xh. Tensor 806 corresponds to tensor 606 in FIG. 6.

[0091] Tensor 802 is element-wise multiplied with tensor 808, which includes cosines of rotational angles (e.g., cosθ) to obtain tensor 812. Tensor 808 corresponds to tensor 604 in FIG. 6, and the element-wise multiplication operation corresponds to  in FIG. 6. One half of tensor 812 is depicted as xh·cos with a dimension h / 2. The other half of tensor 812 is depicted as xl·cos with a dimension h / 2.

[0092] Tensor 806 is element-wise multiplied with tensor 810, which includes sines of rotational angles (e.g., sinθ) to obtain tensor 814. Tensor 806 corresponds to tensor 606 in FIG. 6, and the element-wise multiplication operation corresponds to  in FIG. 6. Tensor 810 corresponds to tensor 608 in FIG. 6. One half of tensor 814 is depicted as -xl·sin with a dimension h / 2. The other half of tensor 814 is depicted as xh·sin with a dimension h / 2.

[0093] Tensor 812 and tensor 814 are added together to obtain tensor 880. Tensor 880 includes results of applying the half-half form of RoPE to tensor 802, which is a transformed tensor that encodes rotational position information through sine and cosine functions. Tensor 880 has rotational positional embeddings.Rethinking RoPE execution on DPUs

[0094] With some manipulation, the calculations illustrated in FIG. 6 can be rewritten. FIG. 9 illustrates a modified half-half form of RoPE, according to some embodiments of the disclosure. In the modified half-half form of RoPE, the items in the second half of the vector are switched. In particular, the terms are swapped for elements 902 in the second half of formulation 910, which yields formulation 912. Formulation 912 can be reformulated to become formulation 920. Formulation 920 represents performing a convolution operation on tensor 950 using tensor 960. The *in formulation 920 means to perform element-wise multiplication and reduce sum along the inner dimension.

[0095] It can be seen that, in this modified half-half form of RoPE (shown as formulation 920) , tensor 950 on the left can be easy to construct, with reshaping and concatenation. Tensor 950 is doubled in size than before. On the right, tensor 960 (e.g., a rotational tensor) having the cosines and sines is doubled in size than before. With this modified half-half form depicted as formulation 920, the following describes how half-half form of RoPE can be executed on DNN accelerators as a convolution type operator (which can be far more efficient than multiply and add operators) .

[0096] FIG. 10 illustrates normal convolution, group convolution, and depth-wise convolution, according to some embodiments of the disclosure. Depth-wise convolution is a special case of convolution, when group=Cin=Cout. group represents group size. Cinrepresents input channel size. Cout represents output channel size. In 1002, normal convolution is illustrated. In 1004 and 1006, group convolutions with different group sizes (e.g., 2 and 3 respectively) are illustrated. In 1008, depth-wise convolution is illustrated.

[0097] In FIG. 10, each “Act” block stands for an input feature map channel; and each “Out” block stands for an output feature map channel; each “Wgt” block stands for a filter kernel. As the group increases until equal to the number of input and output channels, the convolution operation is called a depth-wise convolution, as depicted in 1008, where group=Cin=Cout=6.

[0098] Referring back to the modified half-half formulation 920 in FIG. 9, it is possible to view each pair of x as an input channel, each pair of cosθn and sinθn as a filter kernel. All input channel feature maps and all filter kernels have the same shape. Then, the formula is a depth-wise convolution (as illustrated in 1008 of FIG. 10) , which implements element-wise multiplication of tensor 950 (e.g., the input) and tensor 960 (e.g., the weight) and perform reduce sum along the inner dimension of 2.

[0099] FIG. 11 illustrates an optimized processing graph for the half-half form of RoPE using depth-wise convolution, according to some embodiments of the disclosure. The inefficient operators as seen FIG. 7 (e.g., multiply 706 and add 708) have been removed, and replaced by depth-wise / group convolution 1102.

[0100] FIG. 12 illustrates efficient operations to calculate the half-half form of RoPE using depth-wise convolution, according to some embodiments of the disclosure. Given a tensor x (illustrated by tensor 802) , with a tensor shape [bz, nh, seq, h] , the operations depicted transform the tensor x into rotational positional embeddings shown as tensor y (illustrated by tensor 1206) . Tensor 1206 is mathematically equivalent to tensor 880. bz stands for batch size (number of samples processed simultaneously) . nh stands for number of attention heads. Seq stands for sequence length (number of tokens in the input) . h stands for hidden dimension size per head.

[0101] Tensor 1202 may have a number of elements. Tensor 1202 may be split into two equal halves along axis h to obtain xh and xl. Tensor 1202 may be reshaped to form a half of tensor 1204 (half of the elements / values of tensor 1204) . The reshaped tensor 1220 is depicted as [xh, xl] , and has a dimension h / 2, and the same number of elements as tensor 1202. The reshaped tensor 1220 is concatenated with the reshaped tensor 1220 to form tensor 1204. In other words, a reshape operation and a concatenation operation can be applied to tensor 1202 to form the expanded tensor x′ (represented by tensor 1204) . The expanded tensor has twice the number of elements as tensor 1202.

[0102] One half of tensor 1204 (one half of the elements / values of tensor 1204) is depicted as [xh, xl] and has a dimension h / 2. The other half of tensor 1204 (the other half of the elements / values of tensor 1204) is depicted as [xh, xl] and has a dimension h / 2. Tensor 1204 has a dimension h. Tensor 1204 corresponds to tensor 950 in FIG. 9.

[0103] Rotation tensor 1208 is obtained. Rotation tensor 1208 corresponds to tensor 960 of FIG. 9. Obtaining rotation tensor 1208 may include determining / calculating a positive cosine of a rotation angle (e.g., cosθ) and determining a negative sine of the rotation angle (e.g., sinθ) . Additional positive cosines and negative sines may be calculated for rotation tensor 1208 to obtain the values seen in tensor 960 of FIG. 9. Obtaining rotation tensor 1208 may include performing a gather operation on the positive cosine and the negative sine (and other cosines and other negative sines) to form rotation tensor 1208.

[0104] Rotation tensor 1208 has one or more positive cosines of one or more rotation angles and one or more negative sines of the one or more rotational angles. Rotation tensor 1208 may have a first quarter of elements / values, a second quarter of elements / values, a third quarter of elements / values, and a fourth quarter of elements / values (depicted as, in this order: cos, -sin, -sin, and cos) . The one or more positive cosines form the first quarter of tensor 1208 and the fourth quarter of tensor 1208, or half of the elements of tensor 1208. The one or more negative cosines form the second quarter of tensor 1208 and the third quarter of tensor 1208, or the other half of the elements of tensor 1208. Tensor 1208 as the same shape and same number of elements as tensor 1204.

[0105] A convolution operation, such as depth-wise convolution operation, is performed on or applied to tensor 1204 (the expanded tensor) using tensor 1208 (the rotation tensor) as filter kernels to obtain tensor 1206. Tensor 1206 has one or more rotary positional embeddings, representing a transformed tensor for tensor 1202. Tensor 1206 has a dimension h. The convolution operation corresponds to *operator in formulation 920 in FIG. 9. Performing the convolution involves performing element-wise multiplication of tensor 1204 and tensor 1208 to obtain products and summing the products along a dimension.

[0106] FIG. 13 illustrates compiler 450, according to some embodiments of the disclosure. To take advantage of subgroup optimization of MatMul as discussed herein, compiler 450 may implement operations to identify opportunities to convert RoPE operation into the graph depicted in FIG. 11, so that a DNN accelerator can perform operations depicted in FIG. 12. Compiler 450 includes neural network analyzer 1302, identify RoPE 1304, configuration descriptors generator 1308, and scheduler 1310. Compiler 450 may perform method 1500 of FIG. 15.

[0107] Neural network analyzer 1302 may analyze a DNN and determine how a neural network hardware accelerator can implement the DNN utilizing the DPUs of the accelerator. Neural network analyzer 1302 may receive the neural network model definition of the 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. ) .

[0108] In some cases, neural network analyzer 1302 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. 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, etc. ) , etc. 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. The processing graph may include one or more neural network operations to be executed by one or more DPUs (of the neural network hardware accelerator) .

[0109] Neural network analyzer 1302 may determine one or more data processing workloads to be carried out by the DPUs (of the neural network hardware accelerator) based on the processing graph and / or the neural network model definition. The one or more data processing workloads may correspond to and / or include one or more neural network operations of the processing graph. For example, a data processing workload may include one or more neural network operations to be executed according to one or more configurations. The data processing workload may 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. In some cases, a neural network operation may translate to a data processing workload. In some cases, a neural network operation may translate to multiple data processing workloads. In some cases, one or more neural network operations may translate to one or more data processing workloads. 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. A neural network operation of a data processing workload may be executed by a data processing unit according to one or more configurations for the neural network operation. In some cases, the neural network model definition includes the processing graph.

[0110] As illustrated by FIGS. 9-12 and discussed herein, there are opportunities for rethinking RoPE to allow for half-half form of RoPE to be executed efficiently on DPUs. Identify RoPE 1304 may determine whether the processing graph has a RoPE operation. Identify RoPE 1304 may traverse through the processing graph determined by neural network analyzer 1302 to find a RoPE operation. Identify RoPE 1304 may transform the RoPE operation to have a processing graph illustrated in FIG. 11 (and not use the version illustrated in FIG. 7) .

[0111] Configuration descriptors generator 1308 may generate one or more instructions (e.g., one or more configuration descriptors, one or more workload descriptors, low-level machine instructions) based on the data processing graph.

[0112] Scheduler 1310 may coordinate when and which DPUs should have the configuration descriptors generated by configuration descriptors generator 1308 loaded to execute the data processing workloads. The data processing workloads may be allocated by scheduler 1310 to the DPUs (in a neural network hardware accelerator) , and scheduler 1310 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 1310 may determine a plan that can load balance execution of the data processing workloads. Scheduler 1310 may determine a plan that ensures the data processing workloads are being executed according to the processing graph. Scheduler 1310 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 1310 may be a part of compiler 450. In some cases, scheduler 1310 may be a part of DNN module 101 of FIGS. 1 and 4.

[0113] FIG. 14 depicts a flow diagram illustrating method 1400 for calculating RoPE embeddings, according to some embodiments of the disclosure. Method 1400 may be performed by one or more components in a DNN accelerator. In 1402, an input tensor is received. The input tensor has a number of elements. In 1404, an expanded tensor having twice the number of elements can be obtained from the input tensor. An expanded tensor is illustrated as tensor 950 of FIG. 9 and tensor 1204 of FIG. 12. In 1406, a rotation tensor having a same shape as the expanded tensor can be obtained. A rotation tensor is illustrated as tensor 960 of FIG. 9 and tensor 1208 of FIG. 12. In 1408, one or more rotary positional embeddings are obtained by performing a convolution operation on the expanded tensor using the rotation tensor. The convolution operation is illustrated in 1008 of FIG. 10.

[0114] FIG. 15 depicts a flow diagram illustrating method 1500 for compiling instructions for a neural network hardware accelerator to calculate RoPE embeddings, according to some embodiments of the disclosure. Method 1500 can be performed by one or more components of a compiler for a DNN accelerator. In 1502, a processing graph having a rotation operation on a tensor is received. In 1504, an instruction to a neural network hardware accelerator is generated. The instruction may instruct the neural network hardware accelerator to concatenate a reshaped tensor with the reshaped tensor to obtain an expanded tensor. The reshaped tensor can be obtained from the tensor to which rotational positional embedding technique is to be applied. In 1506, a further instruction to the neural network hardware accelerator may be generated. The further instruction may instruct the neural network hardware accelerator to gather values to form a rotation tensor. In 1508, a yet further instruction to the neural network hardware accelerator may be generated. The yet further instruction may instruct the neural network hardware accelerator to perform convolution on the expanded tensor using the rotation tensor.Test case results

[0115] In one experiment where half-half form of RoPE is implemented with and without the optimization discussed herein, the performance (e.g., execution duration) is optimized from 12us to 0.54us, which is about 20x improvement.Exemplary computing device

[0116] FIG. 16 is a block diagram of an apparatus or a system, e.g., an exemplary computing device 1600, according to some embodiments of the disclosure. One or more computing devices 1600 may be used to implement the functionalities described with the FIGS. and herein. A number of components illustrated in FIG. 16 can be included in the computing device 1600, 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 1600 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 1600 may not include one or more of the components illustrated in FIG. 16, and the computing device 1600 may include interface circuitry for coupling to the one or more components. For example, the computing device 1600 may not include a display device 1606, and may include display device interface circuitry (e.g., a connector and driver circuitry) to which a display device 1606 may be coupled. In another set of examples, the computing device 1600 may not include an audio input device 1618 or an audio output device 1608 and may include audio input or output device interface circuitry (e.g., connectors and supporting circuitry) to which an audio input device 1618 or audio output device 1608 may be coupled.

[0117] The computing device 1600 may include a processing device 1602 (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 1602 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 1602 may include a CPU, a 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 102 as illustrated in FIG. 1-3) , etc.

[0118] The computing device 1600 may include a memory 1604, 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 1604 includes one or more non-transitory computer-readable storage media. In some embodiments, memory 1604 may include memory that shares a die with the processing device 1602.

[0119] In some embodiments, memory 1604 includes one or more non-transitory computer-readable media storing instructions executable to perform operations described with the FIGS. and herein. Exemplary parts, e.g., DNN module 101 and compiler 450, that may be encoded as instructions and stored in memory 1604 are depicted. Memory 1604 may store instructions that encode one or more exemplary parts, such as DNN module 101, one or more parts of DNN module 101, compiler 450, and / or one or more parts of compiler 450. The instructions stored in the one or more non-transitory computer-readable media may be executed by processing device 1602. Memory 1604 may store instructions that causes processing device 1602 to perform method 1400. Memory 1604 may store instructions that causes processing device 1602 to perform method 1500.

[0120] In some embodiments, memory 1604 may store data, e.g., data structures, binary data, bits, metadata, files, blobs, etc., as described with the FIGS. and herein. Memory 1604 may store compiled configuration descriptors described herein, e.g., constant configuration descriptors and variable configuration descriptors. Memory 1604 may store a neural network definition. Memory 1604 may store a processing graph. Memory 1604 may store data processing workloads that can implement the processing graph. Memory 1604 may store the dictionary that groups data processing workloads that share a common operation.

[0121] In some embodiments, memory 1604 may store one or more DNNs (and or parts thereof) . Memory 1604 may store training data for training (trained) a DNN. Memory 1604 may store instructions that perform operations associated with training a DNN. Memory 1604 may store input data, output data, intermediate outputs, intermediate inputs of one or more DNNs. Memory 1604 may store one or more parameters used by the one or more DNNs. Memory 1604 may store information that encodes how nodes of the one or more DNNs are connected with each other. Memory 1604 may store instructions to perform one or more operations of the one or more DNNs. Memory 1604 may store a model definition that specifies one or more operations of a DNN. Memory 1604 may store instructions, such as configuration descriptors, that are generated by a compiler based on the model definition.

[0122] In some embodiments, the computing device 1600 may include a communication device 1612 (e.g., one or more communication devices) . For example, the communication device 1612 may be configured for managing wired and / or wireless communications for the transfer of data to and from the computing device 1600. 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 1612 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 1612 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 1612 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 1612 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 1612 may operate in accordance with other wireless protocols in other embodiments. The computing device 1600 may include an antenna 1622 to facilitate wireless communications and / or to receive other wireless communications (such as radio frequency transmissions) . The computing device 1600 may include receiver circuits and / or transmitter circuits. In some embodiments, the communication device 1612 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication device 1612 may include multiple communication chips. For instance, a first communication device 1612 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication device 1612 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 1612 may be dedicated to wireless communications, and a second communication device 1612 may be dedicated to wired communications.

[0123] The computing device 1600 may include power source  / power circuitry 1614. The power source  / power circuitry 1614 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 1600 to an energy source separate from the computing device 1600 (e.g., DC power, AC power, etc. ) .

[0124] The computing device 1600 may include a display device 1606 (or corresponding interface circuitry, as discussed above) . The display device 1606 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.

[0125] The computing device 1600 may include an audio output device 1608 (or corresponding interface circuitry, as discussed above) . The audio output device 1608 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.

[0126] The computing device 1600 may include an audio input device 1618 (or corresponding interface circuitry, as discussed above) . The audio input device 1618 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) .

[0127] The computing device 1600 may include a GPS device 1616 (or corresponding interface circuitry, as discussed above) . The GPS device 1616 may be in communication with a satellite-based system and may receive a location of the computing device 1600, as known in the art.

[0128] The computing device 1600 may include a sensor 1630 (or one or more sensors) . The computing device 1600 may include corresponding interface circuitry, as discussed above) . Sensor 1630 may sense physical phenomenon and translate the physical phenomenon into electrical signals that can be processed by, e.g., processing device 1602. Examples of sensor 1630 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.

[0129] The computing device 1600 may include another output device 1610 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 1610 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.

[0130] The computing device 1600 may include another input device 1620 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 1620 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.

[0131] The computing device 1600 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 1600 may be any other electronic device that processes data.Select examples

[0132] Example 1 provides an apparatus, including one or more data processing units; and one or more non-transitory computer-readable memories to store instructions, where the instructions, when executed by the one or more data processing units, cause the one or more data processing units to: receive an input tensor having a number of elements; obtain an expanded tensor from the input tensor, the expanded tensor having twice the number of elements; obtain a rotation tensor having a same shape as the expanded tensor; and obtain one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor.

[0133] Example 2 provides the apparatus of example 1, where obtaining the expanded tensor includes reshaping the input tensor to obtain a reshaped tensor; and concatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.

[0134] Example 3 provides the apparatus of example 1 or 2, where obtaining the rotation tensor includes determining a positive cosine of a rotation angle; determining a negative sine of the rotation angle; and perform a gather operation on the positive cosine and the negative sine to form the rotation tensor.

[0135] Example 4 provides the apparatus of any one of examples 1-3, where the rotation tensor includes one or more positive cosines of one or more rotation angles; and one or more negative sines of the one or more rotation angles.

[0136] Example 5 provides the apparatus of any one of examples 1-4, where the rotation tensor includes a first half of elements of the rotation tensor includes positive cosines of one or more rotation angles; and a second half of the elements of the rotation tensor includes negative sines of the one or more rotation angles.

[0137] Example 6 provides the apparatus of any one of examples 1-5, where the convolution operation is a depth-wise convolution operation.

[0138] Example 7 provides the apparatus of any one of examples 1-6, where performing the convolution operation includes performing element-wise multiplication to obtain products; and summing the products along a dimension.

[0139] Example 8 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more data processing units, cause the one or more data processing units to: receive an input tensor having a number of elements; obtain an expanded tensor from the input tensor, the expanded tensor having twice the number of elements; obtain a rotation tensor having a same shape as the expanded tensor; and obtain one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor to obtain one or more rotary positional embeddings.

[0140] Example 9 provides the one or more non-transitory computer-readable media of example 8, where obtaining the expanded tensor includes reshaping the input tensor to obtain a reshaped tensor; and concatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.

[0141] Example 10 provides the one or more non-transitory computer-readable media of example 8 or 9, where obtaining the rotation tensor includes determining a positive cosine of a rotation angle; determining a negative sine of the rotation angle; and perform a gather operation on the positive cosine and the negative sine to form the rotation tensor.

[0142] Example 11 provides the one or more non-transitory computer-readable media of any one of examples 8-10, where the rotation tensor includes one or more positive cosines of one or more rotation angles; and one or more negative sines of the one or more rotation angles.

[0143] Example 12 provides the one or more non-transitory computer-readable media of any one of examples 8-11, where the rotation tensor includes a half of elements of the rotation tensor includes positive cosines of one or more rotation angles; and a second half of the elements of the rotation tensor includes negative sines of the one or more rotation angles.

[0144] Example 13 provides the one or more non-transitory computer-readable media of any one of examples 8-12, where the convolution operation is a depth-wise convolution operation.

[0145] Example 14 provides the one or more non-transitory computer-readable media of any one of examples 8-13, where performing the convolution operation includes performing element-wise multiplication to obtain products; and summing the products along a dimension.

[0146] Example 15 provides a method, including receiving an input tensor having a number of elements; obtaining an expanded tensor from the input tensor having twice the number of elements; obtaining a rotation tensor having a same shape as the expanded tensor; and obtaining one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor.

[0147] Example 16 provides the method of example 15, where obtaining the expanded tensor includes reshaping the input tensor to obtain a reshaped tensor; and concatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.

[0148] Example 17 provides the method of example 15 or 16, where obtaining the rotation tensor includes determining a positive cosine of a rotation angle; determining a negative sine of the rotation angle; and perform a gather operation on the positive cosine and the negative sine to form the rotation tensor.

[0149] Example 18 provides the method of any one of examples 15-17, where the rotation tensor includes one or more positive cosines of one or more rotation angles; and one or more negative sines of the one or more rotation angles.

[0150] Example 19 provides the method of any one of examples 15-18, where the rotation tensor includes a first half of elements of the rotation tensor includes positive cosines of one or more rotation angles; and a second half of the elements of the rotation tensor includes negative sines of the one or more rotation angles.

[0151] Example 20 provides the method of any one of examples 15-19, where the convolution operation is a depth-wise convolution operation.

[0152] Example 21 provides the method of any one of examples 15-20, where performing the convolution operation includes performing element-wise multiplication to obtain products; and summing the products along a dimension.

[0153] Example A is an apparatus comprising means for carrying out any one of the methods described herein and a method of any one of examples 15-21.

[0154] Example B is a computer program product comprising instructions that cause one or more processors to perform any one of the methods described herein and a method of any one of examples 15-21.

[0155] Example C includes a DNN module as described and illustrated herein.

[0156] Example D includes a compiler as described and illustrated herein.

[0157] Example E includes a DNN system comprising a DNN module according to example C and a DNN accelerator as described herein.

[0158] Example F includes a DNN accelerator to perform any one of the methods described herein and a method of any one of examples 15-21.Variations and other notes

[0159] Although the operations of the example method shown in and described with reference to FIGS. 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. may be combined or may include more or fewer details than described.

[0160] 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.

[0161] 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.

[0162] 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.

[0163] 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.

[0164] 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.

[0165] 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.

[0166] 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.

[0167] 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.

[0168] 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.

[0169] 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. ”

[0170] 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.An apparatus, comprising:one or more data processing units; andone or more non-transitory computer-readable memories to store instructions, wherein the instructions, when executed by the one or more data processing units, cause the one or more data processing units to:receive an input tensor having a number of elements;obtain an expanded tensor from the input tensor, the expanded tensor having twice the number of elements;obtain a rotation tensor having a same shape as the expanded tensor; andobtain one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor.2.The apparatus of claim 1, wherein obtaining the expanded tensor comprises:reshaping the input tensor to obtain a reshaped tensor; andconcatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.3.The apparatus of claim 1 or 2, wherein obtaining the rotation tensor comprises:determining a positive cosine of a rotation angle;determining a negative sine of the rotation angle; andperform a gather operation on the positive cosine and the negative sine to form the rotation tensor.4.The apparatus of any one of claims 1-3, wherein the rotation tensor comprises:one or more positive cosines of one or more rotation angles; andone or more negative sines of the one or more rotation angles.5.The apparatus of any one of claims 1-4, wherein the rotation tensor comprises:a first half of elements of the rotation tensor comprises positive cosines of one or more rotation angles; anda second half of the elements of the rotation tensor comprises negative sines of the one or more rotation angles.6.The apparatus of any one of claims 1-5, wherein the convolution operation is a depth-wise convolution operation.7.The apparatus of any one of claims 1-6, wherein performing the convolution operation comprises:performing element-wise multiplication to obtain products; andsumming the products along a dimension.8.One or more non-transitory computer-readable media storing instructions that, when executed by one or more data processing units, cause the one or more data processing units to:receive an input tensor having a number of elements;obtain an expanded tensor from the input tensor, the expanded tensor having twice the number of elements;obtain a rotation tensor having a same shape as the expanded tensor; andobtain one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor to obtain one or more rotary positional embeddings.9.The one or more non-transitory computer-readable media of claim 8, wherein obtaining the expanded tensor comprises:reshaping the input tensor to obtain a reshaped tensor; andconcatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.10.The one or more non-transitory computer-readable media of claim 8 or 9, wherein obtaining the rotation tensor comprises:determining a positive cosine of a rotation angle;determining a negative sine of the rotation angle; andperform a gather operation on the positive cosine and the negative sine to form the rotation tensor.11.The one or more non-transitory computer-readable media of any one of claims 8-10, wherein the rotation tensor comprises:one or more positive cosines of one or more rotation angles; andone or more negative sines of the one or more rotation angles.12.The one or more non-transitory computer-readable media of any one of claims 8-11, wherein the rotation tensor comprises:a half of elements of the rotation tensor comprises positive cosines of one or more rotation angles; anda second half of the elements of the rotation tensor comprises negative sines of the one or more rotation angles.13.The one or more non-transitory computer-readable media of any one of claims 8-12, wherein the convolution operation is a depth-wise convolution operation.14.The one or more non-transitory computer-readable media of any one of claims 8-13, wherein performing the convolution operation comprises:performing element-wise multiplication to obtain products; andsumming the products along a dimension.15.A method, comprising:receiving an input tensor having a number of elements;obtaining an expanded tensor from the input tensor having twice the number of elements;obtaining a rotation tensor having a same shape as the expanded tensor; andobtaining one or more rotary positional embeddings by performing a convolution operation on the expanded tensor using the rotation tensor.16.The method of claim 15, wherein obtaining the expanded tensor comprises:reshaping the input tensor to obtain a reshaped tensor; andconcatenating the reshaped tensor and the reshaped tensor to form the expanded tensor.17.The method of claim 15 or 16, wherein obtaining the rotation tensor comprises:determining a positive cosine of a rotation angle;determining a negative sine of the rotation angle; andperform a gather operation on the positive cosine and the negative sine to form the rotation tensor.18.The method of any one of claims 15-17, wherein the rotation tensor comprises:one or more positive cosines of one or more rotation angles; andone or more negative sines of the one or more rotation angles.19.The method of any one of claims 15-18, wherein the rotation tensor comprises:a first half of elements of the rotation tensor comprises positive cosines of one or more rotation angles; anda second half of the elements of the rotation tensor comprises negative sines of the one or more rotation angles.20.The method of any one of claims 15-19, wherein the convolution operation is a depth-wise convolution operation.21.The method of any one of claims 15-20, wherein performing the convolution operation comprises:performing element-wise multiplication to obtain products; andsumming the products along a dimension.