Data compression method and device, electronic equipment and computer readable storage medium

By dividing the data into N storage blocks for initial compression and recompression, the problem of low decoding performance in existing data compression algorithms is solved, and parallel processing and efficient decompression are achieved.

CN114640354BActive Publication Date: 2025-11-04SUZHOU DENGLIN TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210301266.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-24
Publication Date
2025-11-04
Estimated Expiration
2042-03-24

AI Technical Summary

Technical Problem

Existing data compression algorithms, such as run-length compression and Huffman compression, have poor decoding performance, resulting in low decompression efficiency and the inability to process in parallel.

Method used

The data to be compressed is divided into N storage blocks for initial compression. Storage blocks that do not conform to the preset rules are selected for recompression to make the data format of all storage blocks uniform, support parallel processing and simplify decoding logic.

Benefits of technology

It improves compression and decompression rates and throughput, simplifies decoding logic, and enhances decompression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114640354B_ABST
    Figure CN114640354B_ABST
Patent Text Reader

Abstract

The application relates to a data compression method and device, electronic equipment and a computer readable storage medium, and belongs to the technical field of computers. The data compression method comprises the following steps: performing initial compression on original data stored in each of N memory banks to obtain initial compressed data and corresponding data indexes, wherein the N memory banks collectively store the same group of to-be-compressed data; selecting a memory bank from the N memory banks, wherein the initial compressed data of the memory bank does not meet a preset rule; and performing re-compression on the original data stored in the memory bank, which does not meet the preset rule, to obtain new compressed data and corresponding new data indexes, wherein the new compressed data meets the preset rule. According to the application, the same group of to-be-compressed data is grouped and stored in the N memory banks, so that the decompression processes among the memory banks can be processed in parallel, and the decompression rate and the decompression throughput are improved; meanwhile, the compression method makes the format of the finally compressed data uniform, and thus simplifies the decoding logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and specifically relates to a data compression method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In recent years, Artificial Intelligence (AI) technology has developed rapidly and achieved remarkable results, especially in areas such as image detection and recognition, and speech recognition, where AI's recognition rate has surpassed that of humans. Neural network processing is a crucial technology for realizing AI, and convolutional neural network (CNN) algorithms, as one of the representative algorithms of existing deep learning algorithms, rely heavily on convolution operations in the discrete number domain for a large portion of their inference and prediction parts. Convolution operations involve two types of input data: real-time input feature maps and offline weights. Convolution operations involve multiplying and accumulating the input feature maps and weights, resulting in a massive computational load, compounded by the inherent sparsity of the weight data. Therefore, compressing this type of weight data not only reduces the amount of data transferred from external storage modules to internal computing modules but also effectively reduces the amount of data involved in internal computations.

[0003] Common compression algorithms include run-length encoding (RUE) and Huffman encoding. Run-length encoding encodes strings based on consecutive repeating characters. Its drawbacks include a high dependence on string composition for compression ratio, and because it's a stream encoding, decompression requires serial decoding, resulting in low performance. Huffman encoding, on the other hand, uses a variable-length cipher to encode the source symbols. Its advantages include high compression ratio, but its disadvantages include a complex compression algorithm, time-consuming execution, and serial decoding, leading to complex decoding logic and low speed and performance. Summary of the Invention

[0004] Therefore, the purpose of this application is to provide a data compression method, apparatus, electronic device and computer-readable storage medium to improve the problems of existing compression methods being cumbersome and only serial decoding during decoding, resulting in low decompression efficiency.

[0005] The embodiments of this application are implemented as follows:

[0006] In a first aspect, embodiments of this application provide a data compression method, comprising: performing initial compression on the original data stored in each of N storage banks to obtain initial compressed data and a corresponding data index; wherein the N storage banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2; selecting from the N storage banks the initial compressed data does not conform to a preset rule; recompressing the original data stored in the storage banks that do not conform to the preset rule to obtain new compressed data and a corresponding new data index, wherein the new compressed data conforms to the preset rule.

[0007] In this application example, by grouping the same set of data to be compressed into N storage units, since each storage unit is a relatively independent storage element, the compression and decompression processes between the storage units can be processed in parallel, improving the compression and decompression speed and throughput. At the same time, during compression, by filtering out storage units that do not conform to the preset rules after initial compression and then recompressing them, all storage units after final compression conform to the preset rules, making the format of all compressed data uniform, simplifying the decoding logic, and having the characteristics of being friendly to decompression hardware implementation.

[0008] In one possible implementation of the first aspect embodiment, selecting a storage bank from N storage banks whose initial compressed data does not conform to a preset rule includes: obtaining the number of rows occupied by the initial compressed data in each storage bank; selecting a storage bank from the N storage banks whose initial compressed data row count is not equal to a specified row count, wherein the storage bank whose initial compressed data row count is not equal to the specified row count is the storage bank that does not conform to the preset rule.

[0009] In this embodiment, the number of rows occupied by the initial compressed data of the storage unit is used to determine whether the storage unit conforms to the preset rules, without the need to introduce other conditions. This has the advantage of simple judgment logic, which can quickly select storage units that do not conform to the preset rules. At the same time, the number of rows can be set as needed, which improves the applicability and flexibility of the solution. Most importantly, since the number of rows is the smallest storage granularity of the storage unit, storage units that occupy the same number of rows but have different numbers of elements in the rows occupy the same storage space. Therefore, using the number of rows as a judgment index can also reduce the number of storage units that are judged to not conform to the preset rules, that is, reduce the amount of data in the storage units that need to be recompressed, thereby improving compression efficiency.

[0010] In one possible implementation of the first aspect embodiment, the number of rows is specified as the maximum number of rows, which is the maximum number of rows occupied by the initial compressed data of the N storage units.

[0011] In this embodiment of the application, by selecting the maximum number of rows as the specified number of rows, the number of rows occupied by the data in all storage units is consistent, which is the maximum number of rows. This greatly simplifies the logic of hardware decompression, which requires specifying how much data to read from the storage unit in order to complete the decompression of this weight group.

