Operation accelerator and compression method

By introducing compression and decompression modules into the computing accelerator, the I/O bandwidth bottleneck in convolutional neural network computation is solved, improving the computing performance of the computing accelerator, especially significantly improving computational efficiency at layers with high sparsity.

CN112771546BActive Publication Date: 2026-11-24HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201880098124.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-30
Publication Date
2026-11-24
Estimated Expiration
2038-09-30

AI Technical Summary

Technical Problem

When performing convolutional neural network calculations, the input/output bandwidth of existing AI computing accelerators becomes a bottleneck, resulting in a decrease in computing performance and an inability to effectively utilize the computing capabilities of the accelerators.

Method used

By introducing compression and decompression modules into the computing accelerator, the amount of data transferred between the computing accelerator and external memory can be reduced by compressing and decompressing the calculation results, thereby improving I/O bandwidth utilization.

Benefits of technology

By introducing compression and decompression modules, the I/O bandwidth requirements of the computing accelerator are reduced, computing performance is improved, and computing performance is maximized at levels with high sparsity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112771546B_ABST
    Figure CN112771546B_ABST
Patent Text Reader

Abstract

This application discloses a computing accelerator, comprising: a first cache for storing first input data; a second cache for storing weight data; a computing circuit connected to the input cache and the weight cache for performing matrix multiplication on the first input data and the weight data to obtain a calculation result; a compression module for compressing the calculation result to obtain compressed data; and a direct memory access controller (DMAC) connected to the compression module for storing the compressed data in a memory outside the computing accelerator. By adding a compression module to the computing accelerator, the amount of data transferred from the computing accelerator to the memory is reduced, saving the I / O bandwidth of the computing accelerator and improving its computing performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to data computing technology in the field of Artificial Intelligence (AI), and more particularly to a computing accelerator, processing device, compression method, and processing method. Background Technology

[0002] Convolutional neural networks (CNNs) have become a hot research and development area in both academia and industry due to their impressive performance in image classification, image recognition, audio recognition, and other related fields. Using AI accelerators to speed up CNN computation can improve the efficiency and shorten the execution time of CNN-related applications, making it a current research focus.

[0003] Convolutional neural networks (CNNs) are used to identify specific features in input images. The input image typically passes through at least four layers in a CNN: convolutional (Conv) layers, rectified linear unit (ReLU) (also known as activation function) layers, pooling layers, and fully connected (FC) layers. The convolutional (Conv) layer performs feature recognition on the input data (i.e., the data of the input image) using multiple filters. Each filter has a scanning range used to scan data information within a certain region of the input image. The calculation result from the current Conv layer is fed into the next layer (such as a ReLU layer, pooling layer, or FC layer) for processing. The ReLU layer performs an operation similar to MAX(0, x) on the input data, comparing each value in the input data with the value 0. If a value is greater than 0, it is retained; otherwise, it is set to 0. The ReLU layer increases the sparsity of the input data (the percentage of 0 values ​​in the total number of data points) without changing the size of the input data. Pooling layers downsample the input data, extracting data from every other row or column within each layer's two-dimensional matrix, thus reducing the size of the input data. Fully connected (FC) layers are similar to Conv layers, except that FC layer filters scan the entire input data at once, rather than scanning a small region, and then output a single value. FC layers contain multiple filters, each corresponding to a specific image feature, and the output value acts as a "score," representing the "probability" that the input data contains those features.

[0004] The core of AI computing accelerators lies in Conv and FC operations. In most neural networks, Conv and FC operations account for over 90% of the total computation, so their performance typically determines the overall performance of the AI ​​accelerator. When implementing Conv and FC operations, AI accelerators handle large amounts of weight data that cannot all be stored in on-chip cache. Therefore, during inference, the weight data needs to be imported from external memory to the accelerator for computation. Furthermore, the computation results obtained after executing the previous layer of the neural network are also substantial and difficult to store in on-chip cache. These results must be exported to external memory. When the AI ​​accelerator needs to execute the next layer of the neural network, the previous layer's results are imported from this external memory as input data.

[0005] Importing and exporting input data will consume the input / output (I / O) bandwidth of the AI ​​computing accelerator. If the I / O bandwidth becomes a bottleneck, the computing function of the AI ​​computing accelerator will be idle, reducing the overall performance of the AI ​​computing accelerator. Summary of the Invention

[0006] This application provides a computing accelerator, a processing device, a compression method, and a processing method, which aim to save the I / O bandwidth of the computing accelerator and improve its computing performance.

[0007] To achieve the above objectives, the embodiments of this application provide the following technical solutions:

[0008] In a first aspect, embodiments of this application provide a computing accelerator, including:

[0009] A first cache is used to store first input data; a second cache is used to store weight data; an arithmetic circuit connected to the first and second caches is used to perform matrix multiplication on the first input data and weight data to obtain a calculation result; a compression module is used to compress the calculation result to obtain compressed data; a direct memory access controller (DMAC) connected to the compression module is used to store the compressed data in a memory outside the arithmetic accelerator.

[0010] The first cache is the input cache in the computing accelerator, and the second cache is the weight cache memory in the computing accelerator.

[0011] Because a compression module has been added to the computing accelerator, the amount of data transferred from the computing accelerator to external memory has been reduced, saving the computing accelerator's I / O bandwidth and improving its computing performance.

[0012] In one alternative implementation, the computation accelerator also includes:

[0013] The decompression module connected to the DMAC and the first cache is used to receive the compressed data obtained by the DMAC from the memory, decompress the compressed data, and store the decompressed data as the second input data into the first cache; the arithmetic circuit is also used to obtain the second input data from the first cache to perform matrix multiplication.

[0014] The addition of a decompression module to the computing accelerator reduces the amount of data transferred from memory to the accelerator for the next calculation, saving I / O bandwidth and improving the computing performance of the accelerator.

[0015] In one alternative implementation, the computation accelerator also includes:

[0016] The third cache is used to store control instructions, which indicate whether to compress and decompress the calculation result. The third cache is the instruction fetch cache in the computing accelerator. The controller connected to the third cache is used to retrieve the control instructions from the third cache and parse the control instructions. When the control instructions indicate that the calculation result should be compressed and decompressed, the controller controls the compression module to compress the calculation result to obtain the compressed data, and controls the decompression module to decompress the obtained compressed data.

[0017] In one alternative implementation, the computation accelerator also includes:

[0018] The fourth cache connected to the arithmetic circuit is used to store the calculation result calculated by the arithmetic circuit, wherein the fourth cache is a unified cache in the arithmetic accelerator; the controller is also used to control the DMAC to store the calculation result in the fourth cache into the memory when the control instruction indicates that the calculation result is not compressed and decompressed, and to control the DMAC to store the calculation result in the memory into the first cache.

