Method and device for accelerating deep learning reasoning based on hardware perception sparsity mode

Through hardware-aware sparsity mode and software optimization technology, the weight matrix is ​​sparse by blocks, and SIMD hardware is used to accelerate the GEMM operation of DNN, which solves the problem of high computational cost of DNN and achieves significant performance gain and accuracy maintenance.

CN118696318APending Publication Date: 2024-09-24INTEL CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202280090866.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-03-04
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing deep neural networks (DNN) are difficult to efficiently accelerate in industrial deployment due to high computational costs, especially the time-consuming general matrix multiplication (GEMM) and convolution operations, and Nvidia's 2/4 sparsity mode cannot be used in Effective application on the SIMD ISA of modern CPUs and GPUs limits the potential for sparse acceleration.

Method used

Adopting hardware-aware sparsity mode, by sparsifying the weight matrix by blocks, leveraging the dense vector/matrix capabilities of SIMD hardware, combined with software optimization to achieve performance acceleration, specific methods include determining the sparsity mode based on ISA register width, and executing group-raso Regularization and magnitude pruning, generating masks to extract non-zero block elements, implementing sparse GEMM operations.

Benefits of technology

Achieving 5x to 10x performance gains without losing accuracy, significantly reducing the computational cost of deep learning inference compared to Nvidia's 1.5x speed improvement, suitable for Intel DL Boost, AMX and other SIMD ISAs .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000
    Figure 00000000_0000
Patent Text Reader

Abstract

The invention provides a method and a device for accelerating deep learning reasoning based on a hardware perception sparsity mode. The method may include determining a hardware aware sparsity mode based on a register width specified by an ISA of a hardware unit to implement a DNN for deep learning reasoning sparsity mode specifying a block size and a sparsity ratio for block-by-block sparseness of a weight matrix for operators in the DNN; during a training process of the DNN, performing block-by-block sparsification on the weight matrix based on a sparsity pattern to obtain a sparse weight matrix; compressing the sparse weight matrix into a concentrated weight matrix by removing all zero blocks from the sparse weight matrix; and generating a mask to indicate the index of each row of non-zero blocks in the sparse weight matrix, so that corresponding elements can be extracted from the activation matrix of the operator.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments described herein generally relate to deep neural networks (DNNs), and more specifically, to a method and apparatus for accelerating deep learning inference based on hardware (HW)-aware sparsity patterns. Background Art

[0002] Deep neural networks (DNNs) have improved rapidly in recent years and have achieved state-of-the-art (SOTA) accuracy for a wide variety of tasks. However, DNNs still face challenges during industrial deployment due to the high computational cost of inference. Most DNN workloads include computationally intensive operations such as general matrix multiplication (GEMM) and convolution. These operations are fundamental to DNNs and consume the most time during deep learning inference. BRIEF DESCRIPTION OF THE DRAWINGS

[0003] Various advantages of the embodiments will become apparent to those skilled in the art by reading the following description and appended claims, and by referring to the following drawings, in which:

[0004] Figure 1 Illustrate various sparsity patterns that can be applied to accelerate deep learning inference;

[0005] Figure 2 illustrates an example sparse weight matrix of K×N shape with a 4-out-of-64 sparsity pattern according to some embodiments of the present disclosure;

[0006] Figure 3 illustrates an example sparse GEMM operation between an activation matrix and a sparse weight matrix according to some embodiments of the present disclosure;

[0007] Figure 4 illustrates an example compression process for generating a concentrated weight matrix according to some embodiments of the present disclosure;

[0008] Figure 5 illustrates an example tandem activation matrix according to some embodiments of the present disclosure;

[0009] Figure 6 illustrates an example sparse GEMM operation based on dot products between a concatenated activation matrix and corresponding non-zero blocks in a sparse weight matrix according to some embodiments of the present disclosure;

[0010] Figure 7illustrates an example process for implementing a sparse GEMM using the SVE ISA according to some embodiments of the present disclosure;

[0011] Figure 8 The block diagram illustrates components capable of reading instructions from a machine-readable or computer-readable medium and performing any one or more of the methods discussed herein, according to some example embodiments;

[0012] Fig. 9 is a block diagram of an example processor platform according to some embodiments of the present disclosure; and

[0013] Fig.10 An example flow chart of a process for accelerating deep learning inference based on hardware-aware sparsity patterns according to some embodiments of the present disclosure is illustrated. DETAILED DESCRIPTION

[0014] The various aspects of the illustrative embodiments will be described using terms that are commonly used by those skilled in the art to convey the essence of the present disclosure to other persons skilled in the art. However, it will be appreciated by those skilled in the art that many alternative embodiments may also be implemented using some parts of the described aspects. For illustration, specific numbers, materials, and configurations are recorded to provide a thorough understanding of the illustrative embodiments. However, it will be clear to those skilled in the art that alternative embodiments may also be implemented without these specific details. In other cases, known features may be omitted or simplified to avoid blurring the illustrative embodiments.

[0015] In addition, various operations will be described as multiple discrete operations in turn in a manner that is most helpful for understanding the illustrative embodiments; however, the order of description should not be interpreted as meaning that these operations are necessarily order-dependent. In particular, these operations do not need to be performed in the order presented.

[0016] Although DNNs have rapidly improved in a wide variety of computing tasks in recent years, they still face challenges during industrial deployment due to their high computational cost of inference. Most DNN workloads include computationally intensive operations such as GEMM and convolution, which are the foundation of DNNs and consume the most time during deep learning inference.

[0017] Sparsification is a promising optimization technique to reduce the computational cost and memory usage of deep learning workloads. In general, a sparse matrix or sparse tensor is a matrix whose elements are mostly zero.

[0018] In recent years, academia and industry have made a lot of efforts in sparsification or compression, and the sparsity pattern is the key to sparsification. For example, Nvidia introduced sparsity hardware in the Ampere architecture (e.g., A100). With the help of sparsity hardware, the 2-in-4 structured sparsity pattern was successfully applied to a typical deep learning model, and the overall performance gain was about 1.5 times, while the accuracy loss was kept within 1%. In addition, some other works focus more on unstructured sparsity patterns.

[0019] Figure 1 The figure shows various sparsity patterns that can be applied to accelerate deep learning inference. Specifically, Figure 1 As shown, sparsity mode (a) is an element-by-element sparsity mode, sparsity mode (b) is a 2 / 4 structured sparsity mode introduced by Nvidia, sparsity mode (c) is a block-by-block sparsity mode, and sparsity mode (d) is a channel-by-channel sparsity mode.

[0020] In general, the more structured the sparsity pattern is, the smaller the accuracy loss caused by the sparsity pattern is, and the higher the performance gain is. Therefore, it is a trade-off between sparsity ratio, accuracy, and performance. As mentioned above, Nvidia's 2 / 4 sparsity pattern may be a successful solution, which means that the matrix is ​​divided into many 1×4 vectors, and for each vector, there are always 2 zeros and 2 non-zeros. Nvidia's solution is more structured than element-wise sparsity, which means that with specific hardware support, Artificial Intelligence (AI) applications can achieve 1.3x-1.5x speed improvement, while the sparsity pattern is unstructured enough to maintain accuracy.