[0012] In one possible implementation of the first aspect embodiment, recompressing the original data stored in a storage device that does not conform to a preset rule includes: for each storage device that does not conform to the preset rule, selecting a target storage device from all storage devices that conform to the preset rule, which has the smallest number of data rows after initial compression and whose number of data rows after initial compression is greater than the number of data rows after initial compression of the storage device that does not conform to the preset rule; and recompressing the original data stored in the storage device that does not conform to the preset rule based on the number of data rows after initial compression of the target storage device, so that the number of data rows after recompression is consistent with the number of rows occupied by the initially compressed data in the target storage device.

[0013] In this embodiment, when recompressing the original data stored in a storage device that does not conform to the preset rules, the recompression is performed based on the target storage device. This ensures that the number of data rows after recompression is consistent with the number of rows occupied by the initial compressed data in the target storage device. Simultaneously, when selecting the target storage device, the storage device with the smallest number of initially compressed data rows among all storage devices conforming to the preset rules, and whose initial compressed data row count is greater than that of the storage device that does not conform to the preset rules, is selected as the target storage device. This reduces the amount of data introduced during recompression, thereby improving compression efficiency. For example, assuming that the storage devices conforming to the preset rules have 2, 4, or 5 initially compressed data rows, and the storage devices that do not conform to the preset rules have 3 initially compressed data rows, based on the above principle, the target storage device is the storage device with 4 initially compressed data rows. Thus, when recompressing the storage device that does not conform to the preset rules, the number of newly compressed data rows is 4, not 5, thereby reducing the amount of data introduced and improving compression efficiency.

[0014] In one possible implementation of the first aspect embodiment, based on the number of data rows after initial compression in the target storage, the original data stored in the storage that does not conform to the preset rules is recompressed, including: obtaining a first number of zero-value data in the original data stored in the target storage and obtaining a second number of zero-value data in the original data stored in the storage that does not conform to the preset rules; obtaining the absolute value of the difference between the first number and the second number, and selecting the minimum value between the absolute value and the second value; and recompressing the zero-value data in the original data stored in the storage that does not conform to the preset rules, starting from the lowest address, as non-zero data.

[0015] In this embodiment, when recompressing the original data stored in a memory that does not conform to the preset rules, the zero-value data, starting from the lowest address, of the original data stored in the memory that does not conform to the preset rules is treated as non-zero data and recompressed. This can quickly recompress the original data stored in the memory that does not conform to the preset rules into a format consistent with that of the memory that conforms to the preset rules. At the same time, it minimizes the number of zero-value data treated as non-zero data, thereby improving the recompression and decompression speed.

[0016] In one possible implementation of the first aspect embodiment, based on the number of data rows after initial compression of the target storage, the original data stored in the storage that does not conform to the preset rules is recompressed, including: obtaining a first difference between the number of original data stored in the storage that does not conform to the preset rules and the number of initially compressed data corresponding to the target storage; obtaining a second difference between the number of zero-value data in the original data stored in the storage that does not conform to the preset rules and the first difference; and recompressing the zero-value data in the original data stored in the storage that does not conform to the preset rules, starting from the highest address and counting the number of the second difference, as non-zero data.

[0017] In this embodiment, when recompressing the original data stored in a memory cell that does not conform to the preset rules, the zero-value data of the second-to-last difference number starting from the highest address in the original data stored in the memory cell that does not conform to the preset rules is treated as non-zero data and recompressed. This can quickly recompress the original data stored in the memory cell that does not conform to the preset rules into a format consistent with that of the memory cell that conforms to the preset rules. At the same time, during recompression, only some zero-value data is treated as non-zero data and no additional data is introduced, which can improve the decompression efficiency.

[0018] In one possible implementation of the first aspect embodiment, the original data stored in each of the N storage blocks is initially compressed, including: removing zero-value data stored in each storage block and arranging the remaining original data together in sequence; and padding the rows occupied by the arrangement with specified numerical data.

[0019] In this embodiment, by using data with specified values ​​to fill in the spaces in the rows after permutation and combination, the compressed data consists of integer rows. This allows the hardware to better distinguish different compressed data groups during decompression, thereby speeding up the decompression process.

[0020] Secondly, embodiments of this application also provide a data compression apparatus, including: an initial compression module, a selection module, and a recompression module; the initial compression module is used to initially compress the original data stored in each of N storage banks to obtain initial compressed data and a corresponding data index; wherein, the N storage banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2; the selection module is used to select storage banks from the N storage banks whose initial compressed data does not conform to a preset rule; the recompression module is used to recompress the original data stored in the storage banks that do not conform to the preset rule to obtain new compressed data and a corresponding new data index, wherein the new compressed data conforms to the preset rule.

[0021] Thirdly, embodiments of this application also provide an electronic device, including: a memory and a processor, the processor being connected to the memory; the memory being used to store a program and to store data to be compressed; the processor being used to invoke the program stored in the memory to execute the method provided by any possible implementation of the first aspect embodiment and / or in combination with the first aspect embodiment.

[0022] Fourthly, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when run by a processor, performs the method provided by any possible implementation of the first aspect embodiments and / or in combination with the first aspect embodiments.

[0023] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly described below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The above and other objects, features, and advantages of this application will become clearer through the drawings. The same reference numerals indicate the same parts in all the drawings. The drawings are not intentionally drawn to scale to actual size; the focus is on illustrating the main points of this application.

[0025] Figure 1 A schematic flowchart of a data compression method provided in an embodiment of this application is shown.

[0026] Figure 2This illustration shows a schematic diagram of data to be compressed stored in bank0 and bank1, as provided in an embodiment of this application.

[0027] Figure 3 This illustration shows an initial compressed data and its corresponding data index obtained after initial compression of the original data stored in bank0 and bank1, according to an embodiment of this application.