[0019] Since the controller in the computing accelerator determines whether to activate compression and decompression functions, it can avoid activating compression and decompression of the computation results generated from computations on input data with low sparsity in neural networks, thereby improving compression and decompression benefits.

[0020] In one alternative implementation, the computation accelerator also includes:

[0021] A third cache is used to store control instructions, which indicate whether to compress and decompress the calculation result. A controller connected to the third cache is used to retrieve the control instructions from the third cache and distribute the control instructions to the compression module and the decompression module. The compression module is used to parse the control instructions and, when the control instructions indicate that the calculation result should be compressed, compress the calculation result to obtain compressed data. The decompression module is used to parse the control instructions and, when the control instructions indicate that the calculation result should be decompressed, decompress the obtained compressed data.

[0022] Since the compression module in the computing accelerator determines whether to initiate compression, it can avoid initiating compression on the computation results generated from computations on input data with low sparsity in the neural network, thus improving compression benefits. Similarly, since the decompression module in the computing accelerator determines whether to initiate decompression, it can avoid initiating decompression on the computation results generated from computations on input data with low sparsity in the neural network, thus improving decompression benefits.

[0023] In one alternative implementation, the computation accelerator also includes:

[0024] The compression module is further configured to control the DMAC to store the calculation result into the memory when the control instruction indicates that the calculation result should not be compressed; the decompression module is further configured to control the DMAC to store the calculation result in the memory into the first cache when the control instruction indicates that the calculation result should not be decompressed.

[0025] In one optional implementation, the compression module includes a fragmentation module and at least one compression engine.

[0026] The sharding module is used to shard the calculation result to obtain at least one sub-calculation result; each of the at least one compression engines is used to compress one of the sub-calculation results to obtain sub-compressed data, wherein the sum of the sub-compressed data generated by each of the at least one compression engines constitutes the compressed data.

[0027] By splitting the data to be compressed into fragments and then compressing each fragment, compression efficiency can be improved.

[0028] In one optional implementation, each of the at least one compression engine is specifically used for:

[0029] The sub-calculation result is compressed to obtain a sub-compressed result; the size of the sub-compressed result and the sub-calculation result are compared; if the sub-compressed result is greater than the sub-calculation result, the sub-calculation result is used as the sub-compressed data; if the sub-compressed result is not greater than the sub-calculation result, the sub-compressed result is used as the sub-compressed data.

[0030] In an optional implementation, each of the at least one compression engine is further used for:

[0031] When the sub-compression result is greater than the sub-calculation result, a compression failure flag corresponding to the sub-compressed data is generated, and the compression failure flag is stored in the memory under the control of the DMAC; when the sub-compression result is not greater than the sub-calculation result, a compression success flag corresponding to the sub-compressed data is generated, and the compression success flag is stored in the memory under the control of the DMAC.

[0032] In one optional implementation, the decompression module is specifically used for:

[0033] The system receives the sub-compressed data obtained from the memory by the DMAC; when the identifier corresponding to the sub-compressed data is a compression failure identifier, the sub-compressed data is stored in the first buffer as the second input data; when the identifier corresponding to the sub-compressed data is a compression success identifier, the sub-compressed data is decompressed, and the decompressed data is stored in the first buffer as the second input data.

[0034] Secondly, embodiments of this application provide a processing apparatus, including:

[0035] The judgment module is used to determine whether the computing accelerator should compress and decompress the calculation result obtained after computing the input data of the i-th layer in the neural network based on the sparsity of the input data of the i-th layer, where 1≤i≤N, N is the number of layers of the neural network, and the computing accelerator is a coprocessor outside the processing device.

[0036] The compilation module is used to generate control instructions based on the determination result of the judgment module. These control instructions are used to instruct the computing accelerator whether to compress and decompress the calculation result.

[0037] The processor generates control instructions to instruct the computing accelerator to perform compression and decompression based on the sparsity of the input data in the neural network. This avoids the computing accelerator from initiating compression and decompression based on the computation results generated from the computation of input data with low sparsity in the neural network, thereby improving the compression and decompression benefits.

[0038] In one optional implementation, this judgment module is specifically used for:

[0039] When the sparsity of the input data of the i-th layer of the neural network is greater than the threshold, it is determined that the computing accelerator compresses the calculation result and decompresses it when using the calculation result as the input data of the (i+1)-th layer for the (i+1)-th layer calculation.

[0040] When the sparsity of the input data of the i-th layer of the neural network is not greater than the threshold, it is determined that the computing accelerator will not compress the calculation result, and will not decompress the calculation result when it is used as the input data of the (i+1)-th layer for the (i+1)-th layer calculation.

[0041] In one alternative implementation, the threshold is determined based on the gains and power costs of input / output (I / O) bandwidth, where the gains in I / O bandwidth indicate the reduction in I / O bandwidth caused by the accelerator compressing and decompressing the computation results, and the power costs indicate the increased power consumption caused by the accelerator compressing and decompressing the computation results.

[0042] Thirdly, embodiments of this application provide a computation acceleration processing system, including:

[0043] The processor is used to generate control instructions, which instruct the computing accelerator whether to compress and decompress the calculation results obtained after processing the input data of the i-th layer of the neural network, where 1≤i≤N and N is the number of layers of the neural network;

[0044] The computation accelerator is used to perform calculations on the input data of the i-th layer of the neural network to obtain the calculation result, and to obtain the control instructions generated by the processor, and to determine whether to compress and decompress the calculation result according to the control instructions.

[0045] In one alternative implementation, the computation accelerator includes:

[0046] The computation circuit is used to perform calculations on the input data of the i-th layer in the neural network to obtain the calculation result; the controller is used to control the compression module to compress the calculation result and the decompression module to decompress the calculation result according to the acquired control command; the compression module is used to compress the calculation result; the decompression module is used to decompress the calculation result.

[0047] In one possible implementation, the computation acceleration system also includes:

[0048] The memory is used to store the control instructions generated by the processor; correspondingly, the processor is also used to store the generated control instructions in the memory; the arithmetic accelerator is also used to retrieve the control instructions from the memory.

[0049] Fourthly, embodiments of this application provide a compression method applied to a computing accelerator, the computing accelerator including a first cache and a second cache, the method comprising:

[0050] A matrix multiplication operation is performed on the first input data obtained from the first cache and the weight data obtained from the second cache to obtain a calculation result; the calculation result is compressed to obtain compressed data; and the compressed data is stored in a memory outside the computing accelerator.