[0021] However, it is clear that Nvidia’s solution cannot be applied to most existing modern Single Instruction Multiple Data (SIMD) instruction set architectures (ISAs) on central processing units (CPUs) and graphics processing units (GPUs), including those from the 2nd generation Scalable Processors and AMD EPYC TM The AVX-X series ISA (AVX2, AVX512, AVX512VNNI) introduced by the processor, starting from the 4th generation Scalable processors introduced Advanced Matrix Extension (AMX), from DP4A / XMX introduced by Xe GPU, and NEON / SVE introduced by ARM. On the other hand, the 2 / 4 sparsity mode sets a maximum limit for the sparsity ratio, and thus sets an upper limit for the sparsification acceleration. In addition, Nvidia's solution cannot fully utilize the capabilities of the general-purpose SIMD ISA, which is usually designed for intensive operations.

[0022] In the absence of native sparsity hardware support, when implementing DNNs for deep learning inference on hardware units with existing modern SIMD ISA, relying on software optimization to achieve performance gains based on reasonable sparsity ratios may be a solution. For example, oneAPI Math Kernel Library (oneMKL) can accelerate GEMM calculations at extremely high sparsity ratios greater than 99%.

[0023] In this disclosure, based on sparsification and kernel optimization methods, a general HW-aware sparsity pattern for hardware units with SIMD capabilities is proposed, which can fully utilize existing dense vector / matrix hardware capabilities to achieve promising performance acceleration by using only software solutions. The granularity of the sparsity pattern can well maintain accuracy and bring much better performance gain (e.g., 5x to 10x) at the kernel level compared to 1.5x obtained by Nvidia using its A100 hardware solution.

