Data compression method, data decompression method and electronic device

By establishing an initial lookup table and encoding the compressed data, efficient data compression and decompression are achieved in combination with the use of splitters, solving the problem of insufficient decompression speed in the prior art, and meeting the real-time read and write needs of the AI ​​engine.

CN116233019BActive Publication Date: 2025-04-25SHENZHEN CORERAIN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211533923.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-01
Publication Date
2025-04-25
Estimated Expiration
2042-12-01

AI Technical Summary

Technical Problem

The compression method adopted in the prior art is difficult to meet the real-time reading and writing needs of AI engines for large data volumes, especially in the decompression speed.

Method used

By using the data of the same value in the data to be compressed as an index, an initial lookup table is established, and encoding operations are performed on the values ​​corresponding to each index, adding a splitter to form an encoding list, and finally adding the encoding list to the lookup table to achieve data compression. When decompressing, use the splitter to search the target lookup table in parallel to obtain the decompression result.

Benefits of technology

It realizes efficient data compression and decompression, with a compression rate of 80%, effectively reducing bandwidth usage by 20%, and improving speed through parallel decompression, which can meet the real-time read and write needs of AI engines for large data volumes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116233019B_ABST
    Figure CN116233019B_ABST
Patent Text Reader

Abstract

The present application relates to a data compression method, a data decompression method and an electronic device. The method comprises: using the data of the same numerical value in the data to be compressed as an index to establish an initial lookup table, performing encoding operations on the numerical values ​​corresponding to each index in turn and then adding separators to obtain a coding list containing a target coding value and a target coding length, adding the coding list to the initial lookup table to obtain a target lookup table, dividing the data to be decompressed into at least two segments of code stream data on average, obtaining the index contained in each segment of code stream data and the location information of each segment of code stream data according to the separator of each segment of code stream data, searching the target lookup table in parallel according to the index and the location information, and obtaining the decompression result of the data to be decompressed. The present application can perform parallel decompression operations on compressed data to increase the decompression speed, so that the decompression speed meets the real-time reading and writing requirements of the AI ​​engine for large amounts of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data compression method, a data decompression method and an electronic device. Background Art

[0002] At present, with the rapid development of deep learning, convolutional neural networks require a large amount of storage bandwidth. In the existing technology, the Huffman compression algorithm is usually used to compress data to improve bandwidth utilization. Although the Huffman compression algorithm can improve bandwidth utilization to a certain extent, when decompressing data compressed by the Huffman algorithm, the value of the next bit must depend on the value of the previous bit for decompression, and the decompression process is serialized, resulting in a very slow decompression speed, which is difficult to meet the real-time reading and writing requirements of AI engines for large amounts of data. Summary of the invention

[0003] In view of the above, the present application provides a data compression method, a data decompression method and an electronic device, which aims to solve the technical problem that the compression method used in the prior art is difficult to meet the real-time reading and writing requirements of the AI ​​engine for large amounts of data.

[0004] In a first aspect, the present application provides a data compression method, the method comprising:

[0005] Taking data with the same value in the data to be compressed as an index, and establishing an initial lookup table according to the number of the indexes;

[0006] Perform encoding operations on the numerical values ​​corresponding to each of the indexes in turn to obtain encoding results, add separators to the encoding results, and obtain an encoding list including the target encoding value corresponding to each of the indexes and the target encoding length corresponding to each of the indexes;

[0007] The encoding list is added to the initial lookup table to obtain a target lookup table after the data to be compressed is compressed.

[0008] In a second aspect, the present application provides a data decompression method, the method comprising:

[0009] Reading the data to be decompressed, and evenly dividing the data to be decompressed into at least two segments of code stream data;

[0010] According to the delimiter of each segment of the bitstream data, an index contained in each segment of the bitstream data and position information of each segment of the bitstream data are obtained;

[0011] The target lookup table described in the first aspect is searched in parallel according to the index and the position information to obtain the decompression result of the data to be decompressed.

[0012] In a third aspect, the present application provides an electronic device, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0013] Memory, used to store computer programs;

[0014] The processor is used to implement the data compression method described in any embodiment of the first aspect when executing the program stored in the memory.

[0015] In a fourth aspect, the present application provides an electronic device, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0016] Memory, used to store computer programs;

[0017] The processor is used to implement the data decompression method described in any embodiment of the second aspect when executing the program stored in the memory.