[0051] In an optional implementation, the compression method further includes:

[0052] The compressed data is retrieved from the memory; the compressed data is decompressed, and the decompressed data is stored in the first buffer as the second input data; matrix multiplication is performed on the second input data retrieved from the first buffer.

[0053] In one optional implementation, the compression method includes:

[0054] Obtain a control command, which indicates whether to compress and decompress the calculation result; parse the control command; compressing the calculation result to obtain compressed data includes: when the control command indicates that the calculation result should be compressed, compressing the calculation result to obtain the compressed data.

[0055] Correspondingly, decompressing the compressed data includes: decompressing the compressed data when the control command instructs the calculation result to be decompressed.

[0056] In an optional implementation, the compression method further includes:

[0057] When the control instruction indicates that the calculation result should not be compressed or decompressed, the calculation result is stored in the memory, and the calculation result is retrieved from the memory and stored in the first cache.

[0058] Fifthly, embodiments of this application provide a compression method applied to a computing accelerator, the computing accelerator including a first cache and a second cache, the compression method comprising:

[0059] A matrix multiplication operation is performed on the first input data obtained from the first cache and the weight data obtained from the second cache to obtain a calculation result; a control instruction is obtained to indicate whether the calculation result is compressed and decompressed; when the control instruction indicates that the calculation result is compressed, the calculation result is compressed to obtain compressed data, and the compressed data is stored in memory outside the computing accelerator; when the control instruction indicates that the calculation result is not compressed, the calculation result is stored in memory outside the computing accelerator.

[0060] In an optional implementation, the compression method further includes:

[0061] When the control instruction instructs that the calculation result be decompressed, the compressed data obtained from the memory is decompressed, and the decompressed data is used as the second input data for matrix multiplication; when the control instruction instructs that the calculation result not be decompressed, the calculation result obtained from the memory is used as the second input data for matrix multiplication.

[0062] Sixthly, embodiments of this application provide a processing method applied to a processing apparatus, comprising:

[0063] Based on the sparsity of the input data of the i-th layer in the neural network, it is determined whether the computing accelerator should compress and decompress the calculation result obtained after calculating the input data of the i-th layer, where 1≤i≤N, N is the number of layers of the neural network, and the computing accelerator is a coprocessor outside the processing device; control instructions are generated to instruct the computing accelerator whether to compress and decompress the calculation result.

[0064] In one optional implementation, determining whether the computation accelerator should compress and decompress the computation result obtained after computing the i-th layer input data based on the sparsity of the input data in the neural network includes:

[0065] When the sparsity of the input data of the i-th layer of the neural network is greater than a threshold, it is determined that the computing accelerator compresses the calculation result and decompresses it when using the calculation result as input data of the (i+1)-th layer for the (i+1)-th layer calculation; when the sparsity of the input data of the i-th layer of the neural network is not greater than a threshold, it is determined that the computing accelerator does not compress the calculation result and does not decompress it when using the calculation result as input data of the (i+1)-th layer for the (i+1)-th layer calculation.

[0066] In one alternative implementation, the threshold is determined based on the gains and power costs of input / output (I / O) bandwidth, whereby the gains in I / O bandwidth indicate the reduction in I / O bandwidth caused by the accelerator compressing and decompressing the computation results, and the power costs indicate the increased power consumption caused by the accelerator compressing and decompressing the computation results.

[0067] This application also provides a processing apparatus, which includes: a memory for storing instructions; and a processor for reading the instructions from the memory and executing the sixth aspect or various possible processing methods described above.

[0068] This application also provides a computer storage medium storing a software program that can be read and executed by one or more processors using the sixth aspect or various possible processing methods described above.

[0069] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform the sixth aspect or various possible processing methods described above. Attached Figure Description

[0070] To more clearly illustrate the technical solutions in the embodiments of this application or the background art, the accompanying drawings used in the embodiments of this application or the background art will be described below.

[0071] Figure 1 A structural diagram of a computing accelerator provided in this application;

[0072] Figure 2 A structural diagram of a computing accelerator provided in an embodiment of this application;

[0073] Figure 3 A structural diagram of a computing accelerator is provided in yet another embodiment of this application;

[0074] Figure 4 A structural diagram of a computing accelerator is provided in yet another embodiment of this application;

[0075] Figure 5 A structural diagram of a compression module applied in a computing accelerator is provided in an embodiment of this application;

[0076] Figure 6 A structural diagram of another compression module applied in a computing accelerator provided in this application embodiment;

[0077] Figure 7 This is a flowchart illustrating a method for controlling a computing accelerator to perform compression, as provided in an embodiment of this application. Detailed Implementation

[0078] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0079] The computing accelerator provided in this application can be applied to fields such as machine learning, deep learning, and convolutional neural networks, as well as digital image processing and digital signal processing, and other fields involving matrix multiplication operations. In this application, the computing accelerator can be a Neural Network Processing Unit (NPU) or other processors, and can be applied to devices capable of performing convolution operations, such as mobile phones, tablets, servers, and wearable devices.

[0080] First, let's explain some of the terms used in this application:

[0081] Input data can be the raw data initially input to the computing accelerator for inference operations, such as image data, voice data, etc., or it can be the intermediate data generated by the computing accelerator during the execution of neural network operations. Since the amount of intermediate data is usually large, the computing accelerator will store the intermediate data obtained from the previous layer of the neural network in external storage, and then read the intermediate data from the storage and load it into the computing accelerator for calculation when executing the next layer of the neural network.

[0082] Weight data refers to the weight data obtained after training a neural network. The training process of a neural network is a process of continuously adjusting the weight values.

[0083] The computation result refers to the intermediate or final data generated by the computing accelerator during the execution of neural network operations. It can be the data output by the computing units within the accelerator, or the data obtained by the vector computing unit further processing the data output by the computing units. It should be noted that the computation result is also a type of input data; the computation result of the previous layer in the neural network often serves as input data for the next layer.

[0084] Data sparsity typically refers to the proportion of data in a dataset that is missing values ​​or has a value of 0 out of the total data.

[0085] Figure 1 This is a hardware structure diagram of a computing accelerator provided in this application. The computing accelerator 30 is mounted as a coprocessor on the host CPU 10, and tasks are assigned by the host CPU 10. The core of the computing accelerator 30 is the computing circuit 303, and the controller 304 controls the computing circuit 303 to extract data from the input buffer 301 or the weight buffer 302 and perform calculations.

[0086] In some implementations, the arithmetic circuit 303 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 303 is a two-dimensional pulsating array. The arithmetic circuit 303 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 303 is a general-purpose matrix processor.