[0028] Figure 4 This illustration shows a schematic diagram of a new compressed data obtained by recompressing the original data stored in bank1, and the corresponding new data index, provided by an embodiment of this application.

[0029] Figure 5 This illustration shows a schematic diagram of a new compressed data and a corresponding new data index obtained by recompressing the original data stored in bank1, as provided in another embodiment of this application.

[0030] Figure 6 A schematic diagram of a data compression device provided in an embodiment of this application is shown.

[0031] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

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

[0033] It should be noted that similar reference numerals and letters in the following figures denote similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, relational terms such as "first," "second," etc., in the description of this application are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one…" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0034] Furthermore, the term "and / or" in this application is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0035] In view of the shortcomings of existing data compression methods, this application provides a data compression method for compressing raw data, such as convolution weights used for convolution calculations. This method utilizes the sparsity characteristics of the raw data to achieve compression, offering advantages such as fast compression speed, high compression ratio, simple decoding logic, parallelizable decoding, and hardware-friendly decompression. It should be noted that the data compression method described in this application is not limited to the compression of convolution weights; it is applicable to the compression of any data with sparse characteristics.

[0036] The following will combine Figure 1 The data compression method provided in the embodiments of this application will be described.

[0037] S1: Perform initial compression on the original data stored in each of the N storage entities to obtain the initial compressed data and the corresponding data index.

[0038] Considering that data is typically stored in a storage buffer, such as a memory, and that a storage buffer usually consists of M banks, this application, in order to accelerate compression efficiency and enable parallel operation during decompression, stores the same set of data to be compressed across N banks. That is, N banks jointly store the same set of data to be compressed, with each bank storing a portion of that set of data. This is equivalent to dividing the data to be compressed into N parts and storing them in N banks. Since each bank of the buffer is a relatively independent storage element, the decompression process between banks can be parallelized, improving the decompression rate and throughput. Here, N is a positive integer greater than or equal to 2, and M is a positive integer greater than or equal to N.

[0039] Assuming each row of each memory bank has a data bit width of C, and [C-1:0] represents the bit range of the storable data, where commonly used data bit widths in this field include, but are not limited to, 64, 128, and 256 bits. Let c represent the number of bits occupied by a single data item; typically, c should be a multiple of 4. Therefore, each row can store C / c data items. The data types supported by this application include 4-bit integers, 8-bit integers, 16-bit integers, 32-bit integers, 16-bit floating-point numbers, 32-bit floating-point numbers, and 64-bit floating-point numbers.

[0040] The data compression method proposed in this application is based on each storage block as the smallest unit. During compression, the original data stored in each of the N storage blocks is initially compressed to obtain the initial compressed data and the corresponding data index.

[0041] In one optional implementation, the initial compression process for the original data stored in each memory cell can be as follows: first, remove the zero-value data stored in each memory cell, and then arrange and combine the remaining original data sequentially to obtain the initial compressed data. This application considers the sparsity of the weight data participating in the convolution operation; therefore, during compression, zero-value data in the original data stored in the memory cell can be removed first, and then the remaining original data can be tightly arranged and combined together. Furthermore, to facilitate the restoration of the compressed data during decompression, a corresponding data index needs to be generated to indicate which original data are zero-value data and have been removed.

[0042] To make it easier to understand, let's take an example. Suppose the original data stored in a certain memory is {0, 1, 3, 0, 0, 0, 0, 0, 5, 2, 5, 1, 0, 0, 1}, then the initial compressed data obtained after initial compression is {1, 3, 5, 2, 5, 1, 1}.

[0043] The data index used to restore the compressed original data can be implemented in several ways. For example, it can be constructed using 1s and 0s, where 1 represents non-zero values ​​in the original data and 0 represents zero values. Taking the example above, the corresponding data index would be {0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1}. Since the data at position 0 in the example above is "0", the corresponding index is 0; the data at position 1 is "1", the corresponding index is 1; and so on, the data at position 14 is "0", the corresponding index is 0; and the data at position 15 is "1", the corresponding index is 1.

[0044] Of course, besides the data indexing method described above, other methods can also be used. For example, the data index corresponding to the compressed original data can be determined according to the absolute position of the non-zero value data in the storage. Taking the example above again, the corresponding data index is {1, 2, 9, 10, 11, 12, 15}, that is, the data index represents the absolute position of the original data retained after compression in the original data. For the original data "1" retained after compression, its position number in the original data is 1; for the original data "3" retained after compression, its position number in the original data is 2; for the original data "5" retained after compression, its position number in the original data is 9; for the original data "2" retained after compression, its position number in the original data is 10; for the original data "5" retained after compression, its position number in the original data is 11; for the original data "1" retained after compression, its position number in the original data is 12; for the original data "1" retained after compression, its position number in the original data is 15.

[0045] Furthermore, the data index corresponding to the compressed original data can be determined according to the absolute position of the zero weight in the original data. Taking the example above, the corresponding data index would be {0, 3, 4, 5, 6, 7, 8, 13, 14}, where "0" in the data index represents the 0th position of the zero weight in the original data before compression; "3" represents the 3rd position; "4" represents the 4th position; and so on, with "14" representing the 14th position.

[0046] Furthermore, the data index corresponding to the compressed original data can be determined according to the number of zero-value data between each non-zero value in the original data and the preceding non-zero value. Taking the example above, the corresponding data index would be {1, 0, 6, 0, 0, 0, 2}. For the original data "1" retained after compression, the number of zero-value data between it and the preceding non-zero value (which also has no preceding non-zero value) is 1; for the original data "3" retained after compression, the number of zero-value data between it and the preceding non-zero value (which has a preceding non-zero value "1") is 0; for the original data "5" retained after compression, the number of zero-value data between it and the preceding non-zero value (which has a preceding non-zero value "3") is 6; for the original data "2" retained after compression, the number of zero-value data between it and the preceding non-zero value (which has a preceding non-zero value "3") is 6; and so on. For the non-zero value data "5", the number of zero values ​​in the middle interval is 0; for the original data "5" retained after compression, the number of zero values ​​in the middle interval is 0 relative to the previous non-zero value data (the non-zero value data before it is "2"); for the original data "1" retained after compression, the number of zero values ​​in the middle interval is 0 relative to the previous non-zero value data (the non-zero value data before it is "5"); for the original data "1" retained after compression, the number of zero values ​​in the middle interval is 2 relative to the previous non-zero value data (the non-zero value data before it is "1").