[0024] This approach can be used to accelerate deep learning inference on hardware ISAs such as Intel DL Boost (including 2nd Gen VNNI, the next generation of scalable processors AMX on scalable processors, and more SIMD ISAs from ARM, AMD or Nvidia. These SIMD ISAs are all based on fixed register lengths. For example, VNNI provides INT8 registers organized in a 4x16 register shape, AMX provides BF16 registers with a 16x32 shape and INT8 registers with a 16x64 shape, and NEON from ARM provides uint8 vectors with a 1x16 shape. It is necessary and possible to design a sparse solution to fully utilize these advanced ISA capabilities.

[0025] According to some embodiments of the present disclosure, a HW-aware sparsity mode may first be determined based on the register width specified by the ISA of a hardware unit used to implement a DNN for deep learning inference. The sparsity mode may specify a block size and sparsity ratio for block-wise sparsification of weight matrices of operators in the DNN. Taking the AVX512ISA introduced by the scalable processor as an example, the AVX512 ISA specifies a 512-bit register width, and for the FP32 data type, the AVX512 ISA provides a vector with a register shape of 1×16. In this case, the sparsity mode may specify a block size of 1×16, and the weight matrix may be divided into many 1×16 blocks, and each block may contain all zeros or non-zero elements. Blocks containing all zeros may be referred to as all-zero blocks, and blocks containing non-zero elements may be referred to as non-zero blocks. The sparsity ratio may be defined as the number of all-zero blocks divided by the total number of blocks in the matrix.

[0026] Among all the more general sparsity modes that specify a block size of 1×16, a specific 4-in-64 sparsity mode designed for VNNI is first introduced as an example. Figure 2 An example sparse weight matrix of K×N shape with a 4 / 64 sparsity pattern is illustrated according to some embodiments of the present disclosure. For example, assume that the shape of the weight matrix B is K×N, where K is the height of the weight matrix or the number of input channels of the linear layer in the DNN, and N is the width of the weight matrix or the number of output channels of the linear layer. When performing deep learning inference with a DNN, the weight matrix can be multiplied by an input matrix (also referred to herein as an activation matrix), which has a shape of M×K, where M is the height of the input matrix or the batch size.

[0027] Note that in this disclosure, the description of the proposed optimization method focuses on the inference of the linear layer in the DNN, which basically involves the GEMM operation between the input matrix / tensor A and the weight matrix B. For the GEMM operation, the weight matrix B can be trained to a sparse weight matrix with a sparsity pattern based on the HW-aware sparsity pattern during the training process of the DNN. It should be understood that the proposed optimization method can also be easily adopted for the convolution operation after the img2col operation used to transform the convolution operation into a GEMM operation.

[0028] like Figure 2As shown, a 4 / 64 sparsity mode can be designed for AVX512VNNI of INT8 data type. AVX512VNNI provides INT8 data vectors with a register shape of 4x16. Therefore, the sparsity mode can specify a block size of 1×16 and a sparsity ratio of 4 / 64. For example, assuming that K and N can be divided by 64 and 16 respectively (filled if necessary), that is, k=K / 64, n=N / 16, then the weight matrix can be divided into k×n large blocks. In each large block, there are 60 all-zero 1×16 blocks and 4 non-zero blocks, and the shape of each block is 1×16. In other words, the weight matrix can be divided into many 1×16 blocks, 4 of every 64 blocks are non-zero blocks, and 60 of the 64 blocks are all-zero blocks.

[0029] Figure 3 FIG. 4 illustrates an example sparse GEMM operation between an activation matrix and a sparse weight matrix according to some embodiments of the present disclosure. Figure 3 As shown, the activation matrix is ​​a dense matrix, and the weight matrix is ​​a sparse matrix with a HW-aware sparsity pattern. According to some embodiments of the present disclosure, in order to fully utilize the existing dense vector / matrix hardware capabilities, the sparse weight matrix can be compressed into a concentrated weight matrix for deep learning inference by removing all-zero blocks from the sparse weight matrix.

[0030] Figure 4 An example compression process for generating a concentrated weight matrix according to some embodiments of the present disclosure is illustrated. Figure 4 As shown, only four 1×16 non-zero blocks out of every sixty-four 1×16 blocks in the weight matrix are retained in the concentrated weight matrix. At the same time, a mask can be generated to indicate the index of each row of non-zero blocks in the sparse weight matrix so that the corresponding elements can be extracted from the activation matrix of the operator during deep learning inference. Note that the compression process can be performed only once before inference.

[0031] With the mask indicating the index of each row of non-zero blocks in the sparse weight matrix, when performing the GEMM operation for inference, the elements in the activation matrix can be loaded first, and then the elements corresponding to the non-zero blocks of the sparse weight matrix can be extracted from the activation matrix based on the mask.

[0032] For example, for Figure 3In the GEMM operation, since the large blocks in the weight matrix are of shape 64×16, for the first row, 64 elements can be loaded at once, which just fit into one cache line of a single AVX512 intrinsic function A=_mm512_load_epi32(memory_addr_of_row_head) to obtain a vector A including 64 elements, and then the 4 elements corresponding to the non-zero blocks of the sparse weight matrix can be extracted in another single AVX512 intrinsic function A_extracted=_mm512_maskz_compress_epi8(mask,A) to obtain a vector A_extracted including 4 elements. Note that the intrinsic function _mm512_maskz_compress_epi8 is a new intrinsic function introduced by AVX512-VBMI2 as one of the new features of the 3rd generation Xeon scalable processors.

[0033] To align with the register width of the VNNI, the extracted elements may be broadcasted to generate a concatenated activation matrix. Figure 5 An example cascade activation matrix is ​​illustrated according to some embodiments of the present disclosure. Figure 5 As shown, the four extracted elements can be spread to generate a 1×64 concatenated activation matrix containing 16 copies of the four extracted elements. When performing inference, the GEMM operation between the activation matrix and the weight matrix can be easily and efficiently implemented by calculating the dot product between the concatenated activation matrix obtained as described above and the corresponding non-zero blocks in the sparse weight matrix. For example, the dot product can be performed in a single AVX512VNNI built-in function _mm512_dpbusds_epi32().

[0034] Figure 6 An example sparse GEMM operation based on the dot product between the concatenated activation matrix and the corresponding non-zero blocks in the sparse weight matrix is ​​illustrated in accordance with some embodiments of the present disclosure. Figure 6 As shown, the dot product between the 1×64 concatenated activation matrix and the corresponding non-zero block in the weight matrix can be easily and efficiently calculated via a single AVX512VNNI built-in function _mm512_dpbusds_epi32(). In the same way, the next 1×64 concatenated activation matrices corresponding to other non-zero blocks in the weight matrix can be generated in sequence. Therefore, the dot products between these concatenated activation matrices and their corresponding non-zero blocks in the weight matrix can be calculated to obtain respective dot product results, and these results can be added to the same position.

[0035] As described above, in the present disclosure, an optimization process for accelerating deep learning inference based on HW-aware sparsity patterns is proposed. In general, the process may include the following operations: based on the register width specified by the ISA of the hardware unit for implementing the DNN for deep learning inference, determining the HW-aware sparsity pattern, wherein the sparsity pattern specifies the block size and sparsity ratio of the block-wise sparsification of the weight matrix of the operator in the DNN; during the training process of the DNN according to the training data set received via the interface circuit, performing block-wise sparsification for the weight matrix based on the sparsity pattern to obtain a sparse weight matrix; by removing all-zero blocks from the sparse weight matrix, compressing the sparse weight matrix into a concentrated weight matrix for deep learning inference; and generating a mask to indicate the index of each row of non-zero blocks in the sparse weight matrix, so that the corresponding elements can be extracted from the activation matrix of the operator during deep learning inference.

[0036] Among these operations, the determination of HW-aware sparsity patterns, the compression of sparse weight matrices and the generation of masks have been described above. Figures 1 to 6 Next, the block-wise sparsification based on the sparsity pattern will be described with reference to the pseudo code in Table 1, which shows the updated training process.

[0037]

[0038] Table 1 Updated training process

[0039] The training procedure in Table 1 is based on the typical training procedure for DNNs and is updated by adding a function for block-wise sparsification based on the sparsity mode. L1 normalization can be used to regularize the gradients so that the weight matrix tends to adopt a certain sparse format. Note that according to the sparsity ratio specified by the sparsity mode, during the training process, the gradients should be calculated according to the formula new = gradients origin +data×ratio sparse To update the gradient of the elements in the weight matrix.

[0040] In Table 1, the added functions for block-wise sparsification are shown in bold. First, the group-lasso algorithm is used in the group_lasso_regularize function. The core idea of ​​the group-lasso algorithm is to divide the weight matrix into multiple blocks with a block size specified by the sparsity pattern, and apply L2 normalization to each block and L1 normalization between different blocks, so as to generate a sparse solution according to the sparsity pattern. Assuming that the total number of elements in the weight matrix is ​​N, the weight matrix is ​​divided into K blocks, each block contains M elements, then N=K×M. The formula for group-lasso regularization is as follows:

[0041]

[0042] In this formula, N represents the total number of elements in the weight matrix, and J represents the number of blocks in the weight matrix. According to this formula, it can be seen that the group-lasso regularization is based on ridge regression, which is actually a combination of linear regression and L2 norm constraint for minimizing the cost function.

[0043] In other words, the group_lasso_regularize function applies the group-lasso algorithm to the weight matrix based on a predetermined sparsity pattern to perform regularization according to the above formula, thereby generating a preliminary sparse weight matrix. Specifically, if the weight matrix is ​​not a two-dimensional matrix, the weight matrix needs to be reshaped into a two-dimensional matrix first. Then, according to the above formula for group-lasso, the elements in the weight matrix can be divided into blocks of block size (e.g., 1×16). Assuming that the shape of the weight matrix is ​​[m,n], the weight matrix can be reshaped into [m / BlockSize[0], BlockSize[0], n / BlockSize[1], BlockSize[1]]. For example, the torch.norm function can be used to perform L2 regularization calculation on the [1,3] dimension, and then the torch.repeat_interleave function can be used to expand the elements on the missing dimensions. Finally, the calculated group lasso regularization term value is added to the gradient of the parameter.

[0044] As mentioned above, group-Lasso regularization can be used to generate a preliminary sparse weight matrix, which means that some elements in the weight matrix that should be zero according to the predetermined sparsity pattern may be trained to have very low values, but still not zero. In other words, group-Lasso regularization cannot guarantee that the generated sparse weight matrix fully satisfies the required sparsity pattern.

[0045] In view of this problem, a block-based magnitude pruning process can be applied to the preliminary sparse weight matrix to determine whether a block in the weight matrix should be set to an all-zero block based on some kind of normalization value. For example, an L2 norm constraint can be used. In the training process shown in Table 1, the prune_weights_with_magnitude function can be used to prune the elements in the preliminary sparse weight matrix according to the block-based magnitude, thereby obtaining a sparse weight matrix with a required sparsity pattern.

[0046] In some embodiments, the prune_weights_with_magnitude function may determine whether the value of an element in a block in the preliminary sparse weight matrix is ​​less than a preset threshold, and set the block to an all-zero block when the value of the element in the block is less than the preset threshold.

[0047] Alternatively, the prune_weights_with_magnitude function can determine the number of all-zero blocks K in the sparse weight matrix based on the sparsity pattern and the shape of the weight matrix, select K blocks containing elements with the smallest values ​​among all blocks in the weight matrix, and set these K blocks to all-zero blocks. For example, for a general sparsity pattern that specifies a block size of 1×16, if the shape of the weight matrix is ​​[m,n], then The block with the minimum value The blocks are set to all zero blocks. However, for a specific 4 / 64 sparsity pattern, the weight matrix can be divided into sub-matrices, and for each sub-matrix, the 60 blocks with minimum values ​​can be set to all-zero blocks.

[0048] In addition, the training process in Table 1 may further include a prune_gradient_with_magnitude function, which may be used to prune the gradients of elements in each block of the weight matrix during the training process, so that when the values ​​of the elements in a block of the weight matrix have been trained to be zero, the gradients of the elements in the block are set to zero. Specifically, if the values ​​of the elements in a particular block have been trained to be zero in a certain round of the training process, the gradients of the elements in the block may be set to zero. This function may be applied to prevent some all-zero blocks obtained in previous rounds of the training process from becoming non-zero blocks in later rounds of the training process due to gradient updates (e.g., Stochastic Gradient Descent (SGD)).

[0049] Therefore, according to the updated training process in Table 1, block-wise sparsification can be achieved by combining group-lasso regularization and magnitude pruning. Therefore, the training process can generate a sparse weight matrix with a predetermined HW-aware sparsity pattern.

[0050] Furthermore, it should be appreciated that the proposed optimization method can be easily applied to more SIMD ISAs. Table 2 shows a summary of Intel's advanced ISA.

[0051]

[0052]

[0053] Table 2 Summary of Intel's advanced ISA

[0054] As shown in Table 2, the vector width of all these ISAs is 16, so the block size of all these ISAs can be set to 1×16, and the above block-wise sparsification and compression process can be easily applied to these ISAs. However, it should be noted that the register shapes of these ISAs and different data types may not be the same, so the sparsity ratio may also be different. In summary, when the register shape is N×M, the block size should be 1×M, and the sparsity ratio should be preset so that the number of non-zero blocks in the sparse weight matrix is ​​an integer multiple of N. In this way, a hardware-aware sparsity pattern can be determined to specify the block size and sparsity ratio, and the above block-wise sparsification and compression process based on the determined sparsity pattern can be similarly applied to these ISAs. In addition, the 4 / 64 sparsity pattern of VNNI can be generalized to the L / N pattern, and the sparsity ratio is equal to (LN) divided by L, and L is an integer determined according to the length of the cache line specified by the ISA.

[0055] In addition, the proposed optimization method can also be applied to more SIMD ISAs, such as Tile Matrix Multiply Unit (TMUL), NEON, and Scalable Vector Extension (SVE). For the specific 4 / 64 sparsity mode, in fact, "4" is determined according to the register width of VNNI, and "64" is determined according to the length of the cache line. But for more general workloads, it may not be possible to train the weight matrix with this mode. For example, the register shape of TMUL is 32×16 (for bfloat16) and 64×16 (for int8), so 32 1×16 blocks cannot be concentrated in one cache line, but the general sparsity mode specifying a block size of 1×16 can still be used. The above operations for the 4 / 64 mode can be similarly used for TMUL to implement a 1×16 sparse GEMM. Specifically, the weight matrix can be pre-compressed so that the weights are stored continuously in the memory and the relevant masks are obtained. For example, if there are x 1×16 non-zero blocks, then a compressed weight tensor of shape x×16 and the associated x mask indices can be generated. However, it may not be possible to load the associated elements in the activation tensor in one load, so the load operation can be looped and then the elements can be lumped together. In addition, padding may be required if the number of elements is not divisible by the required register width (e.g. 32 for AMX bfloat16). Therefore, the compressed weights and selected activation elements in 32×16 mode can be obtained, and both tensors can be fed into the AMX tile calculation.

[0056] NEON is the SIMD ISA introduced by ARM on its v6 design. NEON has a 128-bit register width, which enables dot product capabilities for 1x4 FP32 vectors or 1x16 UINT8 vectors. SIMD registers are organized as vectors, so it may not be necessary to concentrate non-zero blocks in the GEMM kernel. For FP32 NEON, sparse weight matrices can be trained by using the above-mentioned block-wise sparsification process, using a sparsity mode that specifies a block size of 1×4. As with AVX 512, the weight matrix can be divided into 1×4 blocks. These blocks may be all-zero blocks, or contain non-zero elements, and then a compression process can be applied to keep only the non-zero blocks. Non-zero blocks can be dot-producted with the associated activation elements.

[0057] SVE is a new SIMD ISA introduced by ARM in conjunction with its v8.2 design, but as expected, will be adopted by more silicon designs of ARM-V9. The key feature of SVE is the configurable SIMD register width, up to 2048 bits, or 256 UINT8. Obviously, it is difficult to train sparse weight matrices using the sparsity mode that specifies a block size of 1×256, however, centralized built-in functions can be used to concatenate elements from different vectors, so sparse GEMM can be implemented based on the sparsity mode that specifies a block size of 1×4. Figure 7 FIG. 4 illustrates an example process for implementing a sparse GEMM using the SVE ISA according to some embodiments of the present disclosure. Figure 7 As shown, the weight matrix can be divided into many 1×4 blocks, the non-zero blocks in the trained sparse weight matrix can be compressed into a dense concentrated weight matrix, the corresponding activation elements from the activation matrix can be extracted and collected to generate a concatenated activation matrix, and the dot product between the concentrated weight matrix and the concatenated activation matrix can be calculated. Note that gather-load is one of the key features from SVE, which is different from NEON, and can be used to generate a concatenated activation matrix.

[0058] Note that according to the sparsity mode proposed in the present disclosure, the block size is aligned with the register width in one dimension, so the contraction of the extracted activation elements can be performed in another dimension. In this way, the advanced ISA capabilities can be fully utilized and the computational efficiency can be improved.

[0059] Regarding the proposed optimization method, experimental results will be provided using Tables 3 to 6 to demonstrate the benefits of the optimization. For example, during the MLPerf1.1 inference challenge, a sparse deep learning recommendation model (DLRM) using the proposed method was tested, which can bring more than 50% performance gain relative to dense results. Table 3 shows the performance and accuracy of the submitted DLRM. It can be seen that sparsification not only brings performance gains, but also maintains accuracy. For the fp32 sparse model, the accuracy is even higher, which may be the effect of pruning; for the int8 sparse model, the accuracy drop is also within 0.5%, or 99.5% of the baseline. In Table 3, QPS refers to the number of queries per second.

[0060]

[0061] Table 3 Measurement results of sparse DLRM of MLPerf1.1

[0062] Furthermore, as shown in Tables 4 and 5, sparsification also shows performance gains relative to prediction for more HW and more workloads.

[0063]

[0064]

[0065] Table 4 Prediction results of BERT on SPR (BS=64)

[0066]

[0067] Table 5 Prediction results of BERT on PVC (BS=128)

[0068]

[0069]

[0070] Table 6 Prediction results of DLRM on SPR (BS=32768)

[0071] Figure 8 The block diagram of illustrates components capable of reading instructions from a machine-readable or computer-readable medium (e.g., a non-transitory machine-readable storage medium) and executing any one or more of the methods discussed herein according to some example embodiments. Specifically, Figure 8A diagrammatic representation of hardware resources 800 is shown, including one or more processors (or processor cores) 810, one or more memory / storage devices 820, and one or more communication resources 830, each of which may be communicatively coupled via a bus 840. For embodiments utilizing node virtualization (e.g., NFV), a hypervisor 802 may be executed to provide an execution environment for one or more network slices / sub-slices utilizing the hardware resources 800.

[0072] Processor 810 may include, for example, processor 812 and processor 814, and processor 512 and processor 514 may be, for example, a central processing unit (CPU), a graphics processing unit (GPU), a tensor processing unit (TPU), a visual processing unit (VPU), a field programmable gate array (FPGA), or any appropriate combination of these.

[0073] The memory / storage device 820 may include main memory, disk storage, or any suitable combination of these. The memory / storage device 820 may include, but is not limited to, any type of volatile or non-volatile memory, such as dynamic random access memory (DRAM), static random access memory (SRAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory, solid-state storage, etc.

[0074] The communication resources 830 may include an interconnect or network interface component or other appropriate device to communicate with one or more peripheral devices 804 or one or more databases 806 via the network 808. For example, the communication resources 830 may include a wired communication component (e.g., for coupling via a Universal Serial Bus (USB)), a cellular communication component, an NFC component, Components (e.g., low energy ), components, and other communication components.

[0075] The instructions 850 may include software, programs, applications, applet programs, apps, or other executable code for causing at least any one of the processors 810 to perform any one or more of the methods discussed herein. The instructions 850 may reside in whole or in part within at least one of the processors 810 (e.g., within a cache memory of the processor), within the memory / storage device 820, or any suitable combination of these. In addition, any portion of the instructions 850 may be transferred to the hardware resources 800 from any combination of the peripheral devices 804 or the database 806. Thus, the memory of the processor 810, the memory / storage device 820, the peripheral devices 804, and the database 806 are examples of computer-readable and machine-readable media.

[0076] Fig. 9 900 is a block diagram of an example processor platform according to some embodiments of the present disclosure. The processor platform 900 may be, for example, a server, a personal computer, a workstation, a self-learning machine (e.g., a neural network), a mobile device (e.g., a cellular phone, a smart phone, an iPad, etc.), or a processor platform. TM ), a personal digital assistant (PDA), an Internet appliance, a DVD player, a CD player, a digital video recorder, a Blu-ray player, a game console, a personal video recorder, a set-top box, headphones or other wearable device, or any other type of computing device.

[0077] The processor platform 900 of the illustrated example includes a processor 912. The processor 912 of the illustrated example is hardware. For example, the processor 912 can be implemented by one or more integrated circuits, logic circuits, microprocessors, GPUs, DSPs, or controllers from any desired family or manufacturer. The hardware processor can be a semiconductor-based (e.g., silicon-based) device. In some embodiments, the processor implements one or more of the methods or processes described above.

[0078] The processor 912 of the illustrated example includes a local memory 913 (e.g., cache). The processor 912 of the illustrated example communicates with a main memory including a volatile memory 914 and a non-volatile memory 916 via a bus 918. The volatile memory 914 may be a synchronous dynamic random access memory (Synchronous Dynamic Random Access Memory, SDRAM), a dynamic random access memory (Dynamic Random Access Memory, DRAM), Dynamic Random Access Memory (DRAM) Dynamic Random Access Memory, ) and / or any other type of random access memory device. The non-volatile memory 916 can be implemented by flash memory and / or any other desired type of memory device. Access to the main memory 914, 916 is controlled by a memory controller.