[0018] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0019] The initial lookup table is established according to the number of indexes. After encoding the values ​​corresponding to each index in turn, a separator is added to obtain a coding list. The target lookup table can be quickly established. The compression rate of the target lookup table after encoding is 80%, which effectively reduces the bandwidth usage by 20%. Since the separator is added to the encoding result obtained by the encoding operation, the separator can be used to distinguish each index when the encoding result is decompressed by table lookup, so that the decompression operation can be processed in parallel, improving the situation where the value of the next bit depends on the value of the previous bit, thereby increasing the decompression speed, so that the decompression speed can meet the real-time reading and writing requirements of the AI ​​engine for large amounts of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0022] Figure 1 A flowchart diagram of a preferred embodiment of the data compression method of the present application;

[0023] Figure 2 A schematic diagram of the method flow for performing encoding operations for this application;

[0024] Figure 3 A flowchart diagram of a preferred embodiment of the data decompression method of the present application;

[0025] Figure 4 A schematic diagram of the structure of an electronic device for executing a data compression method and / or a data decompression method of the present application;

[0026] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0028] It should be noted that the descriptions involving "first", "second", etc. in this application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0029] The present application provides a data compression method. Figure 1 FIG. 1 is a flow chart of a method of an embodiment of a data compression method of the present application. The method may be executed by an electronic device, and the electronic device may be implemented by software and / or hardware. The data compression method includes:

[0030] Step S110: taking data with the same value in the data to be compressed as an index, and establishing an initial lookup table according to the number of the indexes;

[0031] Step S120: performing encoding operations on the values ​​corresponding to each of the indexes in turn to obtain encoding results, adding separators to the encoding results to obtain an encoding list including a target encoding value corresponding to each of the indexes and a target encoding length corresponding to each of the indexes;

[0032] Step S130: Add the coding list to the initial lookup table to obtain a target lookup table after the data to be compressed is compressed.

[0033] In this embodiment, the scheme is explained by taking the weight parameter of the convolutional neural network as an example of the data to be compressed. In actual application scenarios, due to the large amount of computation of the convolutional neural network, its reasoning running time is long, so it is necessary to encode (compress) the weight parameters of the model and then decode (decompress) them, so as to improve the bandwidth utilization and reduce the running reasoning time of the model. It is understandable that the data to be compressed can be the weight parameters of the artificial intelligence model, or other data that needs to be compressed first and then decoded to improve the system operation efficiency, such as the weight parameters of the recognition model in the fields of text recognition, speech recognition, etc., and can also be video data or audio data, etc., which are not limited here.

[0034] The data to be compressed are classified and counted, and the data with the same value in the data to be compressed are used as an index. For example, the value 174 appears 248 times, the value 176 appears 234 times, and the value 175 appears 232 times in the data to be compressed. Then, the 248 values ​​174 are used as an index, the 234 values ​​176 are used as an index, and the 232 values ​​175 are used as an index. An initial lookup table is established according to the number of indexes. In a further step, the initial lookup table may also include the value corresponding to the index and the frequency of occurrence of the value. Specifically, the data with the same value in the data to be compressed are used as an index, and an initial lookup table is established according to the number of indexes, including:

[0035] Counting data with the same value in the data to be compressed, and using the data with the same value as an index;

[0036] The frequency of each of the identical values ​​is counted, and the initial lookup table is established according to the identical values, the number of the indexes, and the frequency of the identical values.

[0037] Count the frequency of the same value in the data to be compressed, and build an initial lookup table based on the number of values, indexes, and the frequency of the same value. The initial lookup table can be sorted in sequence according to the index number. For example, by classifying and counting the weight parameters of one layer of the Resetnet50 network, resnet_v1_50_conv1_weights.npy, we can get the initial lookup table:

[0038] seq:0data:174freq:248

[0039] seq:1data:176freq:234

[0040] seq:2data:175freq:232

[0041] seq:3data:178freq:213

[0042] seq:4data:177freq:210

[0043] seq:5data:173freq:201

[0044] …

[0045] seq:143data:243freq:1

[0046] seq:144data:7freq:1

[0047] seq:145data:246freq:1

[0048] seq:146data:0freq:1