[0047] In addition to the methods described above, the data index corresponding to the compressed original data can also be determined according to the number of non-zero value data between the zero value data and the previous zero value data in the original data. It should be noted that this application does not restrict the implementation method of the data index; any data indexing method that can restore the compressed original data to its original form based on the data index is acceptable.

[0048] In one optional implementation, the initial compression process for the original data stored in each of the N storage banks can be as follows: Remove the zero-value original data stored in each storage bank, and sequentially arrange and combine the remaining original data. Then, pad the rows occupied by the combined data with specified numerical data. When performing initial compression on the original data and sequentially arranging and combining the remaining original data, if there are still empty rows after the combined data is arranged, the empty rows can be filled (pasted) with specified numerical values ​​(such as zero-value data or useless data). By padding the occupied rows, the hardware can better distinguish different weighted sets, thus accelerating the decompression efficiency.

[0049] To make it easier to understand, let's illustrate with an example. Suppose each row of each memory bank can store 8 data items. After compressing 16 initial raw data items, we get 7 non-zero data items. Since the row occupied by these 7 non-zero data items still has a space, we can use 0 to pad the remaining space. As another example, after compressing 16 initial raw data items, we get 9 non-zero data items. These 9 non-zero data items will occupy two rows, with the second row containing only 1 data item and 7 remaining spaces. Therefore, we can use 0 to pad the remaining 7 spaces.

[0050] By filling the rows containing spaces with specified numerical data after compression, the compressed data consists of integer rows. This allows the hardware to better distinguish between different compressed data groups during decompression, thus speeding up the decompression process. The amount of data filled is calculated as C / c * the number of rows of initially compressed data - the number of non-zero data in the original data, expressed by the formula: C / c * compressed_entry_for_bank[i] - non_zero_count[i], where C / c represents the number of data items that can be stored per row, compressed_entry_for_bank[i] represents the number of rows of initially compressed data in the i-th storage bank, and non_zero_count[i] represents the number of non-zero data items in the original data stored in the i-th storage bank. It should be noted that if quantization is required during the initial compression of the original data stored in the storage bank, one implementation method can first quantize the stored original data (such as floating-point data) (i.e., convert floating-point data to fixed-point data), and then perform initial compression on the quantized fixed-point data. Quantization establishes an effective data mapping relationship, bridging fixed-point and floating-point data, thus achieving significant gains with minimal loss of precision. The principles of quantization and dequantization are explained below:

[0051] The quantization formula for converting floating-point data to fixed-point data is Q = Z + R / S, and the dequantization formula for converting fixed-point data to floating-point data is R = (QZ)*S. Here, R represents the actual floating-point value, Q represents the quantized fixed-point value, Z represents the quantized fixed-point value corresponding to the floating-point value 0, and S is the smallest scale that can be represented after fixed-point quantization. The formulas for calculating S and Z are as follows:

[0052] S = (Rmax - Rmin) / (Qmax - Qmin), Z = Qmax - Rmax / S. Where Rmax represents the maximum floating-point value, Rmin represents the minimum floating-point value, Qmax represents the maximum fixed-point value, and Qmin represents the minimum fixed-point value.

[0053] In this system, S and Z are both quantization parameters, while Q and R can be calculated using formulas. Whether it's the quantized Q or the dequantized floating-point value R, if they exceed their respective maximum representable range, they need to be truncated (if exceeding the maximum value, use the maximum value; if less than the minimum value, use the minimum value). The floating-point value 0 plays a crucial role in neural networks; for example, 0 is used for padding. Therefore, a precise integer value must correspond to the floating-point value 0 (i.e., quantization zero).

[0054] The following explains the model quantization process. After model training, the weights are often distributed within a finite range, such as [-2.0, 6.0]. If int8 (signed 8-bit integer) is used for model quantization, the fixed-point quantization value range is [-128, 127]. The calculation process for S and Z is as follows:

[0055]

[0056] Z=127-6.0÷0.031372549≈127-191.25≈-64.25≈-64

[0057] The following correspondence table exists:

[0058]

[0059]

[0060] Assuming R is 0.28, the corresponding value of Q is as follows:

[0061] Q=0.28÷0.031372549+(-64)≈8.925-64≈-55.075≈-55

[0062] In this way, the quantified values ​​of all weights can be obtained one by one.

[0063] S2: Select the storage bank from N storage banks whose initial compressed data does not conform to the preset rules.

[0064] After initially compressing the original data stored in each of the N storage entities to obtain the initial compressed data and the corresponding data index, the storage entities whose initial compressed data does not conform to the preset rules are selected from the N storage entities so that the original data stored in the storage entities that do not conform to the preset rules can be recompressed.

[0065] The process of selecting storage bodies from N storage bodies whose initial compressed data does not conform to the preset rules can be as follows: obtain the number of rows occupied by the initial compressed data of each storage body, and select storage bodies from N storage bodies whose number of data rows after initial compression is not equal to the specified number of rows. The storage bodies whose number of data rows is not equal to the specified number of rows are the storage bodies that do not conform to the preset rules.