[0079] The processor platform 900 of the illustrated example further includes an interface circuit 920. The interface circuit 920 may be implemented by any type of interface standard, such as an Ethernet interface, a universal serial bus (USB), interface, a near field communication (NFC) interface, and / or a PCI Express interface.

[0080] In the illustrated example, one or more input devices 922 are connected to the interface circuit 920. The input device(s) 922 allow a user to enter data and / or commands into the processor 912. The input device(s) may be implemented by, for example, an audio sensor, a microphone, a camera (still or video), a keyboard, buttons, a mouse, a touch screen, a trackpad, a trackball, and / or a voice recognition system.

[0081] One or more output devices 924 are also connected to the interface circuit 920 of the illustrated example. The output device 924 can be implemented, for example, by a display device (e.g., a light emitting diode (LED), an organic light emitting diode (OLED), a liquid crystal display (LCD), a cathode ray tube display (CRT), an in-place switching (IPS) display, a touch screen, etc.), a tactile output device, a printer, and / or a speaker. The interface circuit 920 of the illustrated example thus typically includes a graphics driver card, a graphics driver chip, and / or a graphics driver processor.

[0082] The interface circuitry 920 of the illustrated example also includes communication devices, such as transmitters, receivers, transceivers, modems, residential gateways, wireless access points, and / or network interfaces, to facilitate data exchange with external machines (e.g., any kind of computing device) via a network 926. Communications may be via, for example, an Ethernet connection, a digital subscriber line (DSL) connection, a telephone line connection, a coaxial cable system, a satellite system, a line-of-sight wireless system, a cellular telephone system, and the like.