[0087] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight buffer 302 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the corresponding data of matrix A from the input buffer 301 and performs matrix multiplication with the corresponding data of matrix B to obtain a partial or final result of the matrix, which is stored in the accumulator 308.

[0088] The vector computation unit 307 can further process the output of the arithmetic circuit 303, such as vector multiplication, vector addition, exponentiation, logarithmic operations, and size comparisons. For example, the vector computation unit 307 can be used for network computation in non-convolutional / non-FC layers of a convolutional neural network, such as pooling, batch normalization, and local response normalization.

[0089] In some implementations, vector computation unit 307 stores the processed output vector in unified buffer 306. For example, vector computation unit 307 can apply a nonlinear function to the output of arithmetic circuit 303, such as a vector of accumulated values, to generate activation values. In some implementations, vector computation unit 307 generates normalized values, merged values, or both. In some implementations, the processed output vector can be used as activation input to arithmetic circuit 303, for example, for use in subsequent layers of a neural network.

[0090] The Unified Buffer 306 is used to store the output calculation results and input data for certain layers.

[0091] The Direct Memory Access Controller (DMAC) 305 is used to store input data (or input matrix) from memory 20 outside of the computing accelerator 30 into input cache 301 and unified cache 306, and to store weight data (or weight matrix) into weight cache 302, or to store data from unified cache 306 into memory 20.

[0092] The Bus Interface Unit (BIU) 310 is used to interact between the main CPU 10, DMAC 305 and Instruction Fetch Buffer 309 via a bus.

[0093] The instruction fetch buffer 309, which is connected to the controller 304, is used to store the instructions used by the controller 304.

[0094] The controller 304 is used to call the instructions cached in the instruction fetch cache 309 to control the operation of the computing accelerator 30.

[0095] Generally, the unified cache 306, input cache 301, weighted cache 302, and instruction fetch cache 309 are all on-chip buffers. The memory 20 is an external memory of the computing accelerator 30. The memory 20 can be Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), High Bandwidth Memory (HBM), or other readable and writable memory.

[0096] In this application, the input cache is the first cache, the weight cache is the second cache, the instruction fetch cache is the third cache, and the unified cache is the fourth cache.

[0097] When implementing convolution and fully connected (FC) operations, the aforementioned accelerator has a large amount of weight data involved in the operation, which cannot all be stored in the weight cache. Therefore, the accelerator needs to import the weight data from memory in real time during the operation. In addition, the amount of data obtained by the accelerator after performing the operation of the previous layer of the neural network is also large, which is difficult to store in a unified cache. The calculation results of the previous layer need to be exported to memory. When the accelerator needs to perform the calculation of the next layer of the neural network, it imports the calculation results of the previous layer from memory as input data for the operation.

[0098] Exporting and importing computation results will both consume the input / output (I / O) bandwidth of the accelerator. If the I / O bandwidth becomes a bottleneck, it will cause the computation function of the accelerator to be idle, thus reducing the computation performance of the accelerator.

[0099] Figure 2 This is a hardware structure diagram of a computing accelerator 40 provided in an embodiment of this application. The computing accelerator 40 and Figure 1Compared to the provided computing accelerator 30, the main additions are a compression module 311 and a decompression module 312.

[0100] Input buffer 301 stores input data, weight buffer 302 stores weight data, and arithmetic circuit 303 performs matrix multiplication on the input data obtained from input buffer 301 and the weight data obtained from weight buffer 302 to obtain a calculation result. The calculation result can be an intermediate result or a final result. The calculation result is stored in accumulator 308. Vector calculation unit 307 can retrieve the calculation result from accumulator 308 for further processing, such as vector multiplication, vector addition, exponential operation, logarithmic operation, and size comparison. Vector calculation unit 307 stores the processed calculation result in unified buffer 306.

[0101] The compression module 311 obtains the calculation results from the unified buffer 306 and compresses the calculation results to obtain compressed data. Then, the DMAC 305 stores the compressed data output by the compression module 311 into the memory 20.

[0102] Furthermore, since the compressed data is the result of the computation of a certain layer of the neural network by the accelerator 40, it can be used as input data in the next computation of the accelerator 40. Therefore, the accelerator 40 also includes a decompression module 312, which is used to retrieve the compressed data from the memory 20 via DMAC 305, decompress the compressed data to obtain decompressed data, and store the decompressed data as input data in the input buffer 301. The computation circuit 303 performs matrix multiplication on the input data retrieved from the input buffer 301 and the weight data retrieved from the weight buffer 302.

[0103] As can be seen from the above, by adding compression and decompression modules to the computing accelerator, the amount of data transferred from the computing accelerator to the memory is reduced, as is the amount of data transferred from the memory to the computing accelerator for the next calculation, thus saving the I / O bandwidth of the computing accelerator and improving its computing performance.

[0104] In a neural network, the computation result of the first layer (the initial input data) is processed by the accelerator and used as the input data for the second layer. Subsequent layers use the output of the previous layer as the input data for the next layer, until the final layer (fully connected layer) is completed, yielding the final result. Since the sparsity of the first layer data is typically low, compressing it results in minimal I / O bandwidth gains and incurs power consumption losses, leading to minimal compression benefits. However, as the neural network progresses through deeper layers, the increasing use of Rectified Linear Units (ReLU) (also known as activation functions) gradually increases the sparsity of the computation results. Higher sparsity improves I / O bandwidth gains. Therefore, activating compression only after the accelerator has processed a certain number of layers maximizes the compression benefits.

[0105] Based on the above considerations Figure 3 The present application provides a structure for a computing accelerator 50. In this computing accelerator 50, a controller 504 is connected to a compression module 311, a decompression module 312, a unified cache 306, a DMAC 305, and an instruction fetch cache 309. The instruction fetch cache 309 retrieves control instructions from the memory 20 and stores the control instructions. The control instructions are used to instruct the computing accelerator 50 whether to compress the calculation results after each layer of the neural network and whether to decompress the calculation results retrieved from the memory 20. The controller 504 reads the control instructions from the instruction fetch cache to control the relevant components in the computing accelerator.

[0106] Specifically, the controller 504 retrieves the control instruction from the instruction fetch cache, parses the control instruction, and when the control instruction indicates that the calculation result should be compressed, the controller controls the compression module 311 to compress the calculation result retrieved from the unified cache 306 to obtain the compressed calculation result. The DMAC 305 then moves the compressed calculation result to the memory 20. When the control instruction indicates that the calculation result should not be compressed, the controller controls the unified cache 306 to send the calculation result to the DMAC 305, which then moves the calculation result to the memory 20. In this case, the calculation result has not undergone compression processing by the compression module. As can be seen from the above, when the control instruction indicates that the calculation result should be compressed, the memory 20 stores the compressed calculation result. Since the compressed calculation result will also be used as input data in the next layer calculation of the neural network by the arithmetic accelerator 50, the controller 504 also needs to control the decompression module 312 to perform decompression processing.