[0049] Among them, seq represents the index number, data represents the value, and freq represents the number of times the value appears. As the index gradually increases, after all the values ​​in the data to be compressed are counted, the maximum index number index_num can be obtained. The maximum index number of the above initial lookup table is 147.

[0050] After obtaining the initial lookup table, the encoding operation is performed on the numerical value corresponding to each index in turn according to the index number to obtain the encoding result, and the separator information (2'b11) is added to the end of the encoding result to obtain a coding list, wherein the coding list contains the target coding value corresponding to each index and the target coding length corresponding to each index. Since the separator is added to the coding result obtained by the encoding operation, when the coding result is subsequently decompressed by looking up the table, the separator can be used to distinguish each index, so that the decompression operation can be processed in parallel, improving the situation where the value of the next bit depends on the value of the previous bit, thereby improving the decompression speed. The coding list corresponding to the above initial lookup table is:

[0051] encode:011len:3

[0052] encode:0011len:4

[0053] encode:0111len:4

[0054] encode:00011len:5

[0055] encode:01011len:5

[0056] encode:00111len:5

[0057] …

[0058] encode:010000000011len:12

[0059] encode:001000000011len:12

[0060] encode:000100000011len:12

[0061] encode:010100000011len:12

[0062] Among them, encode represents the target encoding value corresponding to the index, and len represents the target encoding length corresponding to the index.

[0063] After obtaining the encoding list, add the encoding list to the initial lookup table to obtain the target lookup table after the compressed data to be compressed. The obtained target lookup table is:

[0064] seq:0data:174freq:248encode:011len:3

[0065] seq:1data:176freq:234encode:0011len:4

[0066] seq:2data:175freq:232encode:0111len:4

[0067] seq:3data:178freq:213encode:00011len:5

[0068] seq:4data:177freq:210encode:01011len:5

[0069] seq:5data:173freq:201encode:00111len:5

[0070] …

[0071] seq:143data:243freq:1encode:010000000011len:12

[0072] seq:144data:7freq:1encode:001000000011len:12

[0073] seq:145data:246freq:1encode:000100000011len:12

[0074] seq:146data:0freq:1encode:010100000011len:12

[0075] The quantized weight parameter is data with normal distribution. After statistical simulation, using the above compression method, the compression rate of the encoded target lookup table is 80%, which can effectively reduce 20% of the bandwidth occupancy in different network environments.

[0076] Reference Figure 2 As shown, it is a schematic diagram of the method flow of performing the encoding operation of the present application. Specifically, the encoding operation is performed on the numerical value corresponding to each of the indexes in turn, including:

[0077] Step A1, performing encoding operations on the values ​​corresponding to the indexes in sequence;

[0078] Step A2, determining whether the encoding length of the current encoding quantity after the encoding operation is performed is equal to the current maximum encoding length, if so, executing step A3, if not, executing step A4;

[0079] Step A3, obtaining a current code value of the current code quantity, performing an extended coding operation on the current code value, and executing step A2;

[0080] Step A4, adding one to the current maximum encoding length, and determining whether the current encoding quantity after the encoding operation is performed is greater than the maximum sequence number of the index, if so, executing step A5, if not, executing step A1;

[0081] Step A5: Stop the encoding operation.

[0082] After performing the encoding operation on the numerical value corresponding to the index, determine whether the encoding length of the current encoding quantity encode_cnt after the encoding operation is equal to the current maximum encoding length max(len). If the encoding length of encode_cnt is equal to max(len), obtain the current encoding value of the current encoding quantity, and perform an extended encoding operation on the current encoding value. The extended encoding operation refers to filling characters at the end of the encoding value. Since the extended encoding operation is encoded with the minimum encoding length, the consumption of transmission bandwidth can be reduced. For example, after performing the encoding operation on the value corresponding to the index number 2, the current encoding quantity encode_cnt is 3, the encoding length of encode_cnt is 4, and the current maximum encoding length max(len)4, that is, the encoding length of encode_cnt is equal to max(len). At this time, the current encoding value 01 of the current encoding quantity is obtained, and the encoding value obtained by performing the extended encoding operation on the current encoding value 01 is 000. At this time, the current encoding quantity encode_cnt is 4, and the encoding length of encode_cnt is 5. Since the encoding length of encode_cnt is not equal to max(len)4 at this time, the current maximum encoding length is increased by 1, and it is judged whether the current encoding quantity after performing the encoding operation is greater than the maximum index number (that is, it is judged whether the values ​​corresponding to all indexes have completed the encoding operation). If so, the encoding operation is stopped, and if not, the encoding operation is continued for the values ​​corresponding to the index. It should be noted that the current encoding value corresponding to the index number 2 is 01, and the target encoding value of the index number 2 with the separator added is 0111.

[0083] Further, the obtaining of the current code value of the current code quantity and performing an extended coding operation on the current code value includes:

[0084] Fill the tail of the current code value with a first character and a second character respectively, to obtain a code value filled with the first character and a code value filled with the second character;

[0085] The encoding value after the first character is filled is stored in the encoding list;

[0086] Determine whether the code value after the second character is filled contains the separator;

[0087] If yes, delete the encoded value after the second character is filled;

[0088] If not, the encoding value filled with the second character is stored in the encoding list.

[0089] The first character can be 0, and the second character can be 1. The first character and the second character are filled at the tail of the above current code value respectively to obtain the code value after filling with the first character and the code value after filling with the second character. Since the code value obtained by the encoding operation cannot contain a separator (2'b11), otherwise this encoding does not meet the encoding requirements (that is, the code value cannot have two consecutive separators). Therefore, the code value after filling with the first character 0 is directly stored in the code list. For the code value after filling with the second character 1, it is necessary to determine whether there is a separator. If so, the code value after filling with the second character needs to be deleted. If not, the code value after filling with the second character is also stored in the code list.

[0090] In one embodiment, the above-mentioned data compression method also includes: after obtaining the target lookup table, storing the target lookup table in a memory (for example, a double-rate synchronous dynamic random access memory) so that the corresponding decompression module can read the target lookup table from the double-rate synchronous dynamic random access memory for decompression when decompressing the data, thereby meeting the AI ​​engine's real-time reading and writing requirements for large amounts of data.

[0091] Reference Figure 3 , which is a method flow diagram of an embodiment of the data decompression method of the present application. The method can be executed by an electronic device, and the electronic device can be implemented by software and / or hardware. The data decompression method is a method of decompressing data after adopting the above data compression method, and the data decompression method includes:

[0092] Step S210: reading the data to be decompressed, and evenly dividing the data to be decompressed into at least two segments of code stream data;

[0093] Step S220: obtaining the index of each segment of the bitstream data and the position information of each segment of the bitstream data according to the delimiter of each segment of the bitstream data;

[0094] Step S230: searching the target lookup table in parallel according to the index and the position information to obtain a decompression result of the data to be decompressed.

[0095] Read the data to be decompressed and fill the compressed code stream to a multiple of 32 bits. If the parallelism is 64 channels, the data to be decompressed can be evenly divided into 64 segments of compressed code stream data according to the statistical bit width of 32 bits. According to the delimiter contained in each segment of the code stream data, the index contained in each segment of the code stream data and the position information of each segment of the code stream data are counted and obtained. According to the index and position information, the decompression results of the 64 segments of compressed code stream data in the target lookup table are searched in parallel, thereby obtaining the decompression result of the data to be decompressed.

[0096] Specifically, the step of searching the target lookup table in parallel according to the index and the position information to obtain the decompression result of the data to be decompressed includes:

[0097] Search the target lookup table in sequence according to the index and the position information to obtain a decompressed value corresponding to each index of each segment of the bitstream data;

[0098] The decompression value corresponding to each index of each segment of the code stream data is used as the decompression result of the data to be decompressed.

[0099] Since the position information of the code stream data is determined by the encoding length after the encoding operation, the index contained in the code stream data can be determined according to the position information. Each segment of the code stream data has at least one index. Then, the target lookup table is searched according to the index to obtain the decompressed values ​​of all indexes in the code stream data. For example, after searching the target lookup table according to the index, it is determined whether the index is the last index number of the code stream data. If so, it means that the compressed data of the code stream data has been processed. If it is not the last index of the code stream data, it means that the compressed data of the code stream data has not been processed. At this time, the target lookup table is continued to be searched according to the next index for decompression. Then the decompressed values ​​of all indexes of all code stream data are obtained as the decompression result of the data to be decompressed.

[0100] In one embodiment, if all code stream data of the current round of data to be decompressed are decompressed, a decoding (decompression) operation may be performed on the next round of data to be decompressed corresponding to the current round of data to be decompressed.

[0101] The method of decompressing data after adopting the above-mentioned data compression method can enable the hardware to perform parallel accelerated decoding, and the decoding speed can meet the real-time reading and writing requirements of the AI ​​engine for large amounts of data.

[0102] Reference Figure 4 As shown, the present application also provides an electronic device 1 for executing the above-mentioned data compression method and / or the above-mentioned data decompression method. It should be noted that the electronic device for executing the above-mentioned data compression method and / or the above-mentioned data decompression method can be the same electronic device or different electronic devices.

[0103] The electronic device 1 includes but is not limited to: a memory 11, a processor 12 and a communication interface 13. The electronic device 1 can be connected to a network through the communication interface 13. The network can be a wireless or wired network such as the Internet, Global System of Mobile communication (GSM), 4G network, 5G network, Bluetooth, Wi-Fi, or a call network.

[0104] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as a hard disk or a memory of the electronic device 1. The memory 11 is generally used to store an operating system and various application software installed on the electronic device 1, such as program codes of a data compression program 10 and / or a data decompression program 20, etc. The memory 11 may also store data to be compressed, data to be decompressed, and the decompression result of the data to be decompressed.

[0105] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication. The processor 12 is used to run the program code stored in the memory 11 or process data, such as running the program code of the data compression program 10 and / or the data decompression program 20.

[0106] The communication interface 13 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface). The communication interface 13 is generally used to establish a communication connection between the electronic device 1 and other electronic devices.

[0107] Figure 4 Only an electronic device 1 having components 11-13 is shown, but it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead. For example, the electronic device 1 may also include a tensor processing unit / processor (Tensor Processing Unit, TPU), a decoder, etc.

[0108] When the processor 12 executes the data compression program 10 stored in the memory 11, the following steps can be implemented:

[0109] Taking data with the same value in the data to be compressed as an index, and establishing an initial lookup table according to the number of the indexes;

[0110] Perform encoding operations on the numerical values ​​corresponding to each of the indexes in turn to obtain encoding results, add separators to the encoding results, and obtain an encoding list including the target encoding value corresponding to each of the indexes and the target encoding length corresponding to each of the indexes;

[0111] The encoding list is added to the initial lookup table to obtain a target lookup table after the data to be compressed is compressed.

[0112] For a detailed description of the above steps, please refer to the above Figure 1 Description of a flowchart of an embodiment of a method for data compression.

[0113] When the processor 12 executes the data decompression program 20 stored in the memory 11, the following steps can be implemented:

[0114] Reading the data to be decompressed, and evenly dividing the data to be decompressed into at least two segments of code stream data;

[0115] According to the delimiter of each segment of the bitstream data, an index contained in each segment of the bitstream data and position information of each segment of the bitstream data are obtained;

[0116] The target lookup table is searched in parallel according to the index and the position information to obtain a decompression result of the data to be decompressed.

[0117] For a detailed description of the above steps, please refer to the above Figure 3 Description of a flowchart of an embodiment of a method for decompressing data.

[0118] In addition, the embodiment of the present application also proposes a computer-readable storage medium, which can be non-volatile or volatile. The computer-readable storage medium can be any one or any combination of a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disk read-only memory (CD-ROM), a USB memory, etc. The computer-readable storage medium includes a data storage area and a program storage area, and the program storage area stores a data compression program 10 and / or a data decompression program 20. When the data compression program 10 is executed by the processor, the following operations are implemented:

[0119] Taking data with the same value in the data to be compressed as an index, and establishing an initial lookup table according to the number of the indexes;

[0120] Perform encoding operations on the numerical values ​​corresponding to each of the indexes in turn to obtain encoding results, add separators to the encoding results, and obtain an encoding list including the target encoding value corresponding to each of the indexes and the target encoding length corresponding to each of the indexes;

[0121] The encoding list is added to the initial lookup table to obtain a target lookup table after the data to be compressed is compressed.

[0122] The specific implementation of the computer-readable storage medium of the present application is substantially the same as the specific implementation of the above-mentioned data compression method, and will not be described in detail here.

[0123] When the data decompression program 20 is executed by the processor, the following operations are also implemented:

[0124] Reading the data to be decompressed, and evenly dividing the data to be decompressed into at least two segments of code stream data;

[0125] According to the delimiter of each segment of the bitstream data, an index contained in each segment of the bitstream data and position information of each segment of the bitstream data are obtained;

[0126] The target lookup table is searched in parallel according to the index and the position information to obtain a decompression result of the data to be decompressed.

[0127] The specific implementation of the computer-readable storage medium of the present application is substantially the same as the specific implementation of the above-mentioned data decompression method, and will not be described in detail here.

[0128] It should be noted that the serial numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. And the terms "including", "comprising" or any other variants thereof herein are intended to cover non-exclusive inclusion, so that the process, device, article or method including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, device, article or method including the element.

[0129] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, an electronic device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0130] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A data compression method, characterized in that: The method comprises: Taking data with the same value in the data to be compressed as an index, and establishing an initial lookup table according to the number of the indexes, wherein the data to be compressed is a weight parameter of a convolutional neural network; Perform encoding operations on the numerical values ​​corresponding to each of the indexes in turn to obtain encoding results, add separators to the encoding results, and obtain an encoding list including the target encoding value corresponding to each of the indexes and the target encoding length corresponding to each of the indexes; The encoding list is added to the initial lookup table to obtain a target lookup table after the data to be compressed is compressed.