[0066] B can be used to represent the number of specified rows corresponding to these N storage banks, that is, how many specified rows these N storage banks can have. The value of B is an integer from 1 to N, such as a minimum value of 1 and a maximum value of N. In one implementation, the specified row number is the maximum number of rows occupied by the original data stored in the N storage banks after initial compression. In this case, there is only one specified row number, that is, B = 1. Among them, the storage bank with less than the maximum number of rows is the storage bank that does not conform to the preset rule. For ease of understanding, let's take an example. Suppose there are two storage banks, namely storage bank 0 and storage bank 1. If the number of rows occupied by the initial compressed data in storage bank 0 is 3, and the number of rows occupied by the initial compressed data in storage bank 1 is 2, since the number of rows of the original data in storage bank 1 after initial compression is less than the maximum number of rows (3 in this case), storage bank 1 is the storage bank that does not conform to the preset rule. This method can be extended to more storage banks and is not limited to the case of 2 storage banks in the above example.

[0067] In the implementation where the maximum number of rows is specified, after recompressing the original data in storage units that do not conform to the preset rules, the number of rows occupied by the newly compressed data is equal to the maximum number of rows. At this time, the number of rows occupied by data in all storage units is the same, which is the maximum number of rows. This greatly simplifies the logic of hardware decompression, which requires knowing how much data to read from the storage unit to complete the decompression of this weight group. For example, it is only necessary to read the maximum number of rows * C * N data from the storage unit to complete the decompression of this weight group.

[0068] In another implementation, the specified number of rows can include not only the maximum number of rows but also other numbers of rows. That is, there can be multiple specified number of rows, where B is an integer greater than or equal to 2 and less than N. For ease of understanding, let's illustrate with an example. Suppose there are four storage banks: storage bank 0, storage bank 1, storage bank 2, and storage bank 3. If the initial compressed data in storage bank 0 occupies 3 rows, storage bank 1 occupies 2 rows, storage bank 2 occupies 1 row, and storage bank 3 occupies 2 rows. Assuming the specified number of rows B = 2, meaning the number of specified rows is 2, such as 3 rows or 2 rows, then storage bank 2 is the one whose row count does not meet the specified number among the four storage banks (storage bank 0, storage bank 1, storage bank 2, and storage bank 3). Thus, during recompression, only storage bank 2 is recompressed, which improves compression efficiency.

[0069] In one implementation, the specified number of rows can be determined as follows, where the number B of specified rows needs to be preset, and B is an integer from 1 to N. If B is 1, the specified number of rows is the maximum number of rows; if B is an integer greater than or equal to 2, the specified number of rows includes the maximum number of rows as well as B-1 other rows. The selection principle for the other rows can be: after selecting the other rows, after recompressing the storage that does not conform to the preset rules, the sum of the number of data rows after recompressing all storage that does not conform to the preset rules and the number of data rows after initial compression of storage that conforms to the preset rules must be minimized. Taking the example of four memory banks above, if B = 2, the remaining specified number of rows (excluding the maximum of 3) needs to be chosen between row number 1 and row number 2. If row number 1 is chosen, memory banks 1 and 3 need to be recompressed, resulting in 3 rows for both. In this case, the total number of rows for the four memory banks is 3 rows from memory bank 0 + 3 rows from memory bank 1 + 1 row from memory bank 2 + 3 rows from memory bank 3 = 10 rows. If row number 2 is chosen, only memory bank 2 needs to be recompressed, resulting in 2 rows. In this case, the total number of rows for the four memory banks is 3 rows from memory bank 0 + 2 rows from memory bank 1 + 2 rows from memory bank 2 + 2 rows from memory bank 3 = 9 rows. Therefore, the remaining specified number of rows should be 2.

[0070] S3: Recompress the original data stored in the memory that does not conform to the preset rules.

[0071] After selecting the storage bank from N storage banks whose initial compressed data does not conform to the preset rules, the original data stored in the storage bank that does not conform to the preset rules is recompressed to obtain new compressed data and corresponding new data index. The recompression process is similar to the initial compression process, except that when recompressing, some zero-value data in the original data needs to be compressed as non-zero data so that the new compressed data obtained after recompression conforms to the preset rules.

[0072] In one implementation, the process of recompressing the original data stored in a storage body that does not conform to the preset rules may be as follows: for each storage body that does not conform to the preset rules, a target storage body is selected from the storage bodies that conform to the preset rules, and the original data stored in the storage body that does not conform to the preset rules is recompressed based on the number of data rows after the initial compression of the target storage body, so that the number of data rows after recompression is consistent with the number of data rows after the initial compression of the target storage body.

[0073] When selecting a target storage bank from storage banks that meet preset rules, it can be done by selecting the target storage bank with the smallest number of initially compressed data rows from all storage banks that meet the preset rules, and whose initially compressed data row count is greater than that of the storage bank that does not meet the preset rules. For ease of understanding, an example is provided. Assume there are four storage banks: storage bank 0, storage bank 1, storage bank 2, and storage bank 3. If the initially compressed data row count of storage bank 0 is 5, that of storage bank 1 is 4, that of storage bank 2 is 1, and that of storage bank 3 is 2, and if B = 2, then the specified row counts are 5 and 2. The storage banks that meet the preset rules are storage bank 0 and storage bank 3, while the storage banks that do not meet the preset rules are storage bank 1 and storage bank 2. When selecting a target storage device for storage device 1, it needs to be chosen from storage device 0 and storage device 3. Since storage device 1 has 4 rows of data after initial compression, the storage device with the smallest number of rows of data after initial compression, and which needs to be greater than 4, should be selected as the target storage device. Storage device 0 meets this rule. Therefore, for storage device 1, its target storage device is storage device 0. Similarly, when selecting a target storage device for storage device 2, it needs to be chosen from storage device 0 and storage device 3. Since storage device 2 has 1 row of data after initial compression, the storage device with the smallest number of rows of data after initial compression, and which needs to be greater than 2, should be selected as the target storage device. Storage device 3 meets this rule. Therefore, for storage device 2, its target storage device is storage device 3.