[0107] Specifically, the aforementioned control command, in addition to instructing the accelerator 50 whether to compress the computation results after each layer of the neural network, also instructs the accelerator 50 whether to decompress the computation results retrieved from the memory 20. The controller 504 retrieves the control command from the instruction fetch cache 309, parses the control command, and when the control command instructs the computation results to be decompressed, controls the decompression module 312 to decompress the retrieved computation results, and the decompression module 312 stores the decompressed data as input data into the input cache 301; when the control command instructs the computation results not to be decompressed, controls the DMAC 305 to directly store the computation results as input data into the input cache 301, in which case the computation results have not undergone decompression processing by the decompression module 312.

[0108] The following will combine Figure 3 The document further describes how the control instructions stored in memory 20 are generated.

[0109] Figure 3 In addition to providing the structure of the computing accelerator 50, the structure of the main CPU 10 is also shown. The main CPU 10 includes a software-implemented acceleration library and a compilation module. The acceleration library can contain multiple components to perform different acceleration optimization operations, such as a quantization module for data quantization and a sparsity module to support sparse computing architectures. The compilation module is used to generate instructions to control the computing accelerator to perform computational operations. Besides the acceleration library and compilation module, the main CPU may also include a driver and task scheduling module. Figure 4 (Not shown in the image), the connection between the main CPU and the computing accelerator is achieved through the driver and task scheduling modules.

[0110] In the embodiments provided in this application, the acceleration library further includes a judgment module, which is used to analyze the characteristics of the neural network formed after training (the neural network formed after training is the neural network for the computation accelerator to perform inference operations), such as through algorithm analysis or actual test data, and then infer the sparsity of the input data of each layer in the neural network process based on the characteristics of the neural network obtained from the analysis, determine whether to compress and decompress the calculation results of each layer based on the sparsity of the input data of each layer, and send the information on whether to compress and decompress the calculation results of each layer to the compilation module, which then generates specific control instructions.

[0111] Specifically, the judgment module compares the sparsity of the input data of the i-th layer in the neural network with a preset threshold. If the sparsity of the input data of the i-th layer in the neural network is greater than the threshold, it determines that the calculation result of the i-th layer needs to be compressed, and that it needs to be decompressed when the calculation result of the i-th layer is used as the input data of the (i+1)-th layer for the calculation of the (i+1)-th layer. If the sparsity of the calculation result of the i-th layer in the neural network is not greater than the threshold, it determines that the calculation result of the i-th layer does not need to be compressed, and that it does not need to be decompressed when the calculation result of the i-th layer is used as the input data of the (i+1)-th layer for the calculation of the (i+1)-th layer, where 1≤i≤N, and N is the number of layers in the neural network.

[0112] The aforementioned thresholds can be determined based on the benefits of I / O bandwidth and the power consumption cost. The benefits of I / O bandwidth refer to the reduction in I / O bandwidth caused by the accelerator compressing and decompressing the computation results, while the power consumption cost refers to the increased power consumption caused by the accelerator compressing and decompressing the computation results.

[0113] Specifically, the threshold can be predetermined. For example, in a preliminary test, when the sparsity of the input data equals the critical value, the gain in I / O bandwidth brought by the accelerator to enable compression and decompression is equal to the power consumption cost. Therefore, the critical value can be used as the threshold. Of course, in actual implementation, considering the desire for greater I / O bandwidth gain, the critical value can be adjusted to determine the threshold. This application does not limit the method for determining the threshold.

[0114] It should be noted that the preset thresholds mentioned above may vary for different neural network models.

[0115] The compilation module is used to decode the information obtained from the judgment module regarding whether the calculation results of each layer should be compressed and decompressed to obtain the control instructions mentioned above. That is, the control instructions are used to instruct the computing accelerator whether to compress and decompress the calculation results after each layer of the neural network.

[0116] As can be seen from the above, for input data with low sparsity in neural networks, if the computing accelerator initiates compression and decompression, it will result in a small I / O bandwidth gain, while also causing power loss due to the compression and decompression functions, resulting in low compression benefits. In this embodiment, the main CPU only controls the computing accelerator to compress and decompress the calculation results of a certain layer in the neural network when it determines that the sparsity of the input data of that layer is high. Since the I / O bandwidth gain is large at this time, it can offset some of the power loss caused by initiating compression and decompression functions, thereby improving the compression benefits.

[0117] exist Figure 3In the aforementioned computing accelerator, the controller parses the control instructions stored in the instruction fetch cache and performs different control operations on the compression module, unified cache, decompression module, and DMAC based on the parsing results. In another possible implementation, the controller may not perform the parsing of the control instructions and instead delegate the parsing of the control instructions to the compression and decompression modules in the computing accelerator.

[0118] Figure 4 The structure of the computing accelerator 60 provided in one embodiment of this application is as follows: In the computing accelerator 60, the instruction fetch cache 309 retrieves control instructions from the memory 20 and stores the control instructions, and the controller 304 distributes the control instructions to the compression module 611 and the decompression module 612.

[0119] The compression module 611 parses the control instruction. When the control instruction indicates that the calculation result should be compressed, the calculation result is compressed to obtain a compressed calculation result, and the DMAC305 moves the compressed calculation result to the memory. When the control instruction indicates that the calculation result should not be compressed, the calculation result is directly sent to the DMAC305, and the DMAC305 moves the calculation result to the memory 20.

[0120] Similarly, the decompression module 612 parses the control instruction. When the control instruction instructs that the calculation results obtained from the memory 20 be decompressed, the obtained calculation results are decompressed and the decompressed data is stored as input data in the input buffer 301. When the control instruction instructs that the calculation results obtained from the memory 20 are not decompressed, the obtained calculation results are directly stored as input data in the input buffer 301.

[0121] The following describes how the compression module 311 in the computing accelerator mentioned in the above embodiments implements the compression function.

[0122] To improve the compression efficiency of the compression module 311, a segmentation module 3110 is usually introduced into the compression module 311 during its design. This module is used to segment the calculation results received by the compression module 311 and perform compression processing on each segment separately.