[0083] For example, interface circuit 920 may include a training data set input through input device(s) 922 or retrieved from network 926 .

[0084] The processor platform 900 of the illustrated example also includes one or more mass storage devices 928 for storing software and / or data. Examples of such mass storage devices 928 include floppy disk drives, hard disk drives, compact disk drives, Blu-ray disk drives, redundant array of independent disks (RAID) systems, and digital versatile disk (DVD) drives.

[0085] The machine-executable instructions 932 may be stored in the mass storage device 928, in the volatile memory 914, in the non-volatile memory 916, and / or on a removable, non-transitory computer-readable storage medium such as a CD or DVD.

[0086] Fig.10 An example flow chart of a process for accelerating deep learning inference based on hardware-aware sparsity patterns according to some embodiments of the present disclosure is illustrated. The process may be implemented by a processor circuit and may include operations 1010 to 1040.

[0087] At operation 1010, a processor circuit may determine a hardware-aware sparsity mode based on a register width specified by an ISA of a hardware unit for implementing a DNN for deep learning inference, the sparsity mode specifying a block size and a sparsity ratio for block-wise sparsification of weight matrices for operators in the DNN.

[0088] According to some embodiments of the present disclosure, the block size and the sparsity ratio may be preset according to a register shape determined by the register width and the data type of the elements in the weight matrix, and block-wise sparsification may be to divide the weight matrix into blocks of the block size and set a subset of the blocks to all-zero blocks according to the sparsity ratio.

[0089] According to some embodiments of the present disclosure, when the register shape is N×M, the block size may be 1×M, and the number of non-zero blocks in the sparse weight matrix may be an integer multiple of N, where N and M are integers determined by the register width and the data type of the elements in the weight matrix.

[0090] According to some embodiments of the present disclosure, the sparsity pattern may be an L-over-N pattern, and the sparsity ratio may be equal to (LN) divided by L, where L is an integer determined according to the length of a cache line specified by an ISA. In a specific embodiment, the register shape may be 4×16, and the sparsity pattern may be a 4-over-64 pattern.

[0091] At operation 1020 , the processor circuit may perform block-wise sparsification on the weight matrix based on the sparsity pattern during the training process of the DNN to obtain a sparse weight matrix.

[0092] According to some embodiments of the present disclosure, performing block-wise sparsification may include performing group-Lasso regularization on a weight matrix based on a hardware-aware sparsity pattern to generate a preliminary sparse weight matrix; and pruning elements in the preliminary sparse weight matrix according to block-based magnitudes to obtain a sparse weight matrix.

[0093] According to some embodiments of the present disclosure, pruning elements in a preliminary sparse weight matrix according to block-based magnitudes may include: determining whether the value of an element in a block in the preliminary sparse weight matrix is ​​less than a preset threshold; and when the value of an element in the block is less than the preset threshold, setting the block to an all-zero block.

[0094] According to some embodiments of the present disclosure, pruning elements in a preliminary sparse weight matrix according to block-based magnitudes may include: determining the number K of all-zero blocks in the sparse weight matrix according to the sparsity pattern and the shape of the weight matrix; selecting K blocks containing elements with minimum values ​​among all blocks in the weight matrix; and setting the K blocks to all-zero blocks, where K is an integer greater than 0.

[0095] According to some embodiments of the present disclosure, when the register shape specified by the ISA is N×M, the block size may be 1×M, the sparsity mode is an L / N mode, the sparsity ratio is equal to (LN) divided by L, and pruning the elements in the preliminary sparse weight matrix according to the block-based magnitude may include: selecting (LN) blocks containing elements with minimum values ​​among every L blocks in the weight matrix; and setting the (LN) blocks to all-zero blocks, wherein N and M are integers determined by the register width and the data type of the elements in the weight matrix, and L is an integer determined according to the length of the cache line specified by the ISA.

[0096] According to some embodiments of the present disclosure, the processor circuit may prune the gradients of elements in each block of the weight matrix during the training process to set the gradients of the elements in a block of the weight matrix to zero when the values ​​of the elements in the block have been trained to zero.