[0074] It should be noted that, in addition to using the above rule (for each storage cell that does not conform to the preset rule, selecting the target storage cell from all storage cells that conform to the preset rule with the smallest number of initially compressed data rows, and whose number of initially compressed data rows is greater than that of the storage cell that does not conform to the preset rule), the target storage cell can also be selected from all storage cells that conform to the preset rule with a number of initially compressed data rows greater than that of the storage cell that does not conform to the preset rule. For example, assuming that the storage cells that conform to the preset rule have 2, 4, or 5 initially compressed data rows, and the storage cells that do not conform to the preset rule have 3 initially compressed data rows, based on the above principle, the target storage cell is the storage cell with 4 initially compressed data rows. Of course, in another implementation, the storage cell with 5 initially compressed data rows can also be selected as the target storage cell. Therefore, the above example of selecting the target storage cell should not be construed as a limitation of this application.

[0075] When recompressing the original data stored in the target storage that does not conform to the preset rules, based on the number of data rows after the initial compression of the target storage, one implementation may be as follows: obtain a first number of zero-value data in the original data stored in the target storage, and obtain a second number of zero-value data in the original data stored in the storage that does not conform to the preset rules. Then, obtain the absolute value of the difference between the first number and the second number, and select the minimum value between the absolute value and the second value. Then, recompress the original data stored in the storage that does not conform to the preset rules. During recompression, the zero-value data in the original data stored in the storage that does not conform to the preset rules, starting from the lowest address (Least Significant Bit, LSB), is treated as non-zero data and recompressed. Assuming the number of zero-value data in the original data stored in each memory cell is represented by org_zero_count, the number of non-zero data is represented by non_zero_count, and the absolute value of the difference between the first and second counts is represented by delta_non_zero_count, then the minimum of the absolute value and the second count can be expressed as min(delta_non_zero_count, org_zero_count). Assuming the minimum value is 5, since the first 5 zero-value data starting from the lowest address are treated as non-zero data, during recompression, the first 5 zero-value data starting from the lowest address are no longer removed; only the subsequent zero-value data are removed.

[0076] It should be noted that since the non-zero data and zero-value data in the original data stored in the storage are relative, the above process can also be as follows: obtain the first number of non-zero data in the original data stored in the target storage, and obtain the second number of non-zero data in the original data stored in the storage that does not conform to the preset rules. Then obtain the absolute value of the difference between the first number and the second number. After that, obtain the minimum value between the absolute value and the number of zero-value data in the original data stored in the storage that does not conform to the preset rules. Treat the zero-value data with the first minimum number of values ​​starting from the lowest address in the original data stored in the storage that does not conform to the preset rules as non-zero data and re-compress it.

[0077] In another implementation, the recompression process shown in S3 can be as follows: obtain a first difference between the number of original data stored in the memory that does not conform to the preset rules and the number of initially compressed data corresponding to the target memory; then obtain the difference between the number of zero-value data in the original data stored in the memory that does not conform to the preset rules and the first difference to obtain a second difference; then recompress the original data stored in the memory that does not conform to the preset rules. During recompression, the zero-value data in the original data stored in the memory that does not conform to the preset rules, starting from the highest address (Most SignificantBit, MSB) and the number of the second difference, are treated as non-zero data and recompressed. Assuming the initial compressed data quantity corresponding to the target storage is 24, and the quantity of original data stored in the storage that does not conform to the preset rules is 32, then the first difference is 8. Assuming the quantity of zero-value data obtained from the original data stored in the storage that does not conform to the preset rules is 22, then the second difference is 22-8=16. That is, when recompressing, the first 16 zero-value data from the highest address in the original data stored in the storage that does not conform to the preset rules need to be treated as non-zero data and recompressed, while the remaining zero-value data are compressed normally (and need to be removed during compression).

[0078] To make it easier to understand, let's take an example. Assume N=2, C=256, c=32, then each storage bank can store 8 data items per row. Assume the original data to be compressed stored in bank0 and bank1 is as follows: Figure 2 As shown. Bank0 contains 13 zeros, and bank1 contains 22 zeros. Initial compression is performed on both banks, removing all zero data. Bank0 has 19 valid data entries remaining, requiring 5 additional zeros (8*3-19) to pad. Similarly, bank1 has 10 valid data entries, requiring 6 additional zeros (8*2-10) to pad. The initial compressed data and corresponding data indexes obtained after initial compression of the original data stored in banks0 and bank1 are shown below. Figure 3 As shown.

[0079] The data index generation process can be represented by two-dimensional coordinates to indicate the position of the original data in bank0. For example, coordinate (0, 0) represents the first element of row 0 (starting from the least significant bit), which is 0; (0, 2) represents the third element of row 0, which is 1; (1, 0) represents the first data in row 1, which is 8, and so on. For coordinates with a value of 0, a bit 0 is filled at the same index coordinate, indicating that the data at this coordinate is zero and is discarded. For coordinates with a non-zero value, a bit 1 is filled at the same index coordinate, indicating that the data at this coordinate is non-zero and is retained. Based on the above method, the data at coordinate (0, 0) has a value of 0, so the index at coordinate (0, 0) is 0; the data at coordinates (1, 0) and (0, 2) are non-zero, so the index at the same coordinate position is 1. By following this method, the compressed data and corresponding indices of all banks can be obtained. It should be noted that the data index in this example is constructed using 1s and 0s. For example, 1 represents non-zero values ​​in the original data, and 0 represents zero values, thus obtaining the corresponding data index. Besides this method, other methods described above can also be used.

[0080] Assuming the specified number of rows B = 1, since bank0 initially has 3 rows of compressed data and bank1 initially has 2 rows of compressed data, the original data stored in bank1 needs to be recompressed.