[0123] Specifically, Figure 5The present application provides a structural diagram of a compression module 311, which includes a fragmentation module 3110 and at least one compression engine 3111. The fragmentation module 3110 is used to fragment the received calculation results to obtain at least one sub-calculation result. Each compression engine 3111 is used to compress one of the sub-calculation results to obtain sub-compressed data. The sum of the sub-compressed data generated by each compression engine in the at least one compression engine constitutes the compressed data output by the compression module 311.

[0124] It should be noted that this application does not restrict the compression algorithm used in the compression engine 3111. Commonly used compression algorithms in the industry include entropy coding and run-length encoding. Different compression algorithms have their own applicable scenarios. For example, the compression engine can compress data based on the value of 0. Since the compression module runs on the hardware logic circuit of the computing accelerator 40, the selection of the compression algorithm needs to consider hardware resources, power consumption, and performance. This application does not limit which compression algorithm the compression engine uses. Furthermore, Figure 3 The example in the paper divides the calculation result into four sub-calculation results and assigns each sub-calculation result to a corresponding compression engine for compression processing, that is, there are four compression engines in total. In actual implementation, the number of compression engines can be determined by the performance of a single compression engine and the performance requirements of the computing accelerator. This application does not limit the number of compression engines, and the number of compression engines and the number of sub-calculation results do not have to correspond one-to-one. For example, one compression engine can process two or more sub-calculation results.

[0125] Furthermore, since the size of the compressed data may be larger than the size of the data to be compressed after the compression engine 3111 compresses the data, it is not conducive to reducing the I / O bandwidth of the computing accelerator if the compressed data is moved to the memory for storage. Therefore, in order to further reduce the I / O bandwidth of the computing accelerator, further design can be made for the compression engine 3111.

[0126] Specifically, each compression engine 3111 compresses the received sub-computation result to obtain a sub-compression result, compares the size of the sub-compression result with the sub-computation result, and if the sub-compression result is greater than the sub-computation result, the sub-computation result is used as the output sub-compressed data, and a compression failure flag corresponding to the sub-compressed data is generated. Since the output sub-compressed data at this time is data that has not undergone compression processing, the compression fails. If the sub-compression result is not greater than the sub-computation result, the sub-compressed result is used as the output sub-compressed data, and a compression success flag corresponding to the sub-compressed data is generated. Since the output sub-compressed data at this time is data that has undergone compression processing, the compression succeeds. The compression failure flag and the compression success flag are stored in the memory through DMAC.

[0127] It should be noted that for scenarios where the size of the sub-compression result is equal to the size of the sub-calculation result, there are two implementation methods: First, as mentioned above, the compression engine 3111 can output the sub-compression result as the sub-compressed data to DMAC. Although this adds a decompression process to the sub-compressed data in the next calculation, it avoids the compression engine 3111 reading the sub-calculation result again and then outputting it to DMAC, saving power consumption associated with reading the sub-calculation result. Second, the compression engine 3111 can also directly output the sub-calculation result as the sub-compressed data to DMAC. In this case, the sub-compressed data is uncompressed. Although the compression engine 3111 will read the sub-calculation result again, it avoids the decompression process in the next calculation, saving power consumption associated with decompressing the sub-compressed data. Therefore, for scenarios where the size of the sub-compression result is equal to the size of the sub-calculation result, both implementation methods have their advantages and disadvantages. In practice, the appropriate choice can be made based on the performance requirements of the computing accelerator.

[0128] As can be seen from the above, the compression engine in the compression module may experience compression failure and compression success during the compression process. Therefore, the DMAC305 adds a decompression module 312 during the process of moving the sub-compressed data stored in the memory to the input buffer. The decompression module 312 may include multiple decompression engines. Each decompression engine performs decompression processing on the received sub-compressed data. Specifically, after obtaining the sub-compressed data, each decompression engine identifies the identifier corresponding to the received sub-compressed data. When the identifier corresponding to the sub-compressed data is a compression failure identifier, the sub-compressed data is directly stored as input data in the input buffer without decompression processing. When the identifier corresponding to the sub-compressed data is a compression success identifier, the sub-compressed data is decompressed to obtain the decompressed data, and the decompressed data is stored as input data in the input buffer.

[0129] It should be noted that the number of decompression engines is determined by the decompression performance of a single decompression engine and the performance requirements of the computing accelerator, while also taking into account the coupling between the decompression and compression processes; in addition, the decompression algorithm used in the decompression engine is the same as the compression algorithm used in the compression engine of the compression module.

[0130] The following describes how the compression module 611 in the computing accelerator mentioned in the above embodiments implements the compression function. Figure 6 This is a structural diagram of a compression module 611 provided in another embodiment of this application. The compression module 611 is related to... Figure 5Compared to the compression module 311, the main difference is the addition of a parsing module 610.

[0131] The parsing module 610 parses control commands. When the control command instructs that the calculation result be compressed, it provides the calculation result to the fragmentation module 3110 for fragmentation. Then, the compression engine 3111 compresses the fragmented sub-calculation results and sends them to the DMAC 305. Finally, the DMAC 305 moves the compressed calculation result to the memory 20. This part of the implementation is the same as described above. Figure 5 The implementation of the compression module 311 is the same as that in the previous section, and will not be described in detail here. When the control instruction indicates that the calculation result should not be compressed, the calculation result is directly sent to DMAC305, and DMAC305 moves the calculation result to memory 20.

[0132] Correspondingly, the decompression module 612 also includes a parsing module for parsing control instructions. When the control instruction instructs that the calculation results obtained from the memory 20 be decompressed, the obtained calculation results are decompressed, and the decompressed data is stored as input data in the input buffer 301. When the control instruction instructs that the calculation results obtained from the memory 20 are not decompressed, the obtained calculation results are directly stored as input data in the input buffer 301. A structural diagram of the decompression module 612 is not shown in this application.

[0133] Based on the hardware structure diagram of the computing accelerator in the above embodiments, this application provides a method for controlling the computing accelerator to perform compression, such as... Figure 7 As shown, the method may include the following steps S701 to S709, wherein S701 to S704 are executed by the main CPU and S705 to S709 are executed by the computing accelerator.

[0134] S701. Determine whether to compress and decompress the calculation results of each layer in the neural network.

[0135] The CPU analyzes the characteristics of the neural network formed after training (this neural network is the neural network used by the computing accelerator to perform inference operations), for example, through algorithm analysis or actual test data. Then, based on the characteristics of the neural network obtained from the analysis, it infers the sparsity rate of the input data of each layer in the process of the neural network. Based on the sparsity rate of the input data of each layer, it determines whether to compress and decompress the calculation results of that layer. Specifically, this can be achieved by comparing the sparsity rate of the input data of each layer with a threshold. Since the specific implementation method has been described in detail in the above embodiments, it will not be repeated here.