[0097] At operation 1030 , the processor circuit may compress the sparse weight matrix into a concentrated weight matrix for deep learning inference by removing all-zero blocks from the sparse weight matrix.

[0098] At operation 1040 , the processor circuit may generate a mask to indicate the index of each row of non-zero blocks in the sparse weight matrix to enable extraction of corresponding elements from the activation matrix of the operator during deep learning inference.

[0099] According to some embodiments of the present disclosure, a processor circuit may extract elements corresponding to non-zero blocks of a sparse weight matrix from an activation matrix based on a mask, spread the extracted elements to generate a concatenated activation matrix aligned with a register width, and apply the concatenated activation matrix and the lumped weight matrix to an operator to perform DNN-based deep learning inference.

[0100] According to some embodiments of the present disclosure, the ISA may include any SIMD ISA that can be used to implement a DNN to perform deep learning inference.

[0101] According to some embodiments of the present disclosure, the operator may include GEMM or convolution.

[0102] Additional notes and examples:

[0103] Example 1 includes an apparatus for a deep neural network (DNN), the apparatus comprising: an interface circuit; and a processor circuit coupled to the interface circuit and configured to: determine a hardware-aware sparsity pattern based on a register width specified by an instruction set architecture (ISA) of a hardware unit for implementing the DNN for deep learning inference, the sparsity pattern specifying a block size and a sparsity ratio for block-wise sparsification of a weight matrix of an operator in the DNN; perform the block-wise sparsification for the weight matrix based on the sparsity pattern during a training process of the DNN according to a training data set received via the interface circuit to obtain a sparse weight matrix; compress the sparse weight matrix into a lumped weight matrix by removing all-zero blocks from the sparse weight matrix; and generate a mask to indicate the index of each row of non-zero blocks in the sparse weight matrix so that corresponding elements can be extracted from an activation matrix of the operator during the deep learning inference.

[0104] Example 2 includes an apparatus as described in Example 1, wherein the block size and the sparsity ratio are preset according to a register shape determined by the register width and the data type of the elements in the weight matrix, and the block-wise sparsification is to divide the weight matrix into blocks of the block size and set a subset of the blocks to the all-zero blocks according to the sparsity ratio.

[0105] Example 3 includes an apparatus as described in Example 1 or 2, wherein, when the register shape is N×M, the block size is 1×M, and the number of non-zero blocks in the sparse weight matrix is ​​an integer multiple of N, where N and M are integers determined by the register width and the data type of the elements in the weight matrix.

[0106] Example 4 includes an apparatus as described in any of Examples 1 to 3, wherein the sparsity pattern is an L-over-N pattern, the sparsity ratio is equal to (LN) divided by L, and L is an integer determined based on the length of the cache line specified by the ISA.

[0107] Example 5 includes the apparatus of any of Examples 1 to 4, wherein the register shape is 4×16 and the sparsity mode is a 4-in-64 mode.

[0108] Example 6 includes an apparatus as described in any one of Examples 1 to 5, wherein the processor circuit is configured to perform the block-wise sparsification by: performing group-lasso regularization on the weight matrix based on the hardware-aware sparsity pattern to generate a preliminary sparse weight matrix; and pruning elements in the preliminary sparse weight matrix according to block-based magnitudes to obtain the sparse weight matrix.

[0109] Example 7 includes an apparatus as described in any one of Examples 1 to 6, wherein pruning the elements in the preliminary sparse weight matrix according to the block-based magnitude includes: determining whether the value of an element in a block in the preliminary sparse weight matrix is ​​less than a preset threshold; and when the value of the element in the block is less than the preset threshold, setting the block to an all-zero block.

[0110] Example 8 includes an apparatus as described in any one of Examples 1 to 7, wherein pruning the elements in the preliminary sparse weight matrix based on block-based magnitudes includes: determining the number K of all-zero blocks in the sparse weight matrix based on the sparsity pattern and the shape of the weight matrix; selecting K blocks containing elements with minimum values ​​from all blocks in the weight matrix; and setting the K blocks to the all-zero blocks, wherein K is an integer greater than 0.

[0111] Example 9 includes an apparatus as described in any one of Examples 1 to 8, wherein, when the register shape specified by the ISA is N×M, the block size is 1×M, the sparsity mode is an L-over-N mode, the sparsity ratio is equal to (LN) divided by L, and the pruning of elements in the preliminary sparse weight matrix based on block-based magnitudes includes: selecting (LN) blocks containing elements with minimum values ​​among each L blocks in the weight matrix; and setting the (LN) blocks to the all-zero blocks, wherein N and M are integers determined by the register width and the data type of the elements in the weight matrix, and L is an integer determined according to the length of a cache line specified by the ISA.

[0112] Example 10 includes an apparatus as described in any one of Examples 1 to 9, wherein the processor circuit is further configured to prune the gradients of the elements in each block of the weight matrix during the training process to set the gradients of the elements in a block of the weight matrix to zero when the values ​​of the elements in the block have been trained to zero.

[0113] Example 11 includes an apparatus as described in any one of Examples 1 to 10, wherein the processor circuit is further configured to: extract elements corresponding to non-zero blocks of the sparse weight matrix from the activation matrix based on the mask; spread the extracted elements to generate a concatenated activation matrix aligned with the register width; and apply the concatenated activation matrix and the lumped weight matrix to the operator to perform the deep learning inference based on the DNN.

[0114] Example 12 includes the apparatus of any of Examples 1 to 11, wherein the ISA comprises any single instruction multiple data (SIMD) ISA usable to implement the DNN to perform the deep learning inference.

[0115] Example 13 includes the apparatus of any one of Examples 1 to 12, wherein the operator comprises a general matrix multiplication (GEMM) or a convolution.

[0116] Example 14 includes a method for a deep neural network (DNN), the method comprising: determining a hardware-aware sparsity pattern based on a register width specified by an instruction set architecture (ISA) of a hardware unit used to implement the DNN for deep learning inference, the sparsity pattern specifying a block size and a sparsity ratio for block-wise sparsification of a weight matrix of an operator in the DNN; performing the block-wise sparsification on the weight matrix based on the sparsity pattern during a training process of the DNN to obtain a sparse weight matrix; compressing the sparse weight matrix into a lumped weight matrix by removing all-zero blocks from the sparse weight matrix; and generating a mask to indicate the index of each row of non-zero blocks in the sparse weight matrix so that corresponding elements can be extracted from an activation matrix of the operator during the deep learning inference.

[0117] Example 15 includes a method as described in Example 14, wherein the block size and the sparsity ratio are preset according to a register shape determined by the register width and the data type of the elements in the weight matrix, and the block-wise sparsification is to divide the weight matrix into blocks of the block size and set a subset of the blocks to the all-zero blocks according to the sparsity ratio.

[0118] Example 16 includes a method as described in Example 14 or 15, wherein, when the register shape is N×M, the block size is 1×M, and the number of non-zero blocks in the sparse weight matrix is ​​an integer multiple of N, where N and M are integers determined by the register width and the data type of the elements in the weight matrix.

[0119] Example 17 includes a method as described in any one of Examples 14 to 16, wherein the sparsity pattern is an L-over-N pattern, the sparsity ratio is equal to (LN) divided by L, and L is an integer determined based on the length of the cache line specified by the ISA.