[0081] In one implementation, when recompressing the original data stored in bank1, the process can be as follows: First, obtain the first quantity (e.g., 13) of the data in the original data stored in bank0, and obtain the second quantity (e.g., 22) of the zero-value data in the original data stored in bank1. The absolute value of the difference between the first quantity and the second quantity is 9. Therefore, Min(9, 22) = 9. Thus, when recompressing the original data stored in bank1, the first 9 zero-value data starting from the lowest address (LSB) in the original data need to be treated as non-zero data for recompression. That is, the 5 zeros at coordinates (0, 0) to (0, 7) and the 4 zeros at coordinates (1, 0) to (1, 5) in the original data are treated as non-zero and recompressed. The new compressed data and corresponding new data index obtained after recompressing the original data stored in bank1 are as follows: Figure 4 As shown.

[0082] In another implementation, it is still used Figure 2In the example shown, after recompression, the number of data rows in bank1 is the same as the number of rows occupied by the initial compressed data in bank0. Since the initial compressed data in bank0 is 24, for the original 32 data rows in bank1, 8 zeros need to be compressed during recompression, resulting in 24 new compressed data rows. Since the original data stored in bank1 contains 22 zero-value data rows, during recompression, the first 14 (22-8) zero-value data rows starting from the highest address in the original data stored in bank1 need to be treated as non-zero data for recompression. In this implementation, the new compressed data and corresponding new data index obtained after recompressing the original data stored in bank1 are as follows: Figure 5 As shown.

[0083] Furthermore, if the specified number of rows is not 1, that is, B is an integer greater than or equal to 2 and less than N, in addition to recording the compressed data and corresponding data index of each bank, it is also necessary to record the value of B, the specified number of rows, and the number of rows occupied by each bank. Taking the above assumption of 4 banks, namely bank0, bank1, bank2, and bank3, as an example, if the initial compressed data of bank0 occupies 3 rows, the initial compressed data of bank1 occupies 2 rows, the initial compressed data of bank2 occupies 1 row, and the initial compressed data of bank3 occupies 2 rows. Assuming the specified number of rows is 2, such as 3 rows and 2 rows, then in addition to recording the compressed data and corresponding data index of each bank, it is also necessary to record: B = 2, the specified number of rows {3, 2}, and the number of rows corresponding to bank0 as 3, and the number of rows corresponding to bank1, bank2, and bank3 as 2. A set of binary numbers can be used to record the number of rows occupied by the compressed data in each bank. For example, binary 1110 can be used to record the number of rows occupied by the compressed data in bank0, bank1, bank2, and bank3. The lowest bit of the binary number 0 indicates that bank0 uses the zeroth element in the set {3, 2}, the second lowest bit indicates that bank1 uses the first element in the set {3, 2}, and so on.

[0084] Based on the same inventive concept, this application also provides a data compression device 100, such as... Figure 6 As shown. The data compression device 100 includes an initial compression module 110, a selection module 120, and a recompression module 130.

[0085] The initial compression module 110 is used to perform initial compression on the original data stored in each of the N storage banks to obtain the initial compressed data and the corresponding data index; wherein, the N storage banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2.

[0086] Selection module 120 is used to select from N storage banks the storage bank whose initial compressed data does not conform to the preset rules.

[0087] The recompression module 130 is used to recompress the original data stored in the storage body that does not conform to the preset rules, so as to obtain new compressed data and corresponding new data index, wherein the new compressed data conforms to the preset rules.

[0088] Optionally, the initial compression module 110, when performing initial compression on the original data stored in each of the N storage bodies, specifically performs the following: removing zero-value data stored in each storage body and arranging the remaining original data together in sequence; and padding the rows occupied by the arrangement with specified numerical data.

[0089] The selection module 120, when selecting storage bodies from N storage bodies whose initial compressed data does not conform to preset rules, is specifically used to: obtain the number of rows occupied by the initial compressed data of each storage body; select storage bodies from N storage bodies whose number of rows of data after initial compression is not equal to the specified number of rows, wherein the storage bodies whose number of rows of data after initial compression is not equal to the specified number of rows are the storage bodies that do not conform to preset rules.

[0090] Optionally, the recompression module 130, when recompressing the original data stored in the storage body that does not conform to the preset rules, specifically performs the following: for each storage body that does not conform to the preset rules, selects a target storage body from the storage bodies that conform to the preset rules, and recompresses the original data stored in the storage body that does not conform to the preset rules based on the number of data rows after the initial compression of the target storage body, so that the number of data rows after recompression is consistent with the number of rows occupied by the initial compressed data of the target storage body.

[0091] Optionally, the recompression module 130, when selecting a target storage unit from the storage units that conform to the preset rules for each storage unit that does not conform to the preset rules, specifically selects the target storage unit with the smallest number of data rows after initial compression from all storage units that conform to the preset rules, and the number of data rows after initial compression is greater than the number of data rows after initial compression of the storage unit that does not conform to the preset rules.

[0092] Optionally, the recompression module 130, when recompressing the original data stored in the target storage body that does not conform to the preset rules based on the number of data rows after the initial compression of the target storage body, specifically performs the following: obtaining a first number of zero-value data in the original data stored in the target storage body, and obtaining a second number of zero-value data in the original data stored in the storage body that does not conform to the preset rules; obtaining the absolute value of the difference between the first number and the second number, and selecting the minimum value between the absolute value and the second value; treating the zero-value data in the original data stored in the storage body that does not conform to the preset rules, starting from the lowest address, as non-zero data and recompressing it.

[0093] Optionally, the recompression module 130, when recompressing the original data stored in the memory that does not conform to the preset rules based on the number of data rows after the initial compression of the target memory, specifically performs the following: obtaining a first difference between the number of original data stored in the memory that does not conform to the preset rules and the number of the initially compressed data corresponding to the target memory; obtaining a second difference between the number of zero-value data in the original data stored in the memory that does not conform to the preset rules and the first difference; and treating the zero-value data in the original data stored in the memory that does not conform to the preset rules, starting from the highest address, with the number of the second difference count as non-zero data for recompression.

[0094] The data compression device 100 provided in this application embodiment has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.