[0136] S702, Generate control commands.

[0137] The CPU's internal compilation module decodes instructions to generate control instructions based on information about whether the computation results of each layer are compressed and decompressed. These control instructions instruct the computing accelerator whether to compress and decompress the computation results after each layer of the neural network.

[0138] S703: Store control instructions in memory.

[0139] The CPU stores the generated control instructions in memory outside the computing accelerator.

[0140] S704: Place the control instructions into the instruction fetch buffer in the arithmetic accelerator.

[0141] The CPU controls the movement of control instructions stored in memory to the instruction fetch cache in the computing accelerator.

[0142] S705: Read control instructions from the instruction fetch buffer.

[0143] The arithmetic accelerator reads control instructions from the instruction fetch cache.

[0144] S706. Perform calculations on each layer of the neural network to obtain the calculation results.

[0145] The computation accelerator performs calculations on the input data of each layer in the neural network and obtains the calculation results. Specifically, the computation can be performed by the computation circuits in the computation accelerator.

[0146] S707. Determine whether to compress and decompress the calculation results according to the control instructions.

[0147] The computational accelerator parses the control instruction and determines whether to compress and decompress the calculation results of each layer in the neural network based on the control instruction. If it is determined to perform compression and decompression, S708 is executed; if it is uncertain not to perform compression and decompression, S709 is executed.

[0148] S708. Compress the calculation results, store the compressed calculation results in the memory, and decompress the calculation results obtained from the memory in the next calculation to obtain the input data.

[0149] When the computation accelerator determines that the computation results need to be compressed, it compresses the results and stores the compressed results in memory. When executing the next layer of computation in the neural network, the computation accelerator retrieves the computation results from memory and decompresses them to obtain decompressed data. The decompressed data is then used as input data in the next layer of computation in the neural network.

[0150] S709. The calculation result is stored in the memory, and the calculation result read from the memory is used as input data in the next calculation.

[0151] When the computation accelerator determines that there is no need to compress the computation results, it directly stores the computation results in the memory. When executing the next layer of computation in the neural network, the computation accelerator retrieves the computation results from the memory and uses the retrieved computation results as input data to participate in the next layer of computation in the neural network. At this time, the computation results retrieved by the computation accelerator do not need to be decompressed.

[0152] As can be seen from the above, for input data with low sparsity in neural networks, the compression benefit is low if the computing accelerator initiates compression and decompression. In this embodiment, the CPU only controls the computing accelerator to compress and decompress the calculation results of a certain layer in the neural network when it determines that the sparsity of the input data of that layer is relatively high. Since the I / O bandwidth benefit is large at this time, the compression benefit is improved.

[0153] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computing accelerator, all or part of the processes or functions described in the embodiments of this application are generated. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive (SSD).

[0154] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A computing accelerator, characterized in that, include: The first buffer is used to store the first input data of the i-th layer of the neural network, where 1≤i≤N and N is the number of layers of the neural network; The second cache is used to store weight data; The arithmetic circuit connected to the first cache and the second cache is used to perform matrix multiplication on the first input data and the weight data to obtain a calculation result. When the sparsity of the first input data is not greater than a threshold, the calculation result is the input data of the (i+1)th layer of the neural network. A compression module is used to compress the calculation result to obtain compressed data when the sparsity of the first input data is greater than the threshold, and the decompressed data of the compressed data is used as the input data of the (i+1)th layer of the neural network. A Direct Memory Access Controller (DMAC) connected to the compression module is used to store the compressed data into a memory outside the computing accelerator.

2. The computing accelerator as described in claim 1, characterized in that, Also includes: The decompression module connected to the DMAC and the first cache is used to receive the compressed data obtained by the DMAC from the memory, decompress the compressed data, and store the decompressed data as the second input data into the first cache; The arithmetic circuit is also used to obtain the second input data from the first cache to perform matrix multiplication.

3. The computing accelerator as described in claim 2, characterized in that, Also includes: The third cache is used to store control instructions, which are used to indicate whether to compress and decompress the calculation results; The controller connected to the third cache is configured to obtain the control instruction from the third cache and parse the control instruction. When the control instruction instructs the calculation result to be compressed and decompressed, the controller controls the compression module to compress the calculation result to obtain the compressed data and controls the decompression module to decompress the obtained compressed data.

4. The computing accelerator as described in claim 3, characterized in that, Also includes: A fourth buffer connected to the arithmetic circuit is used to store the calculation result calculated by the arithmetic circuit; The controller is further configured to, when the control instruction indicates that the calculation result is not compressed or decompressed, control the DMAC to store the calculation result in the fourth cache into the memory, and control the DMAC to store the calculation result in the memory into the first cache.

5. The computing accelerator as described in claim 2, characterized in that, Also includes: The third cache is used to store control instructions, which are used to indicate whether to compress and decompress the calculation results; A controller connected to the third cache is configured to retrieve the control instructions from the third cache and distribute the control instructions to the compression module and the decompression module. The compression module is used to parse the control command, and when the control command instructs the calculation result to be compressed, compress the calculation result to obtain the compressed data; The decompression module is used to parse the control command and decompress the acquired compressed data when the control command instructs the calculation result to be decompressed.

6. The computing accelerator as described in claim 5, characterized in that, The compression module is further configured to control the DMAC to store the calculation result into the memory when the control command instructs that the calculation result should not be compressed. The decompression module is further configured to control the DMAC to store the calculation result in the memory into the first cache when the control instruction indicates that the calculation result should not be decompressed.

7. The computing accelerator as described in any one of claims 2-5, characterized in that, The compression module includes a fragmentation module and at least one compression engine. The sharding module is used to shard the calculation result to obtain at least one sub-calculation result; Each of the at least one compression engine is used to compress one of the at least one sub-computation results to obtain sub-compressed data, wherein the sum of the sub-compressed data generated by each of the at least one compression engine constitutes the compressed data.

8. The computing accelerator as described in claim 7, characterized in that, Each of the at least one compression engine is specifically used for: The sub-calculation results are compressed to obtain sub-compressed results; Compare the size of the sub-compression result and the sub-computation result; When the sub-compression result is greater than the sub-calculation result, the sub-calculation result is used as the sub-compressed data; When the sub-compression result is not greater than the sub-calculation result, the sub-compression result is used as the sub-compressed data.