[0120] Example 18 includes the method of any one of Examples 14 to 17, wherein the register shape is 4×16 and the sparsity mode is a 4-in-64 mode.

[0121] Example 19 includes a method as described in any one of Examples 14 to 18, wherein performing the block-wise sparsification includes: performing group-Lasso regularization on the weight matrix based on the hardware-aware sparsity pattern to generate a preliminary sparse weight matrix; and pruning elements in the preliminary sparse weight matrix according to block-based magnitudes to obtain the sparse weight matrix.

[0122] Example 20 includes a method as described in any one of Examples 14 to 19, wherein pruning the elements in the preliminary sparse weight matrix according to the block-based magnitude includes: determining whether the value of an element in a block in the preliminary sparse weight matrix is ​​less than a preset threshold; and when the value of the element in the block is less than the preset threshold, setting the block to an all-zero block.

[0123] Example 21 includes a method as described in any one of Examples 14 to 20, wherein pruning the elements in the preliminary sparse weight matrix according to block-based magnitudes includes: determining the number K of all-zero blocks in the sparse weight matrix according to the sparsity pattern and the shape of the weight matrix; selecting K blocks containing elements with minimum values ​​among all blocks in the weight matrix; and setting the K blocks to the all-zero blocks, wherein K is an integer greater than 0.

[0124] Example 22 includes a method as described in any one of Examples 14 to 21, wherein, when the register shape specified by the ISA is N×M, the block size is 1×M, the sparsity mode is an L-over-N mode, the sparsity ratio is equal to (LN) divided by L, and the pruning of elements in the preliminary sparse weight matrix based on block-based magnitudes includes: selecting (LN) blocks containing elements with minimum values ​​among each L blocks in the weight matrix; and setting the (LN) blocks to the all-zero blocks, wherein N and M are integers determined by the register width and the data type of the elements in the weight matrix, and L is an integer determined according to the length of a cache line specified by the ISA.

[0125] Example 23 includes a method as described in any one of Examples 14 to 22, further comprising: pruning the gradients of the elements in each block of the weight matrix during the training process to set the gradients of the elements in a block of the weight matrix to zero when the values ​​of the elements in the block have been trained to zero.

[0126] Example 24 includes a method as described in any one of Examples 14 to 23, further comprising: extracting elements corresponding to non-zero blocks of the sparse weight matrix from the activation matrix based on the mask; spreading the extracted elements to generate a concatenated activation matrix aligned with the register width; and applying the concatenated activation matrix and the lumped weight matrix to the operator to perform the deep learning inference based on the DNN.

[0127] Example 25 includes the method of any one of Examples 14 to 24, wherein the ISA comprises any single instruction multiple data (SIMD) ISA that can be used to implement the DNN to perform the deep learning inference.

[0128] Example 26 includes the method of any one of Examples 14 to 25, wherein the operator comprises a general matrix multiplication (GEMM) or a convolution.

[0129] Example 27 includes a computer-readable medium having instructions stored thereon, wherein the instructions, when executed by a processor circuit, cause the processor circuit to perform the method of any of Examples 14 to 26.

[0130] Various technologies or some aspects or parts thereof may take the form of program codes (i.e., instructions) embodied in tangible media, such as floppy disks, CD-ROMs, hard disk drives, non-transient computer-readable storage media, or any other machine-readable storage media, wherein when the program code is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for implementing various technologies. Non-transient computer-readable storage media may be computer-readable storage media that do not include signals. In the case of program code execution on a programmable computer, a computing system may include a processor, a storage medium (including volatile and non-volatile memory and / or storage elements) that can be read by the processor, at least one input device, and at least one output device. Volatile and non-volatile memory and / or storage elements may be RAM, EPROM, flash drives, optical drives, magnetic hard disk drives, solid-state drives, or other media for storing electronic data. One or more programs that may implement or utilize the various technologies described herein may use application programming interfaces (application programming interfaces, APIs), reusable controls, and the like. Such programs may be implemented in high-level procedural or object-oriented programming languages ​​to communicate with a computer system. However, if desired, the program(s) may be implemented in assembly or machine language. In any case, the language may be a compiled or interpreted language, and combined with a hardware implementation. Exemplary systems or devices may include, but are not limited to, laptop computers, tablet computers, desktop computers, smart phones, computer terminals and servers, storage databases, and other electronic devices utilizing circuits and programmable memory, such as household appliances, smart televisions, digital video disc (DVD) players, heating, ventilating, and air conditioning (HVAC) controllers, light switches, and the like.

[0131] The above detailed description includes reference to the accompanying drawings, which form a part of the detailed description. The accompanying drawings illustrate specific embodiments that can be implemented. These embodiments are also referred to as "examples" in this article. Such examples may include additional elements other than those shown or described. However, the inventors also contemplate examples in which only those elements shown or described are provided. In addition, the inventors also contemplate examples (or one or more aspects thereof) using any combination or arrangement of those elements shown or described, whether for a specific example (or one or more aspects thereof), or for other examples (or one or more aspects thereof) shown or described herein.

[0132] All publications, patents, and patent documents cited in this document are hereby incorporated by reference in their entirety, as if individually incorporated by reference. In the event of inconsistent usages between this document and those documents so incorporated by reference, the usage in the incorporated reference(s) should be considered supplementary to that of this document; for irreconcilable inconsistencies, the usage in this document controls.

[0133] In this document, the term "a" is used to include one or more than one, independent of any other instance or use of "at least one" or "one or more," as is common in patent documents. In this document, the term "or" is used to refer to a non-exclusive or, such that "A or B" includes "A but not B," "B but not A," and "A and B," unless otherwise indicated. In the appended claims, the terms "including" and "wherein" are used as the plain English equivalents of the respective terms "comprising" and "wherein." In addition, in the appended claims, the terms "including" and "comprising" are open-ended, that is, systems, devices, articles, or processes that include other elements in addition to those listed after such terms in the claim are still considered to fall within the scope of the claim. In addition, in the appended claims, the terms "first," "second," and "third," etc. are used merely as labels and are not intended to impose numerical requirements on their objects.

[0134] The above description is intended to be illustrative, not restrictive. For example, the above examples (or one or more aspects thereof) may be used in combination with each other. Other embodiments may be used, for example, by a person of ordinary skill in the art after viewing the above description. The abstract is intended to allow the reader to quickly determine the nature of the technical disclosure and is submitted with the understanding that it will not be used to interpret or limit the scope or meaning of the claims. In addition, in the above detailed description, various features may be grouped together to simplify the disclosure. This should not be interpreted as a desire to make the disclosed features that are not claimed necessary for any claim. More precisely, the subject matter of the invention may be present in less than all the features of a particular disclosed embodiment. Thus, the attached claims are incorporated herein into the "Specific Implementation" section, with each claim acting independently as a separate embodiment. The scope of the embodiment should be determined with reference to the attached claims and the full scope of equivalents to which such claims are entitled.

Claims

1. An apparatus for a deep neural network (DNN), comprising: Interface circuit; as well as a processor circuit coupled to the interface circuit and configured to: determining a hardware-aware sparsity mode based on a register width specified by an instruction set architecture (ISA) of a hardware unit for implementing the DNN for deep learning inference, the sparsity mode specifying a block size and a sparsity ratio for block-wise sparsification of weight matrices of operators in the DNN; During a training process of the DNN according to a training data set received via the interface circuit, performing the block-wise sparsification for the weight matrix based on the sparsity pattern to obtain a sparse weight matrix; Compressing the sparse weight matrix into a concentrated weight matrix by removing all-zero blocks from the sparse weight matrix; and A mask is generated to indicate the index of each row of non-zero blocks in the sparse weight matrix to enable extraction of corresponding elements from the activation matrix of the operator during the deep learning inference.