2. The data compression method according to claim 1, characterized in that: The method of taking the data with the same value in the data to be compressed as an index and establishing an initial lookup table according to the number of the indexes includes: Counting data with the same value in the data to be compressed, and using the data with the same value as an index; The frequency of each of the identical values ​​is counted, and the initial lookup table is established according to the identical values, the number of the indexes, and the frequency of the identical values.

3. The data compression method according to claim 1, characterized in that: The performing encoding operations on the values ​​corresponding to each of the indexes in sequence includes: Step A1, performing encoding operations on the values ​​corresponding to the indexes in sequence; Step A2, determining whether the encoding length of the current encoding quantity after the encoding operation is performed is equal to the current maximum encoding length, if so, executing step A3, if not, executing step A4; Step A3, obtaining a current code value of the current code quantity, performing an extended coding operation on the current code value, and executing step A2; Step A4, adding one to the current maximum encoding length, and determining whether the current encoding quantity after the encoding operation is performed is greater than the maximum sequence number of the index, if so, executing step A5, if not, executing step A1; Step A5: Stop the encoding operation.

4. The data compression method according to claim 3, characterized in that: The obtaining of the current code value of the current code quantity and performing an extended coding operation on the current code value includes: Fill the tail of the current code value with a first character and a second character respectively, to obtain a code value filled with the first character and a code value filled with the second character; The encoding value after the first character is filled is stored in the encoding list; Determine whether the code value after the second character is filled contains the separator; If yes, delete the encoded value after the second character is filled; If not, the encoding value filled with the second character is stored in the encoding list.

