Tensor multiplication in neural network based on dequantization with shuffled data layout
By employing a vectorized LUT-based dequantization method with shuffled data layouts for tensor multiplication in DNNs, the inefficiencies in existing tensor operations are addressed, resulting in improved computational efficiency and reduced memory requirements.
Patent Information
- Application Number
- PCT/CN2023/133169
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-07-28
- Filing Date
- 2023-11-22
- Publication Date
- 2025-02-06
AI Technical Summary
Existing tensor multiplication operations in deep neural networks (DNNs) are inefficient due to high computational costs and memory bandwidth requirements, particularly when dealing with large weight tensors and limited energy availability in mobile and edge devices.
The proposed solution involves using a vectorized LUT-based dequantization method with a shuffled data layout to facilitate tensor multiplication operations. This method quantizes weight tensors, packs them into integer weight blocks, and then unpacks and expands these blocks using bit shifting and zero insertion to generate floating-point weight blocks for efficient computation.
This approach significantly reduces the runtime cost of bitwise operations by applying data shuffling ahead of time, saves memory storage space and bandwidth, and enhances the efficiency of tensor multiplication operations in DNNs, particularly in resource-constrained devices.
Smart Images

Figure CN2023133169_06022025_PF_FP_ABST
Abstract
Description
TENSOR MULTIPLICATION IN NEURAL NETWORK BASED ON DEQUANTIZATION WITH SHUFFLED DATA LAYOUT
[0001] Cross-Reference to Related Application
[0002] This application claims the benefit of and hereby incorporates by reference, for all purposes, the entirety of the contents of International Application No. PCT / CN2023 / 109778, filed July 28, 2023, and entitled “LOOKUP-TABLE BASED DEQUANTIZATION FOR NEURAL NETWORK INFERENCE WITH SHUFFLED DATA LAYOUT AND PERMUTATION INSTRUCTION. ” Technical Field
[0003] This disclosure relates generally to deep neural networks (DNN) , and more specifically, tensor multiplication operations in DNNs based on dequantization with shuffled data layout.Background
[0004] 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 each inference can require hundreds of millions of tensor operations as well as a large amount of data to read and write. Many tensor operations (e.g., MAC (multiply-accumulate) operations in convolutional layers, linear transformations in fully-connected layers, etc. ) include tensor multiplications.Brief Description of the Drawings
[0005] 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.
[0006] FIG. 1 illustrates an example DNN, in accordance with various embodiments.
[0007] FIG. 2 is a block diagram of a DNN system, in accordance with various embodiments.
[0008] FIG. 3 is a block diagram of a DNN module, in accordance with various embodiments.
[0009] FIG. 4 illustrates a tensor multiplication operation based on dequantization with shuffled data layout, in accordance with various embodiments.
[0010] FIG. 5 illustrates quantization of a weight tensor, in accordance with various embodiments.
[0011] FIG. 6 illustrates partitioning a weight tensor, in accordance with various embodiments.
[0012] FIG. 7A illustrates shuffling data elements in a weight group, in accordance with various embodiments.
[0013] FIG. 7B illustrates shuffling data elements in another weight group, in accordance with various embodiments.
[0014] FIG. 8 illustrates unpacking a weight group, in accordance with various embodiments.
[0015] FIG. 9 illustrates an expanded weight group, in accordance with various embodiments.
[0016] FIG. 10 illustrates a floating-point weight group, in accordance with various embodiments.
[0017] FIG. 11 is a flowchart showing a method of executing a tensor multiplication operation in a DNN, in accordance with various embodiments.
[0018] FIG. 12 is a block diagram of an example computing device, in accordance with various embodiments.Detailed Description
[0019] Overview
[0020] The last decade has witnessed a rapid rise in AI (artificial intelligence) based data processing, particularly based on DNNs. DNNs are widely used in the domains of computer vision, speech recognition, image, and video processing mainly due to their ability to achieve beyond human-level accuracy. 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 energy availability.
[0021] For example, large language models (LLMs) can enhance language understanding, generation, and automation, leading to significant advancements in all aspects of the industries. However, the efficient inference of LLMs can pose challenges due to their massive parameter sizes, requiring substantial computational resources. While large-scale models with hundreds of billions or trillions of parameters may require graphics processing unit (GPU) accelerators for optimal performance, domain-specific medium-scale models can still benefit from central processing unit (CPU) capabilities and deliver satisfactory results. In the process of inference, the model may be fed with a text prompt that usually contains tens to thousands of tokens. Then it generates the response tokens one by one in an auto-regressive manner. The majority time of the workload is spent on tensor multiplications in the inner-product operations which are primarily memory bandwidth bound on the loading of parameters (e.g., weights) of large sizes.
[0022] Many DNNs include tensor multiplication operations. A tensor multiplication operation may be performed on an input tensor and a weight tensor. A tensor is a data structure having multiple elements across one or more dimensions. Example tensors include a vector, which may be a one-dimensional tensor, and a matrix, which may be a two-dimensional tensor. There can also be three-dimensional tensors and even higher dimensional tensors. The input tensor includes one or more activations (also referred to as “input activations” or “input elements” ) . The weight tensor includes one or more weights. The value of the weights may be determined by training the DNN. The output of the tensor multiplication operation may be an output tensor that includes one or more output activations (also referred to as “output elements” ) .
[0023] Weight compression techniques, such as low-bit quantization, are used to improve efficiency of tensor multiplication operations in DNNs. DNN accuracy may still be preserved even with small number of bits (e.g., 4-bit for INT4 data format, 8-bit for data INT8 format, etc. ) when they are dequantized at runtime and the computation is conducted in higher-precision floating-point data formats, such as FP32, FP16, BF16, and so on. INT standards for integer. FP standards for floating point. BF standards for brain floating point. However, existing INT4 dequantization algorithms are not efficient. For look-up table (LUT) based solution, dequantization can be applied one scalar 4-bit value at a time. For affine quantization, even though the dequantization can be vectorized, there are still quite a few bit operations and conversion instructions are usually needed for a vector of 4-bit values.
[0024] Embodiments of the present disclosure may improve on at least some of the challenges and issues described above by facilitating tensor multiplication operations in DNNs based on dequantization with shuffled layout. Vectorized LUT-based dequantization may be used to speed up tensor multiplication operations and save the time and power required by DNN inference.
[0025] In various embodiments of the present disclosure, a weight tensor of a tensor multiplication operation in a DNN includes weights having a floating-point data format. The weights in the weight tensor may be quantized to generate an integer weight block. The integer weight block may have a smaller storage size than the weight tensor. The integer weight tensor may be further packed. For instance, the integer weight tensor may be partitioned into weight blocks having a predetermined block size. The block size may indicate the number of data elements in each weight block. A weight block may be further partitioned into weight groups having a predetermined group size. The group size may indicate the number of data elements in each weight group. The data elements in a weight group may be shuffled to form a shuffled weight group. The positions of the data elements in the weight group are different from the positions of the data elements in the shuffled weight group. The shuffled weight groups generated from the weight groups in the same weight block may constitute an integer weight block.
[0026] Integer weight blocks with shuffled data layouts may be generated before the execution of the tensor multiplication operation is started or even before the execution for the DNN is started. To execute the tensor multiplication operation, the integer weight blocks may be provided to a DNN accelerator that executes the DNN. The DNN accelerator may include a dequantization unit that unpacks and dequantizes the integer weight blocks to generate floating-point weight blocks. An integer weight block may be unpacked through bit shifting. For instance, a sequence of bits in the integer weight block may be shifted right by a predetermined number. The predetermined number may be the total number of bits in a single data element. The predetermined number of zero bits may be added to the right side of the sequence of bits after the shifting to form a new sequence of bits. The new sequence of bits may be placed after the original sequence of bits to form an unpacked weight group. The unpacked weight group may have an integer data format that has a higher precision than the integer data format of the integer weight block. Zeros may be added to the unpacked weight group to form an expanded weight group. The expanded weight group may have an integer data format that has a higher precision than the integer data format of the unpacked weight group. The numbers of data elements in the integer weight group, the unpacked weight group, and the unpacked weight group may be the same. A vectorized LUT-based dequantization method may be used to convert the expanded weight group to a floating-point weight group. The floating-point weight group generated using the weight groups from the same integer weight block may constitute a floating-point weight block. The tensor multiplication operation may be executed on the floating-point weight blocks and corresponding activation blocks in the input tensor.
[0027] The present disclosure provides a vectorized LUT-based method that can compute dequantization efficiently via a special shuffled data layout and permutation instructions. The method can be used to implement both affine quantization and LUT-based quantization. The shuffled data layout on the weight data can save the runtime cost of bitwise operations with the data shuffling operation applied ahead of time before inference runtime. Also, vectorized LUT-based on permutation instructions can map integer values to floating-point values without the requirement of explicit type conversion and can provide support for LUT quantization.
[0028] 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 or / and 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.
[0029] Further, references are made to the accompanying drawings that form a part hereof, and in which is 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.
[0030] Various operations may be described as multiple discrete actions or operations in turn, in a manner that is most helpful in understanding the claimed 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.
[0031] 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.
[0032] 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.
[0033] 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.
[0034] 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.
[0035] 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, device, or DNN accelerator 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, device, or DNN accelerators. Also, the term “or” refers to an inclusive “or” and not to an exclusive “or. ”
[0036] 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 below and the accompanying drawings.
[0037] Example DNN
[0038] FIG. 1 illustrates an example DNN 100, in accordance with various embodiments. For the purpose of illustration, the DNN 100 in FIG. 1 is a CNN. In other embodiments, the DNN 100 may be other types of DNNs. The DNN 100 is trained to receive images and output classifications of objects in the images. In the embodiments of FIG. 1, the DNN 100 receives an input image 105 that includes objects 115, 125, and 135. The DNN 100 includes a sequence of layers comprising a plurality of convolutional layers 110 (individually referred to as “convolutional layer 110” ) , a plurality of pooling layers 120 (individually referred to as “pooling layer 120” ) , and a plurality of fully-connected layers 130 (individually referred to as “fully-connected layer 130” ) . In other embodiments, the DNN 100 may include fewer, more, or different layers. In an inference of the DNN 100, the layers of the DNN 100 execute tensor computation that includes many tensor operations, such as convolution (e.g., multiply-accumulate (MAC) operations, etc. ) , pooling operations, elementwise operations (e.g., elementwise addition, elementwise multiplication, etc. ) , other types of tensor operations, or some combination thereof.
[0039] The convolutional layers 110 summarize the presence of features in the input image 105. The convolutional layers 110 function as feature extractors. The first layer of the DNN 100 is a convolutional layer 110. In an example, a convolutional layer 110 performs a convolution on an input tensor 140 (also referred to as IFM 140) and a filter 150. As shown in FIG. 1, the IFM 140 is represented by a 7×7×3 three-dimensional (3D) matrix. The IFM 140 includes 3 input channels, each of which is represented by a 7×7 two-dimensional (2D) matrix. The 7×7 2D matrix includes 7 input elements (also referred to as input points) in each row and 7 input elements in each column. The filter 150 is represented by a 3×3×3 3D matrix. The filter 150 includes 3 kernels, each of which may correspond to a different input channel of the IFM 140. A kernel is a 2D matrix of weights, where the weights are arranged in columns and rows. A kernel can be smaller than the IFM. In the embodiments of FIG. 1, each kernel is represented by a 3×3 2D matrix. The 3×3 kernel includes 3 weights in each row and 3 weights in each column. Weights can be initialized and updated by backpropagation using gradient descent. The magnitudes of the weights can indicate importance of the filter 150 in extracting features from the IFM 140.
[0040] The convolution includes MAC operations with the input elements in the IFM 140 and the weights in the filter 150. The convolution may be a standard convolution 163 or a depthwise convolution 183. In the standard convolution 163, the whole filter 150 slides across the IFM 140. All the input channels are combined to produce an output tensor 160 (also referred to as output feature map (OFM) 160) . The OFM 160 is represented by a 5×5 2D matrix. The 5×5 2D matrix includes 5 output elements (also referred to as output points) in each row and 5 output elements in each column. For the purpose of illustration, the standard convolution includes one filter in the embodiments of FIG. 1. In embodiments where there are multiple filters, the standard convolution may produce multiple output channels in the OFM 160.
[0041] The multiplication applied between a kernel-sized patch of the IFM 140 and a kernel may be a dot product. A dot product is the elementwise multiplication between the kernel-sized patch of the IFM 140 and the corresponding kernel, which is then summed, always resulting in a single value. Because it results in a single value, the operation is often referred to as the “scalar product. ” Using a kernel smaller than the IFM 140 is intentional as it allows the same kernel (set of weights) to be multiplied by the IFM 140 multiple times at different points on the IFM 140. Specifically, the kernel is applied systematically to each overlapping part or kernel-sized patch of the IFM 140, left to right, top to bottom. The result from multiplying the kernel with the IFM 140 one time is a single value. As the kernel is applied multiple times to the IFM 140, the multiplication result is a 2D matrix of output elements. As such, the 2D output matrix (i.e., the OFM 160) from the standard convolution 163 is referred to as an OFM.
[0042] In the depthwise convolution 183, the input channels are not combined. Rather, MAC operations are performed on an individual input channel and an individual kernel and produce an output channel. As shown in FIG. 1, the depthwise convolution 183 produces a depthwise output tensor 180. The depthwise output tensor 180 is represented by a 5×5×3 3D matrix. The depthwise output tensor 180 includes 3 output channels, each of which is represented by a 5×5 2D matrix. The 5×5 2D matrix includes 5 output elements in each row and 5 output elements in each column. Each output channel is a result of MAC operations of an input channel of the IFM 140 and a kernel of the filter 150. For instance, the first output channel (patterned with dots) is a result of MAC operations of the first input channel (patterned with dots) and the first kernel (patterned with dots) , the second output channel (patterned with horizontal strips) is a result of MAC operations of the second input channel (patterned with horizontal strips) and the second kernel (patterned with horizontal strips) , and the third output channel (patterned with diagonal stripes) is a result of MAC operations of the third input channel (patterned with diagonal stripes) and the third kernel (patterned with diagonal stripes) . In such a depthwise convolution, the number of input channels equals the number of output channels, and each output channel corresponds to a different input channel. The input channels and output channels are referred to collectively as depthwise channels. After the depthwise convolution, a pointwise convolution 193 is then performed on the depthwise output tensor 180 and a 1×1×3 tensor 190 to produce the OFM 160.
[0043] The OFM 160 is then passed to the next layer in the sequence. In some embodiments, the OFM 160 is passed through an activation function. An example activation function is rectified linear unit (ReLU) . ReLU is a calculation that returns the value provided as input directly, or the value zero if the input is zero or less. The convolutional layer 110 may receive several images as input and calculate the convolution of each of them with each of the kernels. This process can be repeated several times. For instance, the OFM 160 is passed to the subsequent convolutional layer 110 (i.e., the convolutional layer 110 following the convolutional layer 110 generating the OFM 160 in the sequence) . The subsequent convolutional layers 110 perform a convolution on the OFM 160 with new kernels and generate a new feature map. The new feature map may also be normalized and resized. The new feature map can be kernelled again by a further subsequent convolutional layer 110, and so on.
[0044] In some embodiments, a convolutional layer 110 has four hyperparameters: the number of kernels, the size F kernels (e.g., a kernel is of dimensions F×F×D pixels) , the S step with which the window corresponding to the kernel is dragged on the image (e.g., a step of one means moving the window one pixel at a time) , and the zero-padding P (e.g., adding a black contour of P pixels thickness to the input image of the convolutional layer 110) . The convolutional layers 110 may perform various types of convolutions, such as 2-dimensional convolution, dilated or atrous convolution, spatial separable convolution, depthwise separable convolution, transposed convolution, and so on. The DNN 100 includes 16 convolutional layers 110. In other embodiments, the DNN 100 may include a different number of convolutional layers.
[0045] The pooling layers 120 down-sample feature maps generated by the convolutional layers, e.g., by summarizing the presence of features in the patches of the feature maps. A pooling layer 120 is placed between two convolution layers 110: a preceding convolutional layer 110 (the convolution layer 110 preceding the pooling layer 120 in the sequence of layers) and a subsequent convolutional layer 110 (the convolution layer 110 subsequent to the pooling layer 120 in the sequence of layers) . In some embodiments, a pooling layer 120 is added after a convolutional layer 110, e.g., after an activation function (e.g., ReLU, etc. ) has been applied to the OFM 160.
[0046] A pooling layer 120 receives feature maps generated by the preceding convolution layer 110 and applies a pooling operation to the feature maps. The pooling operation reduces the size of the feature maps while preserving their important characteristics. Accordingly, the pooling operation improves the efficiency of the DNN and avoids over-learning. The pooling layers 120 may perform the pooling operation through average pooling (calculating the average value for each patch on the feature map) , max pooling (calculating the maximum value for each patch of the feature map) , or a combination of both. The size of the pooling operation is smaller than the size of the feature maps. In various embodiments, the pooling operation is 2×2 pixels applied with a stride of two pixels, so that the pooling operation reduces the size of a feature map by a factor of 2, e.g., the number of pixels or values in the feature map is reduced to one quarter the size. In an example, a pooling layer 120 applied to a feature map of 6×6 results in an output pooled feature map of 3×3. The output of the pooling layer 120 is inputted into the subsequent convolution layer 110 for further feature extraction. In some embodiments, the pooling layer 120 operates upon each feature map separately to create a new set of the same number of pooled feature maps.
[0047] The fully-connected layers 130 are the last layers of the DNN. The fully-connected layers 130 may be convolutional or not. The fully-connected layers 130 may also be referred to as linear layers. In some embodiments, a fully-connected layer 130 (e.g., the first fully-connected layer in the DNN 100) may receive an input operand. The input operand may define the output of the convolutional layers 110 and pooling layers 120 and includes the values of the last feature map generated by the last pooling layer 120 in the sequence. The fully-connected layer 130 may apply a linear transformation to the input operand through a weight matrix. The weight matrix may be a kernel of the fully-connected layer 130. The linear transformation may include a tensor multiplication between the input operand and the weight matrix. The result of the linear transformation may be an output operand. In some embodiments, the fully-connected layer may further apply a non-linear transformation (e.g., by using a non-linear activation function) on the result of the linear transformation to generate an output operand. The output operand may contain as many elements as there are classes: element i represents the probability that the image belongs to class i. Each element is therefore between 0 and 1, and the sum of all is worth one. These probabilities are calculated by the last fully-connected layer 130 by using a logistic function (binary classification) or a SoftMax function (multi-class classification) as an activation function.
[0048] In some embodiments, the fully-connected layers 130 classify the input image 105 and return an operand of size N, where N is the number of classes in the image classification problem. In the embodiments of FIG. 1, N equals 3, as there are 3 objects 115, 125, and 135 in the input image. Each element of the operand indicates the probability for the input image 105 to belong to a class. To calculate the probabilities, the fully-connected layers 130 multiply each input element by weight, make the sum, and then apply an activation function (e.g., logistic if N=2, SoftMax if N>2) . This is equivalent to multiplying the input operand by the matrix containing the weights. In an example, the vector includes 3 probabilities: a first probability indicating the object 115 being a tree, a second probability indicating the object 125 being a car, and a third probability indicating the object 135 being a person. In other embodiments where the input image 105 includes different objects or a different number of objects, the individual values can be different.
[0049] Example DNN System
[0050] FIG. 2 is a block diagram of a DNN system 200, in accordance with various embodiments. The whole DNN system 200 or a part of the DNN system 200 may be implemented in one or more computing devices, such as the computing device 1800 in FIG. 18. The DNN system 200 can generate and execute DNNs, such as the DNN 100 in FIG. 1. As shown in FIG. 2, the DNN system 200 includes a DNN module 201 and a DNN accelerator 202. In other embodiments, alternative configurations, different or additional components may be included in the DNN system 200. For instance, the DNN system 200 may include multiple DNN modules or multiple DNN accelerators. Further, functionality attributed to a component of the DNN system 200 may be accomplished by a different component included in the DNN system 200 or a different system. In some embodiments, the DNN module 201 and DNN accelerator 202 may include different types of processing units. The DNN module 201 and DNN accelerator 202 may be implemented in the same chip or separate chips.
[0051] The DNN module 201 facilitates generation and deployment of DNNs. In some embodiments, the DNN module 201 may generate and train DNNs. For instance, the DNN module 201 can define the layered architecture of a DNN. The DNN module 201 can also determine the internal parameters of the DNN through a DNN training process. The DNN module 201 may also determine one or more hyperparameters that define how the DNN is trained. After DNNs are trained, the DNN module 201 may compress DNNs to reduce the amount of computation resources (e.g., power, processing element, time, memory, etc. ) that would be needed for executing the DNNs. The DNN module 201 may also validate DNNs after training or compression to ensure that the accuracy of the trained or compressed DNN meets a target accuracy.
[0052] The DNN module 201 may deploy trained, compressed, or validated DNNs for use in deep learning applications. The DNN module 201 may control inference processes of trained, compressed, or validated DNNs. In some embodiments, the DNN module 201 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, the DNN module 201 may facilitate deployment of the DNNs using the DNN accelerator 202. For instance, the DNN module 201 may receive data from a device or system coupled with the DNN system 200 and input the received data (or data generated by the DNN module 201, e.g., based on the received data) into a DNN. The DNN module 201 may generate instructions (e.g., configuration files) that control the operation of the DNN accelerator 202 during the DNN inference. The DNN module 201 may receive an output of the DNN from the DNN accelerator 202. The DNN module 201 may transmit the output of the DNN (or a result of processing the output of the DNN by the DNN module 201) to the device or system.
[0053] In some embodiments, after DNNs are trained, compressed, or validated, the DNN module 201 may process weight tensors in the DNNs to facilitate tensor multiplication operations based on dequantization with shuffle data layout. For instance, a weight tensor of a tensor multiplication operation may be a floating-point weight tensor including floating-point weights. The DNN module 201 may quantize and pack the floating-point weights to transform the weight tensor into integer weight blocks. A integer weight block includes weights in an integer data format. Compared with the floating-point weight tensor, the integer weight blocks may require less storage space. Also, it may require less time to execute the tensor multiplication operation on the integer weight blocks. In some embodiments, the DNN module 201 may process floating-point weight tensors ahead of time. For instance, the DNN module 201 may process a floating-point weight tensor before the execution of the tensor multiplication operation is started or even before the execution of the DNN is started. More details regarding quantizing and packing floating-point weight tensors by the DNN module 201 are described below in conjunction with FIG. 3, FIG. 4-6, and FIGS. 7A and 7B.
[0054] The DNN accelerator 202 executes DNNs provided by the DNN module 201. For instance, the DNN accelerator 202 can perform DNN inference, e.g., by running deep learning operations in the DNNs, for training DNNs or for using the trained / compressed / validated DNNs to perform tasks. As shown in FIG. 2, the DNN accelerator 202 includes a memory 210, a DMA (direct memory access) engine 220, and compute blocks 230 (individually referred to as “compute block 230” ) . In other embodiments, alternative configurations, different or additional components may be included in the DNN accelerator 202. For example, the DNN accelerator 202 may include more than one memory 210 or DMA engine 220. As another example, the DNN accelerator 202 may include a single compute block 230. Further, functionality attributed to a component of the DNN accelerator 202 may be accomplished by a different component included in the DNN accelerator 202 or by a different system. A component of the DNN accelerator 202 may be implemented in hardware, software, firmware, or some combination thereof.
[0055] The memory 210 stores data associated with deep learning operations performed by the DNN accelerator. In some embodiments, the memory 210 may store data to be used by the compute blocks 230 for DNN inference. For example, the memory 210 may store weights, such as weights of convolutional layers, which are determined by training DNNs. As another example, the memory 210 may store inputs to DNNs or outputs of DNNs. The memory 210 may also store data generated by the compute blocks 230 from performing deep learning operations in DNNs. Example deep learning operations include convolutions (also referred to as “convolutional operations” ) , pooling operations, elementwise operations, activation functions, other types of deep learning operations, or some combination thereof. The memory 210 may be a main memory of the DNN accelerator 202. In some embodiments, the memory 210 includes one or more dynamic random-access memories (DRAMs) .
[0056] The DMA engine 220 facilitates data transfer between the memory 210 and local memories of the compute blocks 230. For example, the DMA engine 220 can read data from the memory 210 and write data into a local memory of a compute block 230. As another example, the DMA engine 220 can read data from a local memory of a compute block 230and write data into the memory 210. The DMA engine 220 provides a DMA feature that allows the compute block 230 to initiate data transfer between the memory 210 and the local memories of the compute blocks 230 and to perform other operations while the data transfer is in being conducted. In some embodiments, the DMA engine 220 may read tensors from the memory 210, modify the tensors in a way that is optimized for the compute block 230 before it writes the tensors into the local memories of the compute blocks 230.
[0057] The compute blocks 230 can perform deep learning operations in DNNs. For instance, a compute block 230 may run a deep learning operation in a DNN layer, or a portion of the deep learning operation, at a time. The compute blocks 230 may be capable of running various types of deep learning operations, such as convolution, pooling, elementwise operation, linear operation, non-linear operation, and so on. In an example, a compute block 230 may perform convolutions, e.g., standard convolution or depthwise convolution. A deep learning operation may include one or more tensor multiplication operations. In some embodiments, the operations of the DNN layers may be run by multiple compute blocks 230 in parallel. For instance, multiple compute blocks 230 may each perform a portion of a workload for a convolution. Data may be shared between the compute blocks 230. A compute block 230 may also be referred to as a compute tile. In some embodiments, each compute block 230 may be a processing unit.
[0058] In the embodiments of FIG. 2, each compute block 230 includes a local memory 240, a dequantization unit 250, and a tensor multiplication unit 260. Some or all the components of the compute block 230 can be implemented on the same chip. In other embodiments, alternative configurations, different or additional components may be included in the compute block 230. Further, functionality attributed to a component of the compute block 230 may be accomplished by a different component included in the compute block 230, a different compute block 230, another component of the DNN accelerator 202, or a different system. A component of the compute block 230 may be implemented in hardware, software, firmware, or some combination thereof.
[0059] The local memory 240 is local to the corresponding compute block 230. In the embodiments of FIG. 2, the local memory 240 is inside the compute block 230. In other embodiments, the local memory 240 may be outside the compute block 230. Data in the local memory 240 may be transferred to or from the memory 210, e.g., through the DMA engine 220. In some embodiments, data in the local memory 240 may be transferred to or from the local memory of another compute block 230. The local memory 240 may store data received, used, or generated by the dequantization unit 250 and the tensor multiplication unit 260. Examples of the data may include input activations, weights, output activations, sparsity bitmaps, and so on.
[0060] The local memory 240 may include different levels of memories. For instance, the local memory 240 may include registers, L1 cache memory, and so on. Different memories in the local memory 240 may be arranged at different locations in the compute block 230. In some embodiments, the local memory 240 includes one or more static random-access memories (SRAMs) . The local memory 240 may be byte-addressable, and each memory address identifies a single byte (eight bits) of storage. In some embodiments, the local memory 240 may include memory banks. The number of data banks in the local memory 240 may be 16, 64, 128, 256, 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.
[0061] Data elements of different precisions may require different amounts of memory. For instance, a storage unit of 8 bits can store a data element in the FP8 or INT8 format. Two storage units may be needed to store a data element in the INT16, FP16, or BF16 format, which has 16 bits. Three storage units may be needed to store a data element in the INT32 or FP32 format, which has 32 bits. Data elements of different precisions may also require different memory bandwidth. In some embodiments, a single read cycle may read a predetermined number of bits from the local memory 240. In example where 16 bits may be transferred from the local memory 240 in a single read cycle, a read cycle can transfer two data elements in the FP8 format but a single data element in the FP16 or BF16 format, while the transfer of a single data element in the FP32 format would require two read cycles. Therefore, reducing data precision may reduce memory storage space and memory bandwidth.
[0062] The dequantization unit 250 receives weight blocks from the DNN module 201 and dequantizes the weight blocks. The weight blocks from the DNN module 201 may have been quantized and packed and may have shuffled data layouts. The dequantization unit 250 may unitize bitwise logical and shifting operations to unpack the weight blocks into floating-point weight blocks. The dequantization unit 250 may be implemented with unpacking and dequantization logic. In some embodiments, the dequantization unit 250 may leverage the shuffled layout of data elements in the weight blocks to simplify the unpacking and dequantization logic.
[0063] In an embodiment, the dequantization unit 250 may load the quantized and packed weight blocks into registers. The dequantization unit 250 may further unpack data elements in the quantized and packed weight blocks. For instance, the dequantization unit 250 may perform bit right shifting on data elements of a weight block (e.g., on a vector in the weight block) to produce new data elements. The new data elements may be added to the weight block to unpack the weight block. The unpacking may also increase the precision of the weight block. For instance, the unpacking may change the data format from a lower-precision integer format (e.g., INT4) to a higher-precision integer format (e.g., INT8) . In some embodiments, one time bit shifting may be sufficient to unpack the high parts and low parts of 4-bit values from each byte. Additional bit masking operations may be avoided given the utilization of the shuffled data layout and permutation instruction which may ignore the higher bits of the index register.
[0064] The dequantization unit 250 may also expand the unpacked weight block by inserting zeros into the unpacked weight block. The insertion of the zeros may change the data format of the data elements in the weight block. In an example, the dequantization unit 250 may increase the precision of the weight block by changing the data format from a lower-precision integer format (e.g., INT4, INT8, etc. ) to a higher-precision integer format (e.g., INT32) . In some embodiments, the unpacking or expanding by the dequantization unit 250 does not change the spatial size of the weight block, i.e., the number of data elements may remain the same. The dequantization unit 250 may further transform the expanded weight blocks to floating-point weight blocks. In some embodiments, the dequantization unit 250 may use a LUT to transform integer data elements in the converted weight blocks to floating-point data elements. The LUT may also be used, e.g., by the DNN module 201, to quantize floating-point weights.
[0065] In some embodiments, the dequantization unit 250 may perform unpacking and dequantization on a group level. For instance, a weight block received by the dequantization unit 250 may include a plurality of weight groups. The weight groups may be unpacked and dequantized separately to generate floating-point weight groups. The floating-point weight groups may be combined to produce a floating-point weight block. More details regarding dequantization are described below in conjunction with FIG. 4 and FIGS. 8-10.
[0066] FIG. 3 is a block diagram of a DNN module 201, in accordance with various embodiments. The DNN module 201 includes an interface module 310, a training module 320, a compressing module 330, a validating module 340, a weight processing module 350, and a datastore 360. In other embodiments, alternative configurations, different or additional components may be included in the DNN module 201. Further, functionality attributed to a component of the DNN module 201 may be accomplished by a different component included in the DNN module 201 or a different module or system.
[0067] The interface module 310 facilitates communications of the DNN module 201 with other modules or systems. For example, the interface module 310 establishes communications between the DNN module 201 with an external database to receive data that can be used to train DNNs or input into DNNs to perform tasks. As another example, the interface module 310 supports the DNN module 201 to distribute DNNs to other systems, e.g., computing devices configured to apply DNNs to perform tasks.
[0068] The training module 320 trains DNNs by using a training dataset. The training module 320 forms the training dataset. In an embodiment where the training module 320 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 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 the validating module 340 to validate performance of a trained DNN.
[0069] The training module 320 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.
[0070] The training module 320 defines the architecture of the DNN, e.g., based on some of the hyperparameters. The architecture of the DNN includes an input layer, an output layer, and a plurality of hidden layers. The input layer of an DNN may include tensors (e.g., a multidimensional array) specifying attributes of the input image, such as the height of the input image, the width of the input image, and the depth of the input image (e.g., the number of bits specifying the color of a pixel in the input image) . The output layer includes labels of objects in the input layer. The hidden layers are layers between the input layer and output layer. The hidden layers include one or more convolutional layers and one or more other types of layers, such as pooling layers, fully-connected layers, normalization layers, SoftMax or logistic layers, and so on. The convolutional layers of the DNN may abstract the input image to a feature map that is represented by a tensor specifying the feature map height, the feature map width, and the feature map channels (e.g., red, green, blue images include 3 channels) . A pooling layer is used to reduce the spatial volume of input image after convolution. It is used between two convolution layers. A fully-connected layer involves weights, biases, and neurons. It connects neurons in one layer to neurons in another layer. It is used to classify images between different category by training.
[0071] In the process of defining the architecture of the DNN, the training module 320 also adds an activation function to a hidden layer or the output layer. An activation function of a layer transforms the weighted sum of the input of the layer to an output of the layer. The activation function may be, for example, a ReLU activation function, a tangent activation function, or other types of activation functions.
[0072] After the training module 320 defines the architecture of the DNN, the training module 320 inputs a training dataset into the DNN. The training dataset includes a plurality of training samples. An example of a training sample includes an image capturing an object and a ground-truth label indicating a prediction made using the image. The training module 320 modifies the parameters inside the DNN ( “internal parameters of the DNN” ) to minimize the error between labels of the training samples that are generated by the DNN and the ground-truth labels of the training samples. The internal parameters include weights of filters in the convolutional layers of the DNN. In some embodiments, the training module 320 uses a cost function to minimize the error.
[0073] The training module 320 may train the DNN for a predetermined number of epochs. The number of epochs is a hyperparameter that defines the number of times that the deep learning algorithm will work through the entire training dataset. One epoch means that each sample in the training dataset has had an opportunity to update internal parameters of the DNN. After the training module 320 finishes the predetermined number of epochs, the training module 320 may stop updating the parameters in the DNN. The DNN having the updated parameters is referred to as a trained DNN.
[0074] The compressing module 330 compresses DNNs. For instance, the compressing module 330 may add pruning operations to DNN layers to reduce computational complexity or memory usage. A pruning operation may prune weight tensors of a DNN layer by changing one or more nonzero valued weights of the layer to zeros. The modification may be done before, during, or after training. Weights may be pruned during training, during inference, or a combination of both. The compressing module 330 may determine a sparsity ratio for a DNN layer. The sparsity ratio may be a ratio of the number of zero-valued weights to the total number of weights in the layer. The compressing module 330 may perform the pruning operation till the sparsity ratio of the DNN layer meets a target sparsity ration, such as 10%, 20%, 30%, 30%, 50%, and so on.
[0075] In some embodiments, the compressing module 330 may select one or more layers in a DNN and modify each selected layer with a pruning operation. For instance, the compressing module 330 may select computationally complex layers, such as layers with large filters. For a pruning operation of a layer or of a type of layer, the compressing module 330 may determine a weight threshold that would not cause a loss of the accuracy of the DNN to exceed an accuracy loss constraint. A pruning operation may modify weights having absolute values above the weight threshold to zeros and leave the other weights unchanged. The weight pruning can reduce memory storage as zero-valued weights may not be stored. Also, the number of operations in the layer can be reduced as computations on zero-valued weights can be skipped without impacting the output of the layer. In some embodiments, the compressing module 330 may also measure energy saving, final DNN accuracy, or layer-wise sparsity caused by pruning operations.
[0076] After compressing a DNN, the compressing module 330 may fine tune the DNN, e.g., through a retraining process. The compressing module 330 may fine tunes DNNs after weights are pruned. In some embodiments, the fine-tuning process is a retraining or further training process. For instance, after weights in a DNN are pruned, the compressing module 330 may further train the DNN by inputting a training dataset into the DNN. The values of the unpruned weights in the DNN may be modified based on outputs of the DNN and ground-truth labels of the training samples in the training dataset. In some embodiments, the values of the pruned weights (i.e., zero) are not changed during the fine-tuning process. For instance, the compressing module 330 may place a mask over a pruned weight block and the mask can prevent values in the pruned weight blocks from being changed during the fine-tuning process. In other embodiments, the values of all weights, including the pruned weights, may be changed during the fine-tuning process. After one or more cycles of retraining and weight changing by the compressing module 330, the compressing module 330 may perform a new pruning process, e.g., by selecting weight blocks and pruning the selected weight blocks. In some embodiments, the weight pruning process may be repeated multiple times before the fine-tuning process is done.
[0077] In some embodiments, the number of epochs in the fine-tuning process may be different from the number of epochs in the training process in which the pre-pruning values of the weights are determined. For instance, the fine-tuning process may have less epochs than the training process. In an example, the number of epochs in the fine-tuning process may be relatively small, such as 2, 3, 3, 5, and so on.
[0078] The validating module 340 verifies accuracy of trained or compressed DNNs. In some embodiments, the validating module 340 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, the validating module 340 may determine an accuracy score measuring the precision, recall, or a combination of precision and recall of the DNN. The validating module 340 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 reference classification model 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.
[0079] The validating module 340 may compare the accuracy score with a threshold score. In an example where the validating module 340 determines that the accuracy score of the DNN is less than the threshold score, the validating module 340 instructs the training module 320 to re-train the DNN. In one embodiment, the training module 320 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.
[0080] The weight processing module 350 may process weight tensors to facilitate tensor multiplication operations in DNNs. The weight processing module 350 may process a weight tensor of a tensor multiplication operation in a DNN ahead of time, e.g., before the execution of the tensor multiplication operation is started or even before the execution of the DNN is started. As shown in FIG. 3, the weight processing module 350 includes a quantization module 370 and a packing module 380. In other embodiments, the weight processing module 350 may include different, fewer, or more components. Also, functions of a component of the weight processing module 350 may be performed by another component of the weight processing module 350, another module in the DNN module 201, or a different system or device. For instance, some functions performed by a component of the weight processing module 350 may be performed by the compute blocks 230 in FIG. 2.
[0081] The quantization module 370 quantizes data elements in the weight tensor. In some embodiments, the quantization module 370 changes the floating-point data format of the weight tensor to an integer data format. In an example, the floating-point data format may be FP32, FP16, BF16, and so on. The integer data format may be INT4, INT8, and so on.
[0082] The quantization module 370 may output a quantized weight tensor. The quantized weight tensor is an integer weight tensor as the data elements in the quantized weight tensor are integers. An example of the quantized weight tensor is the integer weight tensor 520 in FIG. 5. The quantized weight tensor may have a smaller storage size than the weight tensor. The quantized weight tensor may require less memory storage space and less memory bandwidth. A data element in the quantized weight tensor may have a smaller bit width than a data element in the weight tensor. The precision of data elements in the weight tensor may be higher than the precision of data elements in the quantized weight tensor. The quantized weight tensor may have the same number of data elements as the weight tensor.
[0083] In some embodiments, the quantization module 370 may quantize the weight tensor using vectorized LUT-based quantization. The quantization module 370 may use a LUT to map floating-point values to integer values or vice versa. The LUT may store a plurality of values that can be used for the mapping. The quantization module may also apply a scale on the values in the LUT. In other embodiments, the quantization module 370 may quantize the weight tensor using affine quantization. Affine quantization may be denoted as y= (x-Z) ×S, where x denotes the original data element, y denotes the quantized data element, Z denotes a zero point, and S denotes a scale (also referred to as “scale factor” ) . In other embodiments, the quantization module may use other quantization techniques.
[0084] The quantization module 370 may quantize data elements in the weight tensor using one or more quantization parameters. A quantization parameter may be a scale, zero point, LUT, etc. A quantization parameter may be shared by multiple values in the weight tensor. In some embodiments, the quantization module 370 uses the same quantization parameter (s) to quantize all the data elements in the weight tensor. In other embodiments, the quantization module 370 may perform per-channel quantization and use the quantization parameter (s) for data elements in the same channel of the weight tensor but use different quantization parameters for data elements in different channels. In some embodiments, multiple data elements in the quantized weight tensor may be packed as one addressable value. For instance, in embodiments where the quantized weight tensor has the INT data format, two data elements in the quantized weight tensor may be packed in an 8-bit (i.e., 1-byte) addressable value.
[0085] The packing module 380 packs the data elements in the quantized weight tensor generated by the quantization module 370 to form weight groups with shuffled data layouts that can facilitate dequantization by the dequantization unit 250. In some embodiments, the packing module 380 may partition the quantized weight tensor into weight blocks. For instance, the packing module 380 may tile a 2D weight tensor F∈RK×K into a 4D tensor where N=Nc×Nb, and K=Kc×Kb. The 4D tensor comprises Nc×Kc weight blocks, and each weight block may have a spatial size of Nb×Kb and may be denoted as In some embodiments, Nc weight blocks may be arranged in a row, andKc weight blocks may be arranged in a column. In some embodiments, Nb or Kb is small power of 2, such as 8, 16, 32, 64, etc. Nb may be a multiply of the number of vector lanes. In some embodiments, each pair of 4-bit values in the quantized weight tensor is packed into one byte along Nb. The size of the cache block may be Nb×Kb / 2.
[0086] The packing module 380 may further partition each weight block into weight groups. In some embodiments, the packing module 380 may split a weight block into weight groups by splitting Nb. Each weight group may have a predetermined number of data elements. The predetermined number may be the size of the group, e.g., 16, 32, 64, and so on. The size of each group may depend on Nb:
[0087] In an example where Nb=16, the group size may be 16. In another example where Nb=32, the group size may be 32. In an example where Nb is not 16 or 32, the group size may be 64.
[0088] The packing module 380 may shuffle the data elements within each weight group to change the positions of data elements in the corresponding weight group. In some embodiments, data shuffling does not require bitwise shifting after loading the data. After the shuffling is done, the packing module 380 may output weight blocks with shuffled data layouts. These weigh blocks may be used by the compute blocks 230 to execute the tensor multiplication operation in the DNN.
[0089] The datastore 360 stores data received, generated, used, or otherwise associated with the DNN module 201. For example, the datastore 360 stores the datasets used by the training module 320 and validating module 340. The datastore 360 may also store data generated by the training module 320 and validating module 340, 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. The datastore 360 may store weight tensor and weight blocks processed or generated by the weight processing module 350. The datastore 360 may also store quantization parameters or other types of parameters used by the weight processing module 350. In the embodiment of FIG. 3, the datastore 360 is a component of the DNN module 201. In other embodiments, the datastore 360 may be external to the DNN module 201 and communicate with the DNN module 201 through a network.
[0090] Example Process of Executing Tensor Multiplication Operation
[0091] FIG. 4 illustrates a tensor multiplication operation 400 based on dequantization with shuffled data layout, in accordance with various embodiments. The tensor multiplication operation 400 may be a deep learning operation or part of a deep learning operation in a DNN. The tensor multiplication operation 400 includes two stages 400A and 400B. The stage 400A may be performed offline, e.g., the DNN is executed. The stage 400B may be performed during runtime, e.g., during the execution of the DNN.
[0092] In the stage 400A, a floating-point weight tensor 401 is input into a quantizer 410. The quantizer may be an example of the quantization module 370 in FIG. 3. The quantizer 410 converts the floating-point weight tensor 401 to an integer weight tensor 402. For instance, the quantizer 410 may convert floating-point data elements in the floating-point weight tensor 401 to integer data elements in the integer weight tensor 402. The integer weight tensor 402 may have a smaller storage size than the floating-point weight tensor 401. An example of the floating-point weight tensor 401 is the floating-point weight tensor 510 in FIG. 5. Examples of the integer weight tensor 402 include the integer weight tensor 520 in FIG. 5 and the weight tensor 600 in FIG. 6.
[0093] The integer weight tensor 402 is input into a packing module 420. An example of the packing module 420 may be the packing module 380 in FIG. 3. The packing module 420 may convert the integer weight tensor 402 to a plurality of integer weight blocks 403, individually referred to as integer weight block 403. An integer weight block 403 may include some data elements in the integer weight tensor 402. The order in which the data elements are arranged in the integer weight block 403 may be different from the order in which the data elements are arranged in the integer weight tensor 402. In some embodiments, the integer weight blocks 403 do not overlap with each other, meaning no data element is in more than one integer weight block 403. An integer weight block 403 may be formed by combining a plurality of weight groups, each weight group may be generated by shuffling data elements in a portion of the integer weight tensor 402. Examples of weight groups in the integer weight blocks 403 include the shuffled weight group 720 in FIG. 7A and the shuffled weight group 740 in FIG. 7B. The byes in an integer weight block 403 may be in little-endian order. The integer weight blocks 403 are the output of the stage 400A and input of the stage 400B.
[0094] In the stage 400B, the integer weight blocks 403 are input into a dequantizer 430. The dequantizer 430 may be an example of the dequantization unit 250 in FIG. 2. The dequantizer 430 generates floating-point weight blocks 404, individually referred to as floating-point weight block 404. A floating-point weight block 404 may be generated by combining a plurality of floating-point weight groups. Examples of floating-point weight groups in the floating-point weight blocks 404 include the floating-point weight group 1000 in FIG. 10.
[0095] In some embodiments, the dequantizer 430 generates a floating-point weight block 404 by unpacking and expanding an integer weight block 403 on a group level. For instance, the dequantizer 430 unpacks and expands an integer weight group (e.g., the weight group 810) in the integer weight block 403 to generate a floating-point weight group in the floating-point weight block 404. During the unpacking process, the dequantizer 430 may generate new data elements by right shifting bits in the integer weight group in the integer weight block 403. The dequantizer 430 may generate an unpacked weight group (e.g., the unpacked weight group 820) by adding the new data elements to the integer weight group in the integer weight block 403. During the expanding process, the dequantizer may add zeros into the unpacked weight group to generate an expanded weight group (e.g., the expanded weight group 900) . The expanded weight group may have a higher precision than the unpacked weight group. The data formats of the unpacked weight group and expanded weight group may be different but may both be integer data formats. The dequantizer 430 may convert the expanded weight group to the floating-point weight group in the floating-point weight block 404 using one or more dequantization techniques, such as affine dequantization, LUT-based dequantization, and so on. In some embodiments, the dequantizer 430 may use the same quantization parameters as the quantizer 410.
[0096] The floating-point weight blocks 404 are input into a multiplication operator 440. The multiplication operation 440 may compute floating-point output blocks 408 using the floating-point weight blocks 404, floating-point activation blocks 405 (individually referred to as “floating-point activation block 405” ) , and a floating-point bias 407. The floating-point weight blocks 404 and floating-point activation blocks 405 may have the same floating-point data format. In some embodiments, the dequantizer 430 may dequantize the integer weight blocks 403 based on the data format of the floating-point activation blocks 405. In other embodiments, the data format of the floating-point activation blocks 405 may be determined based on the data format of the floating-point weight blocks 404. The floating-point bias 407 may have the same data format as the floating-point weight blocks 404 or floating-point activation blocks 405.
[0097] The floating-point activation blocks 405 may be generated from a floating-point activation tensor 406. The floating-point activation tensor 406 may be an input tensor of the tensor multiplication operation 400. The floating-point bias 407 may be an internal parameter of the DNN and may be determined by training the DNN. A floating-point output tensor 409 may be formed from the floating-point output blocks 408. The floating-point output tensor 409 may be the output of the tensor multiplication operation 400.
[0098] FIG. 5 illustrates quantization of a weight tensor, in accordance with various embodiments. FIG. 5 shows a floating-point weight tensor 510 that has a spatial size of 8×8, i.e., the floating-point weight tensor 510 has 8 rows and 8 columns. The width of the floating-point weight tensor 510 (i.e., the number of weights in a row) may be 8, and the length of the floating-point weight tensor 510 (i.e., the number of weights in column) may also be 8. The floating-point weight tensor 510 may be denoted as a two-dimensional tensor (8, 8) . In some embodiments, the floating-point weight tensor 510 may be a weight tensor (e.g., a kernel) of a convolutional layer or a linear layer in a DNN. The weights in the floating-point weight tensor 510 are in a floating-point data format, such as FP32, FP16, BF16, and so on. The values of the weights may be determined by training the DNN.
[0099] The floating-point weight tensor 510 is converted to an integer weight tensor 520 through a quantization process. The quantization process may be performed by the weight processing module 350, e.g., the quantization module 370 in the weight processing module 350. The integer weight tensor 520 may have the same spatial size as the floating-point weight tensor 510. In some embodiments, the 64 weights in the floating-point weight tensor 510 are quantized to generate 64 integers, which are the 64 data element in the integer weight tensor 520. The data elements in the integer weight tensor 520 are in an integer format, such as INT4, INT8, and so on.
[0100] The integer weight tensor 520 has a smaller storage size than the floating-point weight tensor 510. In some embodiments, a data element in the floating-point weight tensor 510 has more bits than a data element in the integer weight tensor 520. In an example, a data element in the floating-point weight tensor 510 may have a storage size of 4 bytes, and the floating-point weight tensor 510 may have a storage size of 256 bytes; while a data element in the integer weight tensor 520 may have a storage size of half a byte, and the integer weight tensor 520 may have a storage size of 32 bytes. With the quantization, memory storage space and bandwidth can be saved. In the example where a data element in the integer weight tensor 520 has a storage size of half a byte, two data elements in the integer weight tensor 520 may share one byte. The spatial sizes and storage sizes described above are for illustrative purposes. In other embodiments, the floating-point weight tensor 510 or the integer weight tensor 520 may have other spatial sizes or other storage sizes.
[0101] FIG. 6 illustrates partitioning a weight tensor 600, in accordance with various embodiments. The weight tensor 600 may be formed by quantizing a weight tensor (e.g., the floating-point weight tensor 510) of a DNN layer. In some embodiments, the weight tensor 600 may be an integer weight tensor. An example of the weight tensor 600 may be the integer weight tensor 520 in FIG. 5. The weight tensor 600 includes a plurality of weights 620 (individually referred to as “weight 620” ) . Each weight 620 is represented by a square with dashed lines in FIG. 6. The weights 620 may be integers and may have an integer data format, e.g., INT 8, INT4, etc.
[0102] The weight tensor 600 is partitioned into weight blocks 610, individually referred to as “weight block 610. ” Each weight block 610 has a subset of the weights 620 in the weight tensor 600. In some embodiments, the weight tensor 600 may be a two-dimensional tensor (N, K) having a spatial size of N×K. The dimension (e.g., width) of the weight tensor 600 along the X axis is N, and the dimension (e.g., height) of the weight tensor 600 along the Y axis is K. N may denote an output feature dimension of the DNN layer, such as the number of output channels of the DNN layer. K may denote input feature dimension of the DNN layer, such as the number of input channels of the DNN layer.
[0103] The weight tensor 600 may be tiled into a four-dimensional tensor (Nc, Kc, Kb, Nb) , where N=Nc × Nb and K=Kc × Kb. Each weight block may be a two-dimensional tensor (Nb, Kb) having a spatial size of Nb×Kb. A row in the weight tensor 600 along the X axis may include Nc weight blocks 610. A column in the weight tensor 600 along the Y axis may include Kc weight blocks 610. Each weight block 610 may be a unit for further processing the weight tensor 600, e.g., for shuffling, dequantization, and so on.
[0104] FIG. 7A illustrates shuffling data elements in a weight group 710, in accordance with various embodiments. The weight group 710 may be a portion of a weight block. For instance, the weight group may be a portion of a weight block 610 in FIG. 6 in embodiments where the group size for the weight block 610 is determined to be 32. For the purpose of illustration, the weight group 710 has two rows. The first row has 16 data elements x0-x15. The second row has 16 data elements y0-y15. In other embodiments, the weight group 710 may have a different number of data elements or have a different spatial size or shape.
[0105] A shuffled weight group 720 is formed by shuffling the data elements in the weight group 710. The shuffled weight group 720 may have the same data elements as the weight group 710. However, the data elements have different positions in the shuffled weight group 720 from the weight group 710. For instance, the data element x1 is moved from the second position in the first row to the third position in the first row. Also, the data element y0 is moved from the first position in the second row to the second position in the first row. The data elements x2-x15 and y1-y14 are also moved.
[0106] In some embodiments of the shuffling process, a first data element from the first row may be paired with a second data element from the second row and. The position of the first data element in the first row may match the position of the second data element in the second row. The two data elements may be placed right next to each other. In other embodiments, the data elements in the weight group 710 may be shuffled in a different way.
[0107] FIG. 7B illustrates shuffling data elements in another weight group 730, in accordance with various embodiments. The weight group 730 may be a portion of a weight block. For instance, the weight group may be a portion of a weight block 610 in FIG. 6 in embodiments where the group size for the weight block 610 is determined to be 16. For the purpose of illustration, the weight group 730 has one row including eight data elements x0-x7 followed by eight additional data elements y0-y8. In other embodiments, the weight group 730 may have a different number of data elements or have a different spatial size or shape.
[0108] A shuffled weight group 740 is formed by shuffling the data elements in the weight group 730. The shuffled weight group 740 may have the same data elements as the weight group 730. However, the data elements have different positions in the shuffled weight group 740 from the weight group 730. For instance, the data element x1 is moved from the second position to the third position. Also, the data element y0 is moved from the ninth position to the second position. The data elements x2-x7 and y1-y7 are also moved. The data elements in the shuffled weight group 740 are in little-endian byte order. In other embodiments, a different byte ordering method may be used. Also, the data elements in the weight group 730 may be shuffled in a different way.
[0109] FIG. 8 illustrates unpacking a weight group 810, in accordance with various embodiments. The weight group 810 may be generated by shuffling a weight group in a weight block. For the purpose of illustration, the weight group 810 has the same data elements as the shuffled weight group 740. In other embodiments, the weight group 810 may include different, fewer, or more data elements.
[0110] In the embodiments of FIG. 8, the weight group 810 is unpacked to generate an unpacked weight group 820. The unpacked weight group 820 includes two rows, each of which includes 16 data elements. In an example unpacking process, the data elements of the weight group 810 are copied into the first row of the unpacked weight group 820. The second row of the unpacked weight group 820 may be generated by shifting the bits in the weight group 810. In the embodiments of FIG. 8, the bits in the weight group 810 are shifted right by the number of bits in one data element so that the first data element x0 is removed. In an example where a data element has 4 bits, the bits in the weight group 810 are shifted right by 4 bits. A zero-valued data element is added as the last data element. In some embodiments, the shifting process includes shifting bits. For instance, the weight group 810 may be stored in a memory with the layout shown in FIG. 8. All the bits in the layout may be shifted right by the number of bits of a single data element. After the shifting, zero-valued bits may be added, and the zero-valued bits may be placed after the remaining bits.
[0111] In some embodiments, the unpacked weight group 820 may have the INT8 data format. x0 and y0 may constitute the first data element in the unpacked weight group 820, followed by the second data element including x1 and y1, and so on. The last data element may include y7 and 0. Each data element may be one byte. The unpacked weight group 820 may have the same number of data elements as the weight group 810 but have a larger storage size than the weight group 810.
[0112] FIG. 9 illustrates an expanded weight group 900, in accordance with various embodiments. The expanded weight group 900 may be generated from the unpacked weight group 820 by adding zeros into the unpacked weight group 820. In some embodiments, three zero-valued bytes are added after every data element in the unpacked weight group 820 to form a data element in the expanded weight group 900. The expanded weight group 900 may have the INT32 data format. The expanded weight group 900may have the same number of data elements as the unpacked weight group 820 but have a larger storage size than the unpacked weight group 820.
[0113] FIG. 10 illustrates a floating-point weight group 1000, in accordance with various embodiments. The floating-point weight group 1000 may be generated from the expanded weight group 900. In some embodiments, the floating-point weight group 1000 is generated using LUT-based dequantization. Each data element in the expanded weight group 900 is dequantized to compute a data element in the floating-point weight group 1000. In an example, the data elements in the floating-point weight group 1000 have the FP32 format.
[0114] The floating-point weight group 1000 may correspond to one weight group in a weight block 610. In some embodiments (e.g., embodiments where the weight block 610 includes multiple weight groups) , all the other weight groups in the weight block 610 may be converted to floating-point weight groups that have the same data format as the floating-point weight group 1000. All the floating-point weight groups may constitute a floating-point weight block that can be used to perform the tensor multiplication operation.
[0115] FIG. 11 is a flowchart showing a method of executing a tensor multiplication operation in a DNN, in accordance with various embodiments. The method 1100 may be performed by the DNN system 200 in FIG. 3. Although the method 1100 is described with reference to the flowchart illustrated in FIG. 11, many other methods for executing tensor multiplication operations may alternatively be used. For example, the order of execution of the steps in FIG. 11 may be changed. As another example, some of the steps may be changed, eliminated, or combined.
[0116] The DNN system 200 stores 1110 a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation. The weight tensor comprises weights in a first floating-point data format. The first integer weight block comprises data elements in a first integer data format. In some embodiments, the first integer weight block is generated further by partitioning a quantized weight tensor into quantized weight blocks. The quantized weight tensor generated by quantizing the weight tensor. The first integer weight block is generated further by generating the first integer weight block from a single quantized weight block of the quantized weight blocks. The DNN system 200 generates the first integer weight block by partitioning the single quantized weight block into a plurality of weight groups. For each weight group of the plurality of weight groups, the DNN system 200 modifies one or more positions of one or more data elements in the weight group.
[0117] The DNN system 200 forms 1120 a second integer weight block based on the first integer weight block. The second integer weight block comprises data elements in a second integer data format. In some embodiments, the second integer data format is different from the first integer data format. A data element in the second integer weight block comprises bits in multiple data elements in the first integer weight block. In some embodiments, the first integer weight block and the second integer weight block have a same number of data elements. The second integer weight block has a larger storage size than the first integer weight block.
[0118] In some embodiments, the first integer weight block includes a plurality of weight groups. A weight group is stored as a first sequence of bits. The DNN system 200 forms the second integer weight block by forming a new weight group by combining the first sequence of bits and the second sequence of bits. The second integer weight block comprises the new weight group. In some embodiments, a data element in the weight group has a predetermined number of bits. The DNN system 200 shifts the first sequence of bits by shifting the first sequence of bits right by the predetermined number.
[0119] The DNN system 200 forms 1130 a third integer weight block from the second integer weight block. The third integer weight block comprises data elements in a third integer data format. In some embodiments, the third integer data format is different from the first integer data format and different from the second integer data format. The third integer weight block is formed by inserting zeros into the second integer weight block. In some embodiments, a data element in the third integer weight block comprises bits in a data element in the second integer weight block and bits in one or more of the zeros inserted into the second integer weight block.
[0120] The DNN system 200 converts 1140 the third integer weight block into a floating-point weight block. The floating-point weight block comprises data elements in a second floating-point data format. In some embodiments, the first integer weight block and the floating-point weight block have a same number of data elements. In some embodiments, the second floating-point data format is different from the first floating-point data format. In an embodiment, the DNN system 200 stores an activation block. The activation block comprises activations in the first floating-point data format. The DNN system 200 converts the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.
[0121] The DNN system 200 executes 1150 the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.
[0122] Example Computing Device
[0123] FIG. 12 is a block diagram of an example computing device 1200, in accordance with various embodiments. In some embodiments, the computing device 1200 can be used as at least part of the DNN system 200. A number of components are illustrated in FIG. 12 as included in the computing device 1200, 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 1200 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 1200 may not include one or more of the components illustrated in FIG. 12, but the computing device 1200 may include interface circuitry for coupling to the one or more components. For example, the computing device 1200 may not include a display device 1206, but may include display device interface circuitry (e.g., a connector and driver circuitry) to which a display device 1206 may be coupled. In another set of examples, the computing device 1200 may not include an audio input device 1218 or an audio output device 1208, but may include audio input or output device interface circuitry (e.g., connectors and supporting circuitry) to which an audio input device 1218 or audio output device 1208 may be coupled.
[0124] The computing device 1200 may include a processing device 1202 (e.g., one or more processing devices) . The processing device 1202 processes electronic data from registers and / or memory to transform that electronic data into other electronic data that may be stored in registers and / or memory. The computing device 1200 may include a memory 1204, 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. In some embodiments, the memory 1204 may include memory that shares a die with the processing device 1202. In some embodiments, the memory 1204 includes one or more non-transitory computer-readable media storing instructions executable to perform operations, e.g., the method 1100 described above in conjunction with FIG. 11 or some operations performed by the DNN system 200 described above in conjunction with FIGS. 2 and 3. The instructions stored in the one or more non-transitory computer-readable media may be executed by the processing device 1202.
[0125] In some embodiments, the computing device 1200 may include a communication chip 1212 (e.g., one or more communication chips) . For example, the communication chip 1212 may be configured for managing wireless communications for the transfer of data to and from the computing device 1200. 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.
[0126] The communication chip 1212 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 chip 1212 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 chip 1212 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 chip 1212 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 chip 1212 may operate in accordance with other wireless protocols in other embodiments. The computing device 1200 may include an antenna 1222 to facilitate wireless communications and / or to receive other wireless communications (such as AM or FM radio transmissions) .
[0127] In some embodiments, the communication chip 1212 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication chip 1212 may include multiple communication chips. For instance, a first communication chip 1212 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication chip 1212 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 chip 1212 may be dedicated to wireless communications, and a second communication chip 1212 may be dedicated to wired communications.
[0128] The computing device 1200 may include battery / power circuitry 1214. The battery / power circuitry 1214 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 1200 to an energy source separate from the computing device 1200 (e.g., AC line power) .
[0129] The computing device 1200 may include a display device 1206 (or corresponding interface circuitry, as discussed above) . The display device 1206 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.
[0130] The computing device 1200 may include an audio output device 1208 (or corresponding interface circuitry, as discussed above) . The audio output device 1208 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.
[0131] The computing device 1200 may include an audio input device 1218 (or corresponding interface circuitry, as discussed above) . The audio input device 1218 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) .
[0132] The computing device 1200 may include a GPS device 1216 (or corresponding interface circuitry, as discussed above) . The GPS device 1216 may be in communication with a satellite-based system and may receive a location of the computing device 1200, as known in the art.
[0133] The computing device 1200 may include another output device 1210 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 1210 may include an audio codec, a video codec, a printer, a wired or wireless transmitter for providing information to other devices, or an additional storage device.
[0134] The computing device 1200 may include another input device 1220 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 1220 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.
[0135] The computing device 1200 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, an ultrabook computer, a personal digital assistant (PDA) , an ultramobile personal computer, 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, or a wearable computer system. In some embodiments, the computing device 1200 may be any other electronic device that processes data.
[0136] Select Examples
[0137] The following paragraphs provide various examples of the embodiments disclosed herein.
[0138] Example 1 provides a method for executing a tensor multiplication operation in a neural network, including storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor including weights in a first floating-point data format, the first integer weight block including data elements in a first integer data format; forming a second integer weight block based on the first integer weight block, the second integer weight block including data elements in a second integer data format; forming an expanded weight block from the second integer weight block, the expanded weight block including data elements in a third integer data format; converting the expanded weight block into a floating-point weight block, the floating-point weight block including data elements in a second floating-point data format; and executing the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.
[0139] Example 2 provides the method of example 1, in which the second integer data formation is different from the first integer data format, the third integer data format is different from the first integer data format and different from the second integer data format, a data element in the second integer weight block comprising bits in multiple data elements in the first integer weight block, and the third integer weight block is formed by inserting zeros into the second integer weight block.
[0140] Example 3 provides the method of example 1 or 2, in which the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises: generating a second sequence of bits by shifting the first sequence of bits; and forming a new weight group by combining the first sequence of bits and the second sequence of bits, wherein the second integer weight block comprises the new weight group.
[0141] Example 4 provides the method of example 3, in which: a data element in the weight group has a predetermined number of bits, and shifting the first sequence of bits comprises shifting the first sequence of bits right by the predetermined number.
[0142] Example 5 provides the method of any one of examples 1-4, in which the first integer weight block and the second integer weight block have a same number of data elements, and the second integer weight block has a larger storage size than the first integer weight block.
[0143] Example 6 provides the method of any one of examples 1-5, in which a data element in the third integer weight block includes bits in a data element in the second integer weight block and bits in one or more of the zeros inserted into the second integer weight block.
[0144] Example 7 provides the method of any one of examples 1-6, in which the first integer weight block and the floating-point weight block have a same number of data elements.
[0145] Example 8 provides the method of any one of examples 1-7, in which the second floating-point data format is different from the first floating-point data format, and the method further including storing an activation block, the activation block including activations in the first floating-point data format; and converting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.
[0146] Example 9 provides the method of any one of examples 1-8, in which the first integer weight block is generated further by: partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; and generating the first integer weight block from a single quantized weight block of the quantized weight blocks.
[0147] Example 10 provides the method of example 9, in which generating the first integer weight block includes: partitioning the single quantized weight block into a plurality of weight groups; and for each weight group of the plurality of weight groups; and modifying one or more positions of one or more data elements in the weight group.
[0148] Example 11 provides one or more non-transitory computer-readable media storing instructions executable to perform operations for execution a tensor multiplication operation in a neural network, the operations including storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor including weights in a first floating-point data format, the first integer weight block including data elements in a first integer data format; forming a second integer weight block based on the first integer weight block, the second integer weight block including data elements in a second integer data format; forming an expanded weight block from the second integer weight block, the expanded weight block including data elements in a third integer data format; converting the expanded weight block into a floating-point weight block, the floating-point weight block including data elements in a second floating-point data format; and executing the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.
[0149] Example 12 provides the one or more non-transitory computer-readable media of example 11, in which the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises: generating a second sequence of bits by shifting the first sequence of bits; and forming a new weight group by combining the first sequence of bits and the second sequence of bits, wherein the second integer weight block comprises the new weight group.
[0150] Example 13 provides the one or more non-transitory computer-readable media of example 11 or 12, in which the first integer weight block and the second integer weight block have a same number of data elements, and the second integer weight block has a larger storage size than the first integer weight block.
[0151] Example 14 provides the one or more non-transitory computer-readable media of any one of examples 11-13, in which the first integer weight block and the floating-point weight block have a same number of data elements.
[0152] Example 15 provides the one or more non-transitory computer-readable media of any one of examples 11-14, in which the second floating-point data format is different from the first floating-point data format, and the operations further include storing an activation block, the activation block including activations in the first floating-point data format; and converting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.
[0153] Example 16 provides the one or more non-transitory computer-readable media of any one of examples 11-15, in which the first integer weight block is generated further by: partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; and generating the first integer weight block from a single quantized weight block of the quantized weight blocks.
[0154] Example 17 provides an apparatus, including a computer processor for executing computer program instructions; and a non-transitory computer-readable memory storing computer program instructions executable by the computer processor to perform operations for execution a tensor multiplication operation in a neural network, the operations including storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor including weights in a first floating-point data format, the first integer weight block including data elements in a first integer data format, forming a second integer weight block based on the first integer weight block, the second integer weight block including data elements in a second integer data format, forming an expanded weight block from the second integer weight block, the expanded weight block including data elements in a third integer data format; converting the expanded weight block into a floating-point weight block, the floating-point weight block including data elements in a second floating-point data format, and executing the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.
[0155] Example 18 provides the apparatus of example 17, in which the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises: generating a second sequence of bits by shifting the first sequence of bits; and forming a new weight group by combining the first sequence of bits and the second sequence of bits, wherein the second integer weight block comprises the new weight group.
[0156] Example 19 provides the apparatus of example 17 or 18, in which the second floating-point data format is different from the first floating-point data format, and the operations further include storing an activation block, the activation block including activations in the first floating-point data format; and converting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.
[0157] Example 20 provides the apparatus of any one of examples 17-19, in which the first integer weight block is generated further by: partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; and generating the first integer weight block from a single quantized weight block of the quantized weight blocks.
[0158] 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.
Claims
1.A method for execution a tensor multiplication operation in a neural network, comprising:storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor comprising weights in a first floating-point data format, the first integer weight block comprising data elements in a first integer data format;forming a second integer weight block based on the first integer weight block, the second integer weight block comprising data elements in a second integer data format;forming a third integer weight block from the second integer weight block, the third integer weight block comprising data elements in a third integer data format;converting the third integer weight block into a floating-point weight block, the floating-point weight block comprising data elements in a second floating-point data format; andexecuting the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.2.The method of claim 1, wherein the second integer data formation is different from the first integer data format, the third integer data format is different from the first integer data format and different from the second integer data format, a data element in the second integer weight block comprising bits in multiple data elements in the first integer weight block, and the third integer weight block is formed by inserting zeros into the second integer weight block.3.The method of claim 1, wherein the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises:generating a second sequence of bits by shifting the first sequence of bits; andforming a new weight group by combining the first sequence of bits and the second sequence of bits,wherein the second integer weight block comprises the new weight group.4.The method of claim 3, wherein:a data element in the weight group has a predetermined number of bits, andshifting the first sequence of bits comprises shifting the first sequence of bits right by the predetermined number.5.The method of claim 1, wherein the first integer weight block and the second integer weight block have a same number of data elements, and the second integer weight block has a larger storage size than the first integer weight block.6.The method of claim 1, wherein a data element in the third integer weight block comprises bits in a data element in the second integer weight block and bits in one or more of the zeros inserted into the second integer weight block.7.The method of claim 1, wherein the first integer weight block and the floating-point weight block have a same number of data elements.8.The method of claim 1, wherein the second floating-point data format is different from the first floating-point data format, and the method further comprises:storing an activation block, the activation block comprising activations in the first floating-point data format; andconverting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.9.The method of claim 1, wherein the first integer weight block is generated further by:partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; andgenerating the first integer weight block from a single quantized weight block of the quantized weight blocks.10.The method of claim 9, wherein generating the first integer weight block comprises:partitioning the single quantized weight block into a plurality of weight groups; andfor each weight group of the plurality of weight groups, modifying one or more positions of one or more data elements in the weight group.11.One or more non-transitory computer-readable media storing instructions executable to perform operations for execution a tensor multiplication operation in a neural network, the operations comprising:storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor comprising weights in a first floating-point data format, the first integer weight block comprising data elements in a first integer data format;forming a second integer weight block based on the first integer weight block, the second integer weight block comprising data elements in a second integer data format;forming a third integer weight block from the second integer weight block, the third integer weight block comprising data elements in a third integer data format;converting the third integer weight block into a floating-point weight block, the floating-point weight block comprising data elements in a second floating-point data format; andexecuting the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.12.The one or more non-transitory computer-readable media of claim 11, wherein the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises:generating a second sequence of bits by shifting the first sequence of bits; andforming a new weight group by combining the first sequence of bits and the second sequence of bits, wherein the second integer weight block comprises the new weight group.13.The one or more non-transitory computer-readable media of claim 11, wherein the first integer weight block and the second integer weight block have a same number of data elements, and the second integer weight block has a larger storage size than the first integer weight block.14.The one or more non-transitory computer-readable media of claim 11, wherein the first integer weight block and the floating-point weight block have a same number of data elements.15.The one or more non-transitory computer-readable media of claim 11, wherein the second floating-point data format is different from the first floating-point data format, and the operations further comprise:storing an activation block, the activation block comprising activations in the first floating-point data format; andconverting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.16.The one or more non-transitory computer-readable media of claim 11, wherein the first integer weight block is generated further by:partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; andgenerating the first integer weight block from a single quantized weight block of the quantized weight blocks.17.An apparatus, comprising:a computer processor for executing computer program instructions; and a non-transitory computer-readable memory storing computer program instructions executable by the computer processor to perform operations for execution a tensor multiplication operation in a neural network, the operations comprising:storing a first integer weight block generated by quantizing a weight tensor of the tensor multiplication operation, the weight tensor comprising weights in a first floating-point data format, the first integer weight block comprising data elements in a first integer data format,forming a second integer weight block based on the first integer weight block, the second integer weight block comprising data elements in a second integer data format,forming a third integer weight block from the second integer weight block, the third integer weight block comprising data elements in a third integer data format,converting the third integer weight block into a floating-point weight block, the floating-point weight block comprising data elements in a second floating-point data format, andexecuting the tensor multiplication operation by multiplying the floating-point weight block with a floating-point activation block.18.The apparatus of claim 17, wherein the first integer weight block includes a plurality of weight groups, a weight group is stored as a first sequence of bits, and forming the second integer weight block based on the first integer weight block comprises:generating a second sequence of bits by shifting the first sequence of bits; andforming a new weight group by combining the first sequence of bits and the second sequence of bits, wherein the second integer weight block comprises the new weight group.19.The apparatus of claim 17, wherein the second floating-point data format is different from the first floating-point data format, and the operations further comprise:storing an activation block, the activation block comprising activations in the first floating-point data format; andconverting the activation block to the floating-point activation block by changing the first floating-point data format to the second floating-point data format.20.The apparatus of claim 17, wherein the first integer weight block is generated further by:partitioning a quantized weight tensor into quantized weight blocks, the quantized weight tensor generated by quantizing the weight tensor; andgenerating the first integer weight block from a single quantized weight block of the quantized weight blocks.
Citation Information
Patent Citations
Arithmetic unit for floating point data and tensor data operation
CN112416295A
Hybrid precision arithmetic unit for FP16 floating point data and INT8 integer data operation
CN112860218A
Neural network facilitating fixed-point emulation of floating-point computation
US20230008856A1
Hybrid multipy-accumulation operation with compressed weights
US20230229917A1
Cited By
Data operation control method and device, equipment and medium
CN121680937A
Nonlinear encoding for machine learning model quantization
WO2026193883A1