2. The device according to claim 1, wherein: The block size and the sparsity ratio are preset according to a register shape determined by the register width and a data type of elements in the weight matrix, and the block-wise sparsification is to divide the weight matrix into blocks of the block size and set a subset of the blocks to the all-zero blocks according to the sparsity ratio.

3. The device as claimed in claim 2, wherein: When the register shape is N×M, the block size is 1×M, and the number of non-zero blocks in the sparse weight matrix is ​​an integer multiple of N, where N and M are integers determined by the register width and the data type of the elements in the weight matrix.

4. The device according to claim 3, wherein: The sparsity pattern is an L-over-N pattern, the sparsity ratio is equal to (LN) divided by L, and L is an integer determined according to the length of a cache line specified by the ISA.

5. The device according to claim 4, wherein: The register shape is 4x16, and the sparsity mode is 4 / 64 mode.

6. The device according to claim 1, wherein: The processor circuit is configured to perform the block-wise thinning by: performing group-lasso regularization on the weight matrix based on the hardware-aware sparsity pattern to generate a preliminary sparse weight matrix; and Elements in the preliminary sparse weight matrix are pruned according to block-based magnitudes to obtain the sparse weight matrix.

7. The device according to claim 6, wherein: The pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: Determine whether the value of an element in a block of the preliminary sparse weight matrix is ​​less than a preset threshold; and When the value of the element in the block is less than the preset threshold, the block is set to an all-zero block.

8. The device of claim 6, wherein: The pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: Determining the number K of all-zero blocks in the sparse weight matrix according to the sparsity pattern and the shape of the weight matrix; Selecting K blocks containing elements with minimum values ​​among all blocks in the weight matrix; and The K blocks are set to the all-zero blocks, where K is an integer greater than 0.

9. The device according to claim 6, wherein: When the register shape specified by the ISA is N×M, the block size is 1×M, the sparsity mode is an L-over-N mode, the sparsity ratio is equal to (LN) divided by L, and the pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: selecting, among each L blocks in the weight matrix, (LN) blocks containing elements having minimum values; and setting the (LN) blocks to the all-zero blocks, Where N and M are integers determined by the register width and the data type of the elements in the weight matrix, and L is an integer determined according to the length of a cache line specified by the ISA.

10. The device according to any one of claims 1 to 9, wherein: The processor circuit is also configured to clip the gradients of the elements in each block of the weight matrix during the training process to set the gradients of the elements in a block of the weight matrix to zero when the values ​​of the elements in the block have been trained to be zero.

11. The device of claim 1, wherein: The processor circuit is further configured to: extracting, from the activation matrix, elements corresponding to non-zero blocks of the sparse weight matrix based on the mask; spreading the extracted elements to generate a concatenated activation matrix aligned to the register width; and Applying the concatenated activation matrix and the lumped weight matrix to the operator to perform the deep learning inference based on the DNN.

12. The device of claim 1, wherein: The ISA includes any single instruction multiple data (SIMD) ISA that can be used to implement the DNN to perform the deep learning inference.

13. The device of claim 1, wherein: The operators include general matrix multiplication (GEMM) or convolution.

14. A method for a deep neural network (DNN), comprising: determining a hardware-aware sparsity mode based on a register width specified by an instruction set architecture (ISA) of a hardware unit for implementing the DNN for deep learning inference, the sparsity mode specifying a block size and a sparsity ratio for block-wise sparsification of weight matrices of operators in the DNN; During a training process of the DNN, performing the block-wise sparsification on the weight matrix based on the sparsity pattern to obtain a sparse weight matrix; Compressing the sparse weight matrix into a concentrated weight matrix by removing all-zero blocks from the sparse weight matrix; and A mask is generated to indicate the index of each row of non-zero blocks in the sparse weight matrix to enable extraction of corresponding elements from the activation matrix of the operator during the deep learning inference.

15. The method of claim 14, wherein: The block size and the sparsity ratio are preset according to a register shape determined by the register width and a data type of elements in the weight matrix, and the block-wise sparsification is to divide the weight matrix into blocks of the block size and set a subset of the blocks to the all-zero blocks according to the sparsity ratio.

16. The method of claim 15, wherein: When the register shape is N×M, the block size is 1×M, and the number of non-zero blocks in the sparse weight matrix is ​​an integer multiple of N, where N and M are integers determined by the register width and the data type of the elements in the weight matrix.

17. The method of claim 16, wherein: The sparsity pattern is an L-over-N pattern, the sparsity ratio is equal to (LN) divided by L, and L is an integer determined according to the length of a cache line specified by the ISA.

18. The method of claim 17, wherein: The register shape is 4x16, and the sparsity mode is 4 / 64 mode.

19. The method of claim 14, wherein: The performing the block-wise thinning comprises: performing group-lasso regularization on the weight matrix based on the hardware-aware sparsity pattern to generate a preliminary sparse weight matrix; and Elements in the preliminary sparse weight matrix are pruned according to block-based magnitudes to obtain the sparse weight matrix.

20. The method of claim 19, wherein: The pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: Determine whether the value of an element in a block of the preliminary sparse weight matrix is ​​less than a preset threshold; and When the value of the element in the block is less than the preset threshold, the block is set to an all-zero block.

21. The method of claim 19, wherein: The pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: Determining the number K of all-zero blocks in the sparse weight matrix according to the sparsity pattern and the shape of the weight matrix; Selecting K blocks containing elements with minimum values ​​among all blocks in the weight matrix; and The K blocks are set to the all-zero blocks, where K is an integer greater than 0.

22. The method of claim 19, wherein: When the register shape specified by the ISA is N×M, the block size is 1×M, the sparsity mode is an L-over-N mode, the sparsity ratio is equal to (LN) divided by L, and the pruning of elements in the preliminary sparse weight matrix according to block-based magnitudes comprises: selecting, among each L blocks in the weight matrix, (LN) blocks containing elements having minimum values; and setting the (LN) blocks to the all-zero blocks, Where N and M are integers determined by the register width and the data type of the elements in the weight matrix, and L is an integer determined according to the length of a cache line specified by the ISA.

23. The method of any one of claims 14 to 22, further comprising: Gradients of elements in each block of the weight matrix are clipped during the training process to set the gradients of elements in a block of the weight matrix to zero when the values ​​of the elements in the block have been trained to be zero.

24. The method of claim 14, further comprising: extracting, from the activation matrix, elements corresponding to non-zero blocks of the sparse weight matrix based on the mask; spreading the extracted elements to generate a concatenated activation matrix aligned to the register width; and Applying the concatenated activation matrix and the lumped weight matrix to the operator to perform the deep learning inference based on the DNN.

25. A computer readable medium having instructions stored thereon, wherein: When the instructions are executed by a processor circuit, the processor circuit is caused to perform the method according to any one of claims 14 to 24.

Citation Information

Cited By

  • Graph neural network calculation acceleration method and system based on Tensor Core, medium and electronic equipment

    CN119830974A