5. The data compression method according to claim 1, wherein: After obtaining the target lookup table after the data to be compressed is compressed, the method further includes: The target lookup table is stored in a memory.

6. A data decompression method, characterized in that: The method comprises: Reading the data to be decompressed, and evenly dividing the data to be decompressed into at least two segments of code stream data; According to the delimiter of each segment of the bitstream data, an index contained in each segment of the bitstream data and position information of each segment of the bitstream data are obtained; The target lookup table as claimed in claim 1 is searched in parallel according to the index and the position information to obtain the decompression result of the data to be decompressed.

7. The data decompression method according to claim 6, characterized in that: The step of searching the target lookup table according to claim 1 in parallel according to the index and the position information to obtain the decompression result of the data to be decompressed comprises: Search the target lookup table in sequence according to the index and the position information to obtain a decompressed value corresponding to each index of each segment of the bitstream data; The decompression value corresponding to each index of each segment of the code stream data is used as the decompression result of the data to be decompressed.

8. The data decompression method according to claim 6, characterized in that: After obtaining the decompression result of the to-be-decompressed data, the method further includes: The next round of data to be decompressed corresponding to the data to be decompressed is read, and a decompression operation is performed on the next round of data to be decompressed.

9. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the data compression method described in any one of claims 1 to 5 when executing a program stored in a memory.

10. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the data decompression method described in any one of claims 6 to 8 when executing a program stored in a memory.

Citation Information

Patent Citations

  • Data processing method and device

    CN113595557A

  • Method and system for compression and decompression of data

    US5396595A