[0095] like Figure 6 As shown, Figure 6 This diagram illustrates a structural block diagram of an electronic device 200 provided in an embodiment of this application. The electronic device 200 includes a transceiver 210, a memory 220, a communication bus 230, and a processor 240.

[0096] The transceiver 210, memory 220, and processor 240 are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 230 or signal lines. The transceiver 210 is used for transmitting and receiving data. The memory 220 is used to store data to be compressed and to store computer programs, such as... Figure 5The software functional module shown is the data compression device 100. The data compression device 100 includes at least one software functional module that can be stored in the memory 220 or embedded in the operating system (OS) of the electronic device 200 in the form of software or firmware. The processor 240 is used to execute executable modules stored in the memory 220, such as the software functional module or computer program included in the data compression device 100. For example, the processor 240 is used to initially compress the original data stored in each of N memory banks to obtain initial compressed data and a corresponding data index; wherein the N memory banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2; select memory banks from the N memory banks whose initial compressed data does not conform to a preset rule; re-compress the original data stored in the memory banks that do not conform to the preset rule to obtain new compressed data and a corresponding new data index, wherein the new compressed data conforms to the preset rule.

[0097] The memory 220 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0098] Processor 240 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or processor 240 can be any conventional processor.

[0099] Among them, the aforementioned electronic devices 200 include, but are not limited to, AI processors, computers, servers, etc.

[0100] This application embodiment also provides a non-volatile computer-readable storage medium (hereinafter referred to as the storage medium) storing a computer program, which, when run by a computer such as the electronic device 200 described above, executes the data compression method described above.

[0101] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0102] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0103] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0104] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, laptop, server, or electronic device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0105] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included 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 data compression method, characterized in that, include: The original data stored in each of the N storage banks is initially compressed to obtain the initial compressed data and the corresponding data index; wherein, the N storage banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2; Select from the N storage banks that the initial compressed data does not conform to the preset rules, wherein the preset rules include that the number of data rows after compression must be equal to the specified number of rows; The original data stored in the storage body that does not conform to the preset rules is recompressed to obtain new compressed data and corresponding new data index. The new compressed data conforms to the preset rules. The recompression process is similar to the initial compression process. During recompression, some zero-value data in the original data is compressed as non-zero data so that the new compressed data obtained after recompression conforms to the preset rules.

2. The method according to claim 1, characterized in that, Selecting storage banks from the N storage banks whose initial compressed data does not conform to preset rules includes: Get the number of rows occupied by the initial compressed data in each storage unit; Select from the N storage entities that have an initial compressed data row count that is not equal to the specified number of rows. The storage entities that have an initial compressed data row count that is not equal to the specified number of rows are those that do not conform to the preset rules.

3. The method according to claim 2, characterized in that, The specified number of rows is the maximum number of rows occupied by the initial compressed data of the N storage units.

4. The method according to claim 1, characterized in that, The original data stored in the memory that does not conform to the preset rules is recompressed, including: For each storage unit that does not conform to the preset rules, select the target storage unit from all storage units that conform to the preset rules, which has the smallest number of data rows after initial compression and whose number of data rows after initial compression is greater than the number of data rows after initial compression of the storage unit that does not conform to the preset rules. Based on the number of data rows after the initial compression of the target storage, the original data stored in the storage that does not conform to the preset rules is recompressed so that the number of data rows after recompression is consistent with the number of rows occupied by the initial compressed data of the target storage.

5. The method according to claim 4, characterized in that, Based on the number of data rows after initial compression of the target storage, the original data stored in the storage that does not conform to the preset rules is recompressed, including: Obtain a first number of zero-value data in the original data stored in the target storage body, and obtain a second number of zero-value data in the original data stored in the storage body that does not conform to the preset rule; Obtain the absolute value of the difference between the first quantity and the second quantity, and select the minimum value between the absolute value and the second quantity; In the original data stored in the memory that does not conform to the preset rules, the zero-value data starting from the lowest address and the number of minimum values ​​are treated as non-zero data and recompressed.

6. The method according to claim 4, characterized in that, Based on the number of data rows after initial compression of the target storage, the original data stored in the storage that does not conform to the preset rules is recompressed, including: Obtain the first difference between the number of original data stored in the storage body that does not conform to the preset rules and the number of initial compressed data corresponding to the target storage body; The difference between the number of zero-value data in the original data stored in the storage body that does not conform to the preset rule and the first difference is obtained to obtain the second difference; In the original data stored in the memory that does not conform to the preset rules, the zero-value data starting from the highest address and the first second difference number of zero-value data are treated as non-zero data and recompressed.

7. The method according to claim 1, characterized in that, Perform initial compression on the original data stored in each of the N storage banks, including: Remove zero-value data stored in each memory cell and then arrange and combine the remaining original data in sequence. Use specified numerical data to fill in the spaces in the rows occupied by the permutation and combination.

8. A data compression device, characterized in that, include: An initial compression module is used to perform initial compression on the original data stored in each of the N storage banks to obtain the initial compressed data and the corresponding data index; wherein, the N storage banks jointly store the same set of data to be compressed, and N is a positive integer greater than or equal to 2; The selection module is used to select from the N storage banks that the initial compressed data does not conform to a preset rule, wherein the preset rule includes that the number of data rows after compression must be equal to a specified number of rows; The recompression module is used to recompress the original data stored in the storage body that does not conform to the preset rules, so as to obtain new compressed data and corresponding new data index. The new compressed data conforms to the preset rules. The recompression process is similar to the initial compression process. During recompression, some zero-value data in the original data is compressed as non-zero data so that the new compressed data obtained after recompression conforms to the preset rules.

9. An electronic device, characterized in that, include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs and data to be compressed; The processor is configured to invoke a program stored in the memory to execute the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, performs the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Method and system for accelerating neural network processor and neural network processor

    CN107844829A

  • Data processing method and device and storage medium

    CN111767280A