9. The computing accelerator as described in claim 8, characterized in that, Each of the at least one compression engine is further used for: When the sub-compression result is greater than the sub-calculation result, a compression failure identifier corresponding to the sub-compressed data is generated, wherein the compression failure identifier is controlled by the DMAC to be stored in the memory; When the sub-compression result is not greater than the sub-calculation result, a compression success identifier corresponding to the sub-compressed data is generated, wherein the compression success identifier is controlled by the DMAC to be stored in the memory.

10. The computing accelerator as described in claim 9, characterized in that, The decompression module is specifically used for: Receive the sub-compressed data retrieved from the memory by the DMAC; When the identifier corresponding to the sub-compressed data is a compression failure identifier, the sub-compressed data is stored as the second input data in the first cache; When the identifier corresponding to the sub-compressed data is a successful compression identifier, the sub-compressed data is decompressed, and the decompressed data is stored in the first cache as the second input data.

11. A processing apparatus, characterized in that, include: The judgment module is used to determine whether the computation accelerator should compress and decompress the calculation result obtained after calculating the input data of the i-th layer in the neural network based on the sparsity of the input data of the i-th layer, where 1≤i≤N, N is the number of layers of the neural network, and the computation accelerator is a coprocessor outside the processing device. A compilation module is used to generate control instructions based on the determination result of the judgment module. The control instructions are used to instruct the computing accelerator whether to compress and decompress the calculation results. When the sparsity of the input data of the i-th layer of the neural network is greater than a threshold, it is determined that the computing accelerator compresses the calculation result and decompresses it when the calculation result is used as the input data of the (i+1)-th layer for the (i+1)-th layer calculation. When the sparsity of the input data of the i-th layer of the neural network is not greater than a threshold, it is determined that the computing accelerator will not compress the calculation result, and will not decompress the calculation result when using the calculation result as the input data of the (i+1)-th layer for the (i+1)-th layer calculation.

12. The processing apparatus as claimed in claim 11, characterized in that, The threshold is determined based on the gains and power costs of input / output (I / O) bandwidth, where the gains in I / O bandwidth indicate the reduction in I / O bandwidth caused by the accelerator compressing and decompressing the computation results, and the power costs indicate the increased power consumption caused by the accelerator compressing and decompressing the computation results.

13. A compression method, characterized in that, The compression method is applied to a computing accelerator, which includes a first cache and a second cache, and the method includes: The first input data of the i-th layer of the neural network obtained from the first cache, where 1≤i≤N, and N is the number of layers of the neural network, is multiplied by the weight data obtained from the second cache to obtain the calculation result. When the sparsity of the first input data is not greater than a threshold, the calculation result is the input data of the (i+1)-th layer of the neural network. When the first input data is greater than the threshold, the calculation result is compressed to obtain compressed data, and the decompressed data of the compressed data is used as the input data of the (i+1)th layer of the neural network. The compressed data is stored in a memory outside the computing accelerator.

14. The compression method as described in claim 13, characterized in that, Also includes: Retrieve the compressed data from the memory; The compressed data is decompressed, and the decompressed data is stored in the first cache as the second input data; Perform matrix multiplication on the second input data obtained from the first cache.

15. The compression method as described in claim 14, characterized in that, The method includes: Obtain control commands, which are used to indicate whether to compress and decompress the calculation results; Parse the control commands; The step of compressing the calculation results to obtain compressed data includes: When the control command instructs the calculation result to be compressed, the calculation result is compressed to obtain the compressed data; The decompression of the compressed data includes: When the control command instructs that the calculation result be decompressed, the compressed data is decompressed.

16. The compression method as described in claim 15, characterized in that, The method further includes: When the control command instructs that the calculation result should not be compressed or decompressed, the calculation result is stored in the memory, and the calculation result is retrieved from the memory and stored in the first cache.

17. A compression method, characterized in that, The compression method is applied to a computing accelerator, which includes a first cache and a second cache, and the method includes: A matrix multiplication operation is performed on the first input data of the i-th layer of the neural network obtained from the first cache and the weight data obtained from the second cache to obtain the calculation result, where 1≤i≤N, and N is the number of layers of the neural network; Obtain control commands, which are used to indicate whether to compress and decompress the calculation results; When the control command instructs the calculation result to be compressed, the calculation result is compressed to obtain compressed data, and the compressed data is stored in a memory outside the computing accelerator. The decompressed data of the compressed data is used as the input data of the (i+1)th layer of the neural network. When the control command instructs that the calculation result not to be compressed, the calculation result is stored in a memory outside the computing accelerator.

18. The method as described in claim 17, characterized in that, The method further includes: When the control command instructs the calculation result to be decompressed, the compressed data obtained from the memory is decompressed, and the decompressed data is used as the second input data for matrix multiplication. When the control command instructs that the calculation result should not be decompressed, the calculation result obtained from the memory is used as the second input data for matrix multiplication.

19. A processing method, characterized in that, Applied to a processing device, including: Based on the sparsity of the input data of the i-th layer in the neural network, it is determined whether the computation accelerator should compress and decompress the calculation result obtained after calculating the input data of the i-th layer, where 1≤i≤N, N is the number of layers of the neural network, and the computation accelerator is a coprocessor outside the processing device. Generate control instructions, which instruct the computing accelerator whether to compress and decompress the computation results; The step of determining whether the computation accelerator should compress and decompress the computation result obtained after computing the i-th layer input data based on the sparsity of the i-th layer input data in the neural network includes: When the sparsity of the input data of the i-th layer of the neural network is greater than a threshold, it is determined that the computing accelerator compresses the calculation result and decompresses it when the calculation result is used as the input data of the (i+1)-th layer for the (i+1)-th layer calculation. When the sparsity of the input data of the i-th layer of the neural network is not greater than a threshold, it is determined that the computing accelerator will not compress the calculation result, and will not decompress the calculation result when using the calculation result as the input data of the (i+1)-th layer for the (i+1)-th layer calculation.

20. The method as described in claim 19, characterized in that, The threshold is determined based on the gains and power costs of input / output (I / O) bandwidth, where the gains in I / O bandwidth indicate the reduction in I / O bandwidth caused by the accelerator compressing and decompressing the computation results, and the power costs indicate the increased power consumption caused by the accelerator compressing and decompressing the computation results.

21. A processing apparatus, characterized in that, include: Memory, used to store instructions; A processor for reading instructions from the memory and executing the processing method of claim 19 or claim 20.

22. A computer storage medium, characterized in that, The storage medium stores a software program that, when read and executed by one or more processors, implements the processing method of claim 19 or claim 20.

Citation Information

Patent Citations

  • Mobile speech recognition hardware accelerator

    US20150199963A1

  • Deep neural network processing on hardware accelerators with stacked memory

    US20160379115A1