WO2021120067A1 - 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质 - Google Patents

数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质 Download PDF

Info

Publication number
WO2021120067A1
WO2021120067A1 PCT/CN2019/126393 CN2019126393W WO2021120067A1 WO 2021120067 A1 WO2021120067 A1 WO 2021120067A1 CN 2019126393 W CN2019126393 W CN 2019126393W WO 2021120067 A1 WO2021120067 A1 WO 2021120067A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
coding
residual
decoded
data block
Prior art date
Application number
PCT/CN2019/126393
Other languages
English (en)
French (fr)
Inventor
阮肇夏
赵文军
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to PCT/CN2019/126393 priority Critical patent/WO2021120067A1/zh
Publication of WO2021120067A1 publication Critical patent/WO2021120067A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits

Definitions

  • the present disclosure relates to the field of data processing technology, and in particular to data encoding methods, data decoding methods, data processing methods, encoders, decoders, data processing systems, removable platforms, and computer-readable media.
  • CNN Convolutional Neural Networks, convolutional neural network
  • weight data is the main parameter
  • the parameter scale is very large, usually reaching the level of one million or even ten million.
  • Such a huge amount of data consumes high bandwidth during the reading and writing process, and requires high hardware computing and storage capabilities, which in turn limits the application scenarios for data processing and use.
  • the present disclosure provides data encoding methods, data decoding methods, data processing methods, encoders, decoders, data processing systems, removable platforms, and computer-readable media, thereby at least improving the data reading and writing in the prior art to a certain extent The problem of high bandwidth.
  • a data encoding method including: obtaining the encoding overhead of multiple candidate encoding methods for a data block to be encoded, and determining a target encoding method with the smallest encoding overhead from the multiple candidate encoding methods;
  • the data block to be coded is coded by the target coding mode; wherein the candidate coding mode includes residual coding and Huffman coding.
  • a data decoding method including: analyzing data to be decoded, determining a target encoding method corresponding to the data to be decoded among a plurality of candidate encoding methods, and determining the corresponding encoding method according to the target encoding method.
  • the target decoding method the data to be decoded is decoded by the target decoding method to obtain the original data corresponding to the data to be decoded; wherein the candidate encoding method includes residual coding and Huffman coding.
  • a data encoding method including: obtaining a data block to be encoded; determining the total encoding bit length and column encoding required for row encoding the residuals in the data block to be encoded The total coding bit length of is, and the residual error in the data block to be coded is coded using the coding method in which the total coding bit length is smaller.
  • a data decoding method including: obtaining data to be decoded obtained by encoding an original data block by residual coding; The reference data and the residual are read in the decoded data, and the inverse operation of the residual calculation is performed on the reference data and the residual line by line to obtain the original data block corresponding to the data to be decoded; when the residual code is During column encoding, the reference data and residual are read from the data to be decoded, and the inverse operation of the residual calculation is performed on the reference data and the residual column by column to obtain the original data block corresponding to the data to be decoded .
  • a data encoding method including: acquiring a data block to be encoded; dividing the data in the data block to be encoded into a plurality of numerical intervals, and using different bit lengths for data in different numerical intervals Encode.
  • a data decoding method including: obtaining data to be decoded; determining the bit length occupied by the original data corresponding to the data to be decoded, and the original data in different numerical ranges have different bits. Length; the original data is decoded from the data to be decoded according to the bit length occupied by the original data.
  • a data processing method is provided, which is applied to a configurator, a memory, and a processor connected in sequence, and the method includes: executing the above-mentioned first, third, or fifth aspect through the configurator
  • the data encoding method is to encode a data block to be encoded composed of preset data to generate code stream data; write the code stream data into the memory to reduce the write bandwidth to the memory;
  • the processor reads the code stream data in the memory and decodes the code stream data to reduce the read bandwidth of the memory.
  • an encoder which encodes a data block to be encoded by executing the data encoding method provided in the first, third, or fifth aspect.
  • a decoder that decodes data to be decoded by executing the data decoding method provided in the second, fourth, or sixth aspect.
  • a data processing system including: a configurator, a memory, and a processor connected in sequence; the configurator is used to execute the data encoding method provided in the first, third, or fifth aspect, Encode a data block to be encoded composed of preset data, generate code stream data, and write the code stream data into the memory to reduce the write bandwidth to the memory; the processor is used for reading The code stream data in the memory is decoded to reduce the read bandwidth of the memory.
  • a movable platform including: a body; a power system provided in the body, the power system is used to provide power to the movable platform; and, the tenth aspect described above Provided data processing system.
  • a computer-readable medium on which a computer program is stored, and when the computer program is executed by a processor, any one of the methods provided in the first to sixth aspects is implemented.
  • the target encoding method encodes the data block to be encoded, which has high flexibility. According to the characteristics of the data block to be encoded, the most suitable encoding method can be selected to minimize the bit length of the encoded bit stream to reduce the bit stream data reading.
  • the bit width occupied by writing can speed up the calculation and processing speed of hardware devices, save storage resources, and broaden data application scenarios.
  • all candidate coding methods including residual coding, Huffman coding, and numerical segmentation coding, are all lossless coding, which can ensure the accuracy of the data block to be coded after being coded and decoded; it is especially suitable for neural networks.
  • this exemplary embodiment does not reduce the convergence speed of the network, does not need to fine-tune hyperparameters, and does not require repeated training, which has higher practicability. .
  • Figure 1 shows a schematic diagram of LeNet
  • Figure 2 shows a schematic diagram of the CNN hardware computing platform framework
  • FIG. 3 shows a flowchart of a data encoding method in this exemplary embodiment
  • Figure 4 shows a schematic diagram of the convolution kernel of CNN
  • FIG. 5 shows a schematic diagram of dividing data blocks into blocks in this exemplary embodiment
  • Fig. 6 shows a schematic diagram of calculating residuals in this exemplary embodiment
  • FIG. 7 shows a schematic diagram of calculating row/column residuals in this exemplary embodiment
  • FIG. 8 shows a schematic diagram of performing numerical value segment coding in this exemplary embodiment
  • FIG. 9 shows a schematic diagram of a code stream structure in this exemplary embodiment
  • Fig. 10 shows a flowchart of a data decoding method in this exemplary embodiment
  • FIG. 11 shows a flowchart of another data encoding method in this exemplary embodiment
  • FIG. 12 shows a flowchart of another data decoding method in this exemplary embodiment
  • FIG. 13 shows a flowchart of yet another data encoding method in this exemplary embodiment
  • Fig. 14 shows a flowchart of yet another data decoding method in this exemplary embodiment
  • FIG. 15 shows a schematic structural diagram of a data processing system in this exemplary embodiment
  • FIG. 16 shows a flowchart of a data processing method in this exemplary embodiment
  • FIG. 17 shows an architecture diagram of an encoder in this exemplary embodiment
  • FIG. 18 shows an architecture diagram of a decoder in this exemplary embodiment
  • FIG. 19 shows a structural diagram of a movable platform in this exemplary embodiment.
  • CNN is a feed-forward neural network and one of the most representative network structures in deep learning technology. It provides an end-to-end processing method and has achieved great success in the field of image and voice processing. On the ImageNet data set, many successful models are based on CNN, which improves the accuracy of computer vision tasks compared to traditional neural networks.
  • Figure 1 shows the composition structure of LeNet (a classic CNN model), which is mainly composed of the following five structures: Input and Convolution.
  • C1 in the figure indicates that the first intermediate layer is convolution. Layer), pooling layer (or subsampling), S2 in the figure indicates that the second intermediate layer is the pooling layer), fully connected layer (Full Connection, F6 in Figure 1 indicates that the sixth intermediate layer is fully connected) Layer) and output layer (Output).
  • LeNet a classic CNN model
  • the input layer is the input of the entire neural network, which generally represents the pixel matrix of an image; the convolutional layer is to perform convolution calculations on the input feature map through each convolution kernel, trying to make each small block in the neural network more in-depth Analysis to obtain more abstract features; the pooling layer does not change the depth of the three-dimensional matrix, but it can reduce the size of the matrix, similar to downsampling; the purpose of the fully connected layer is to complete the classification task, the previous convolutional layer and pooling
  • the transformation layer is the process of automatic image feature extraction, which needs to be classified after the feature extraction is completed; the output layer is used for classification problems, and the output of the fully connected layer is Gaussian Connection, and then normalized (such as normalization).
  • the exponential function softmax is used to obtain the probability distribution of the current sample belonging to different types, and then complete the task of the entire network.
  • the input layer is a single-channel image with a size of 32x32x1.
  • the 6@28x28 feature map of the C1 layer can be obtained through convolution, and the number 6 represents the C1 layer
  • the number of channels of the feature map is also the number of convolution kernels used by the convolution layer. All convolution kernels in each layer contain a large number of parameters.
  • LeNet is a relatively simple CNN structure in the early stage. According to the current development trend of CNN, the number of network layers is gradually deepening, making the parameter model size of the entire network larger, and the system bandwidth occupied by the chip application is very high, which affects the power consumption of the device. The speed of operation presents a huge challenge.
  • Figure 2 shows the framework of the CNN hardware computing platform. The task of the configurator is to allocate CNN parameters and write DDR (Double Data Rate Synchronous Random Access Memory) in a specified format. Double data rate synchronous dynamic random access memory, usually Referred to as DDR), the CNN computing core reads the parameters stored in the DDR to SRAM (Static Random Access Memory, static random access memory) during the calculation process.
  • DDR Double data rate synchronous dynamic random access memory
  • the total amount of raw weight data that the CNN calculation core needs to load from the DDR is about 132.81MB, and the DDR read bandwidth occupied by it is calculated at a frame rate of 30 to be 31.13Gbps. If repeated reading occurs, the bandwidth will be larger. It can be seen that it is necessary to reduce the bandwidth occupied by the weighted data.
  • exemplary embodiments of the present disclosure provide a data encoding method, a data decoding method, a data processing method, an encoder, a decoder, a data processing system, a removable platform, and a computer-readable storage medium.
  • Various aspects of this exemplary embodiment will be described in detail below.
  • Fig. 3 shows a flowchart of a data encoding method in this exemplary embodiment.
  • the method includes the following steps S310 and S320:
  • Step S310 Obtain the coding overhead of the multiple candidate coding modes for the data block to be coded, and determine the target coding mode with the smallest coding overhead from the multiple candidate coding modes.
  • the data to be encoded is in the form of data blocks, showing an arrangement of rows and columns, such as a matrix, a data table, and the like.
  • the data block to be encoded may be obtained in the following manner:
  • the data blocks are divided into blocks according to a preset size, and each divided block is used as a data block to be coded.
  • FIG. 4 shows the weight parameter format of CNN, which is composed of N convolution kernels.
  • Each convolution kernel is a three-dimensional structure with a size of C*Kh*Kw, where N is the following The number of channels in a layer of feature maps, C is the number of channels in the current layer of feature maps, and Kw and Kh are the width and height of the convolution kernel, respectively.
  • the total number of weight parameters is N*C*Kh*Kw, and these parameters are expanded into a two-dimensional data block in a certain order. For example, a data block with a column height of N*C*Kh can be obtained by taking Kw as the row width.
  • the preset size for the data block can be determined, and the data block can be divided into multiple data blocks of the preset size, and each data block is a waiting block. Encode the data block.
  • the preset size generally includes a preset width and a preset height, for example, M and N respectively.
  • the above-mentioned Kw*N*C*Kh data block can be divided into M*N data blocks according to the M*N preset size.
  • the data block is filled with data so that the size of the filled data block meets the preset size Integer multiples of the size.
  • the data block can be filled to an integer multiple of 4*4, for example, two columns of values and a row of values are filled to obtain a 12*8 data block, which can be exactly divided into 4*4 blocks.
  • the encoding overhead refers to the bit width occupied by the code stream data generated after encoding the data block to be encoded.
  • Candidate coding methods include at least residual coding and Huffman coding, and may also include other coding methods, such as numerical segment coding.
  • a plurality of candidate encoding methods are set, and the data volume of the code stream data obtained after each candidate encoding method is encoded after the data block to be encoded is encoded, and the candidate encoding method with the smallest amount of data is selected as the target Encoding.
  • the compression rate is usually used as a measurement, that is, the ratio of the data size of the data after encoding to the data size before encoding.
  • the lower the compression rate the smaller the encoding overhead.
  • This exemplary embodiment can calculate the compression rate of each candidate encoding method for encoding the data block to be encoded, and select the candidate encoding method with the lowest compression rate as the target encoding method; if the compression rates of all candidate encoding methods are greater than or equal to 1, It means that the amount of data increases after encoding with any candidate encoding method, and the Bypass mode can be adopted, that is, the data block to be encoded is not encoded, and the original data is directly transmitted.
  • step S320 the data block to be encoded is encoded by the target encoding method.
  • the target encoding method with the smallest encoding overhead is selected to encode the data block to be encoded, so as to achieve the best compression effect.
  • the determined target encoding methods may be different, and then encoding is performed by selecting a suitable target encoding method with the best compression effect for the data blocks to be encoded, so that the compressed bit stream data The amount of data is the smallest.
  • the implementation complexity of numerical segment coding and residual coding is relatively low.
  • it can be suitable for weighted data coding with low image complexity.
  • numerical segment coding is particularly suitable for data whose values are concentrated in a small range.
  • Residual coding is especially suitable for data with strong correlation in the data neighborhood;
  • Huffman coding is suitable for more complex data coding, such as data with more scattered numerical values or data with weaker data neighborhood correlation; it can be seen that,
  • Each candidate encoding method has its own characteristics and applicability.
  • the target encoding method with the least encoding overhead is adopted to encode the data block to be encoded, which has high flexibility and can select the most suitable data block according to the characteristics of the data block to be encoded.
  • the encoding method minimizes the bit length of the encoded bit stream to reduce the bit width occupied by the bit stream data read and write, thereby speeding up the calculation and processing speed of the hardware device, saving storage resources, and broadening the data application scenarios.
  • step S320 can be implemented in the following manner:
  • the residual refers to the difference between two adjacent data in the data block to be encoded.
  • the initial values of the data to be encoded are p1, p2, p3, and p4, a reference value p0 is selected, and the difference between two adjacent data is calculated respectively to obtain residual values d1, d2, d3, and d4.
  • row residuals that is, the difference between each piece of data and the adjacent data on the left
  • column residuals that is, the difference between each piece of data and the adjacent data above it. Therefore, there are two corresponding residual coding methods: row coding, that is, coding the row residuals; column coding, that is, coding the column residuals.
  • row coding that is, coding the row residuals
  • column coding that is, coding the column residuals.
  • the data volume of the code stream data obtained by row coding and column coding may be different. Therefore, the method with smaller data volume, that is, smaller coding overhead, is selected for residual coding.
  • the encoding overhead of row encoding and column encoding may be obtained in the following manner:
  • the total bit length of the code stream of each row is counted to obtain the coding overhead of the row coding, and the total bit length of the code stream of each column is counted to obtain the coding overhead of the column coding.
  • the reference data can be the first data in the data block to be encoded (that is, the data in the upper left corner), or set to data in other locations according to coding habits, or can choose any designated value, such as 0, 1, etc.
  • bit stream bit length required for each residual in each column is calculated according to the maximum residual of each column, so as to encode each residual in each column separately.
  • the calculation method of the bit stream bit length can be found in formula (1).
  • the bit length of the bit stream is 3 bits, which can be encoded as 101; for the residual 126, the bit length of the bit stream is 7 bits. , Can be coded as 1111110.
  • row and column mode flags can be set in the code stream structure of the data block to be coded to record the corresponding row coding or column coding.
  • Numerical value For example, the row-column mode flag bit can be 1 bit, with 0 representing row coding and 1 representing column coding. In this way, it is convenient to determine whether row coding or column coding is used according to the row and column mode flags during decoding, so that the data block to be coded can be restored.
  • the row-column mode flag can be set at the starting position in the code stream structure of the residual coding, or at other designated positions.
  • a value length flag can be set in the code stream structure of each line of the data block to be coded, which is used to record the code required for each residual of the line.
  • Stream bit length When column coding is used, a value length flag can be set in the code stream structure of each column of the data block to be coded to record the bit length of the code stream required for each residual of the column. For example, in FIG. 7, when the residual coding is performed on the first row, it is determined that each residual of the first row requires 1 bit, and the value length flag bit can be set to 0, which means 1 bit.
  • the latter value is used to subtract the previous value, so the residual may be positive or negative.
  • a sign flag can be set in the bitstream structure of each residual to record whether the residual is positive or negative.
  • the sign flag bit can be 1 bit, 0 means the residual is positive, and 1 means the residual is negative.
  • the sign flag bit can be set before or after the value bit of each residual.
  • the row-column mode flag bit, the value length flag bit of each residual, the sign flag bit, and the value bit may be sequentially set in the code stream structure of the residual coding.
  • line coding as an example in Figure 7 for illustration, the following two coding methods can be used:
  • the sequence is: the row-column mode flag bit is 0, which means that row coding is used, then the value length flag bit of the first row, which is 000, and then the sign flag bit of each residual in the first row And the value bit; then the value length flag bit in the second row, and the sign flag bit and value bit of each residual in the second row..., the complete code stream structure is as follows:
  • the value length flag is set for each residual.
  • the sequence is as follows: the row-column mode flag bit is 0, which means row coding is used, and then the value length flag bit of the first residual (0) is 000, its sign flag bit is 0, and the value is 0; Then there are the value length flag, sign flag and value bit of the second residual.
  • the complete code stream structure is as follows:
  • the code stream structure is a completely continuous binary value.
  • a size flag bit may be set in the code stream structure of the data block to be encoded for recording the original size of the data block to be encoded.
  • a 16-bit size flag can be set at the start position of the code stream structure, where 8 bits are used to record the width of the data block to be encoded, and the other 8 bits are used to record the height of the data block to be encoded.
  • the coding overhead can be determined in the following way:
  • the maximum residual of each row is Max Diff (R1), Max Diff (R2), ..., Max Diff (RN), and the maximum residual of each column
  • the differences are Max Diff (C1), Max Diff (C2), ..., Max Diff (CM), using formula (2) to calculate the total bit length of the code stream required for row coding and column coding, respectively:
  • Row represents the row code
  • Column represents the column code.
  • 1 represents the bit length of the row-column mode flag bit
  • 3 represents the bit length of the value length flag bit of each row
  • row coding or column coding can be selected flexibly for coding, so as to further reduce coding overhead.
  • step S320 can be implemented in the following manner:
  • the Huffman table is used to encode the data in the data block to be encoded.
  • the frequency of data appearance refers to the number of times each piece of data appears in the entire data block to be encoded.
  • the data can be arranged according to the frequency of occurrence from low to high (or from high to low), and then a Huffman tree is generated: the two data with the lowest frequency are used as the two leaf nodes of the tree, and the parent node of these two nodes is merged ,
  • the frequency of the parent node is the sum of the frequencies of the two child nodes.
  • the branch from the parent node to the two child nodes is coded separately, for example, it can be coded as 0 and 1; the parent node replaces the data of the two child nodes, rearranges them, and Repeat the above process; merge multiple times until the merge probability is 1, and the root node is merged.
  • all the data are mapped to the nodes of the Huffman tree to obtain the Huffman tree.
  • each branch has a code. Taking data A as an example, from the root node to the path of the node where data A is located, the codes of all branches are connected, which is the code of data A. In this way, the code of each data can be obtained and recorded in the Huffman table.
  • the Huffman table is actually a code mapping table, which records each data and its corresponding code.
  • the Huffman table can be used to code the data in the data block to be coded.
  • the coding overhead can be determined in the following way:
  • the bit length of the bit stream required for each data can be determined according to the Huffman table. Since the Huffman table is also required for decoding, the information of the Huffman table needs to be recorded in the code stream structure of the data block to be encoded.
  • the Huffman table can be calculated by binary fixed-length encoding and other methods. Bit length of code stream. Therefore, the total bit length of the Huffman table and the bit stream required for each data can be counted, and the coding overhead of the Huffman coding for the data block to be coded can be obtained.
  • the code stream structure can also contain other information.
  • a size flag can be set in the code stream structure of the data block to be coded to record the data to be coded. The original size of the block and so on. This disclosure does not limit this.
  • candidate coding methods can also include numerical segment coding.
  • step S320 can be implemented in the following ways:
  • the data in the data block to be encoded is divided into multiple numerical intervals, and the data in different numerical intervals are encoded with different bit lengths.
  • each data it is divided into different numerical ranges. If the numerical value is larger, more bits are needed, and if the numerical value is smaller, fewer bits are needed. Compared with the prior art that uses 8 bits and 16 bits to encode all data, it has stronger pertinence, can reduce a large number of redundant bit lengths, and improve coding efficiency.
  • dividing the data in the data block to be encoded into multiple numerical intervals includes:
  • the data in the data block to be encoded is divided into corresponding numerical intervals.
  • the preset value range may be the value range where the data in the data block to be encoded is located.
  • the parameters of the neural network are usually within [0,255], and [0,255] may be used as the preset value range.
  • the dividing point can be an integer power of 2, such as 2, 4, 8, etc., and numerical intervals such as [0,2), [2,4), [4,8) can be obtained, so that the value of each numerical interval
  • the encoding bit length required for the data is the same. According to the value of each data, it is divided into the corresponding numerical interval.
  • a single numerical interval can be divided, and for a numerical range with a relatively scattered data distribution, multiple numerical ranges can be combined into a single numerical interval.
  • the number of numerical intervals may be an integer power of two. This is convenient for encoding the value interval itself.
  • the code stream structure of the data block to be coded after numerical segment coding may include numerical bits, and the numerical bits are used to record data encoding. Using different bit lengths to encode data in different numerical ranges can be achieved in the following ways:
  • Each data in the data block to be encoded is encoded according to the bit length of the numerical bit corresponding to each numerical interval.
  • the upper limit value of the numerical range is 7 (assuming that the data are all positive integers), and 7 needs a bit length of 3 bits for encoding (the encoding of 7 is 111), so Allocate 3 bits for each data in the numerical range as its numerical bit; if the data is in the numerical range [8,16), the upper limit value of the numerical range is 15, and 15 needs a bit length of 4 bits for encoding (the encoding of 15 is 1111), therefore, 4 bits are allocated for each data in the numerical range as its numerical bits.
  • the code stream structure of the data block to be coded after numerical segment coding may further include an interval flag bit, which is used to mark the value interval in which the data is located.
  • an interval flag bit which is used to mark the value interval in which the data is located.
  • the interval flag bit needs to be uniquely represented for each numerical interval, so the more the number of numeric intervals, the higher the bit length of the interval flag bit required. For example, if the number of numerical intervals is 2, then the interval flag bit can be 1 bit, 0 and 1 respectively represent two numerical intervals; if the number of numeric interval is 4, the interval flag bit needs 2 bits, 00, 01, 10, 11 respectively represent 4 numerical intervals.
  • the interval flag bit of each data can be located before the value bit, so that when decoding, the value interval of the data is determined first, and then the bit length of the value bit is determined, and the decoding is performed according to the bit length.
  • bit length of the interval flag bit can satisfy the following formula (5):
  • Q is the number of numerical intervals. It can be seen that when Q is at (2i, 2i+1) (i is a positive integer), the bit length of the required interval flags are all i+1, for example, when the numerical interval is 3 or 4, the required interval The flag bits are all 2 bits. Therefore, setting the number of numerical intervals to an integer power of 2 can make full use of each bit of the interval flag and improve coding efficiency.
  • bit length of the numerical bit corresponding to the numerical interval Si can satisfy the following formula (6):
  • max(Si) represents the upper limit value of the numerical interval Si.
  • the upper limit value max(Si) can be determined according to the numerical interval Si, and then the bit length of the numerical bit can be determined.
  • the numerical segment coding is exemplified below with reference to FIG. 8.
  • the data block to be coded in FIG. 8 is the same as that in FIG. 7.
  • Figure 8 shows two numerical segmentation methods: the first is to divide the preset numerical range [0,255] into two numerical ranges, which are [0,8) and [8,255], and the interval flag can be 1bit. 0 means [0,8), 1 means [8,255]; the second is to divide the preset value range [0,255] into four numerical ranges, namely [0,2), [2,8), [8, 32) and [32,255], the interval flag bit can be 2bit, 00 means [0,2), 01 means [2,8), 10 means [8,32), 11 means [32,255].
  • Figure 8 shows the interval flags of each data in the two numerical segmentation modes.
  • the code of 1 is 0,001, the code of 6 is 0,110, the code of 28 is 1,00011100, and the code of 127 is 1,011111111.
  • the first bit is the interval flag bit, and the latter is the value bit.
  • the code of 1 is 00, the code of 1, 6 is 01,110, the code of 28 is 10,11100, and the code of 127 is 11,01111111.
  • the first and second bits are the interval flag bits, and the latter are the numerical bits.
  • the coding overhead can be determined in the following way:
  • the bit length of the bit stream required for each data is calculated, and the total bit length of the bit stream is counted as the coding overhead of the numerical segment coding for the data block to be coded.
  • the code stream structure can also contain other information.
  • the size flag bit can be set in the code stream structure of the data block to be encoded to record the data block of the data block to be encoded. Original size and so on. This disclosure does not limit this.
  • a segmentation mode flag bit may be set in the code stream structure to record which numerical value segmentation mode is adopted during encoding. The following is a further description of the numerical segmentation method.
  • Z is the data quantity of the data block to be coded
  • Z*R_h is the bit length of the coded stream. , That is, coding overhead.
  • a numerical value segmentation method can be selected flexibly to further reduce the coding overhead.
  • the encoding overhead of each candidate encoding method can be calculated separately, and the smallest candidate encoding method is selected as the target encoding method for encoding. It should be noted that when the parameters of the neural network are encoded, the parameters of the neural network are divided into multiple data blocks to be encoded, and different target encoding methods can be selected for different data blocks to be encoded.
  • the encoding mode flag bit may be set in the code stream structure after the data block to be encoded is encoded, and the encoding method flag bit is used for recording The value corresponding to the target encoding method.
  • Fig. 9 shows a schematic diagram of the code stream structure for encoding the parameters of the neural network.
  • Frame represents the code stream structure corresponding to the original parameters, including size information (Width and Height), Huffman table information (Huffman_table, the starting position usually includes 1bit flags, and whether the Huffman table is used to indicate whether the Huffman table is used), each The code stream structure of the data block to be encoded (Slice_data).
  • the code stream structure of each data block to be coded is composed of the coding mode flag (Mode) and the actual code stream (Bit_stream).
  • the target encoding method with the least encoding overhead is adopted to encode the data block to be encoded, which has high flexibility and can be selected according to the characteristics of the data block to be encoded.
  • the most suitable encoding method minimizes the bit length of the encoded bit stream to reduce the bit width occupied by the bit stream data read and write, thereby speeding up the calculation and processing speed of the hardware device, saving storage resources, and broadening the data application scenarios.
  • all candidate coding methods including residual coding, Huffman coding, and numerical segmentation coding, are all lossless coding, which can ensure the accuracy of the data block to be coded after being coded and decoded; it is especially suitable for neural networks.
  • this exemplary embodiment does not reduce the convergence speed of the network, does not need to fine-tune hyperparameters, and does not require repeated training, which has higher practicability. .
  • Fig. 10 shows a flowchart of a data decoding method in this exemplary embodiment. Referring to FIG. 10, the method includes the following steps S1010 and S1020:
  • Step S1010 Analyze the data to be decoded, determine the target encoding method corresponding to the data to be decoded among the multiple candidate encoding methods, and determine the corresponding target decoding method according to the target encoding method.
  • the data to be decoded is generally a one-dimensional continuous binary value, and is not arranged in rows and columns like the data block to be encoded.
  • Candidate coding methods include at least residual coding and Huffman coding, and may also include other coding methods, such as numerical segment coding.
  • the data to be decoded may include an encoding mode flag bit, and the encoding mode flag bit has a fixed bit length, for example, it may be 2 bits.
  • Step S1010 can be implemented in the following ways:
  • the target coding mode corresponding to the data to be decoded is determined.
  • the target coding mode is residual coding.
  • the corresponding target decoding method can be determined according to the target encoding method.
  • the target decoding mode may be the inverse operation of the target encoding mode.
  • step S1020 the data to be decoded is decoded by the target decoding mode to obtain the original data corresponding to the data to be decoded.
  • the target decoding mode is used to decode the data to be decoded in order. Since the data to be decoded has a one-dimensional structure, the original data decoded is also a one-dimensional structure. In an optional implementation manner, if the original data itself is in the form of original data blocks, the original data blocks have a preset size. When the data to be decoded is decoded, the decoded original data can be arranged according to the preset size. Original data block. For example, the preset size is M*N. After the original data is decoded, it can be arranged into M*N data blocks.
  • the preset size can be recorded in the size flag of the data to be decoded, and the corresponding size information can be obtained by reading the value of the size flag, or it can be obtained by the decoder through a configuration table before receiving the data to be decoded. Information to the preset size.
  • the corresponding target decoding methods are also different.
  • the following is a specific description of the decoding methods corresponding to the three methods of residual coding, Huffman coding, and numerical segment coding, namely, residual decoding, Huffman decoding, and numerical segment decoding.
  • Step S1020 can be implemented in the following ways:
  • the residual coding is line coding
  • read the reference data and the residual from the data to be decoded and perform the inverse operation of the residual calculation on the reference data and the residual line by line to obtain the original data block corresponding to the data to be decoded;
  • the residual coding is column coding
  • the reference data and the residual are read from the data to be decoded, and the inverse operation of the residual calculation is performed on the reference data and the residual column by column to obtain the original data block corresponding to the data to be decoded.
  • whether the residual coding is row coding or column coding can be determined according to the value of the row-column mode flag in the data to be decoded, for example, read the value of the row-column mode flag bit, if it is 0, it means that row coding is used, if it is 1. , Indicates that column coding is used; or the coding mode flag can contain row/column coding information, and the row coding or column coding can be determined according to the value of the coding mode flag. For example, read the value of the coding mode flag, if it is 00 , Indicates that row coding is used, if it is 01, indicates that column coding is used.
  • the decoded data is the residual, which is arranged into residual data blocks according to a preset size, the form of which can be referred to as shown in FIG. 7.
  • the first residual can be the reference data, and also the first original data, or a fixed value (such as 0) can be used as the reference data.
  • Starting from the reference data perform the inverse operation of the residual calculation. If it is row encoding, add each residual to its left adjacent value in turn to get the corresponding original data; if it is column encoding, add each residual to its adjacent value in turn to get The corresponding raw data.
  • the residual decoding is used to decode the original data block. If the original data itself has a one-dimensional structure, the inverse operation of the residual calculation cannot be performed through the arrangement of rows/columns.
  • the bit length occupied by the residual may be read first, and then the residual is read according to the bit length.
  • the data to be decoded may include a value length flag bit, which has a fixed bit length, for example, 3 bits, and is used to record the bit length occupied by the residual (ie, the bit length of the residual code stream). There are two ways to set the value length flag:
  • the first is to set one before each row (for row encoding) or each column (for column encoding).
  • row encoding as an example: if the default size of the original data block is M*N, that is, there are N data in each row.
  • the bit length of the residual code stream of the first row can be determined according to the corresponding relationship in Table 1. For example, the value length flag is 000 to determine every bit of the first row.
  • Each residual is 2bit; then read N 2bits sequentially, which is the N residuals of the first row; then read the next 3bit data, which is the value length flag bit of the second row, and so on.
  • the second is to set one before each residual.
  • decoding each residual first read the value length flag to determine the bit length of the residual, and then read the value of the bit length to decode the corresponding The residuals.
  • the to-be-decoded data may also include a sign bit of each residual, which is generally located before the numerical bit of the residual, and is used to record whether the residual is positive or negative. Therefore, when the residual is read from the data to be decoded, it can be determined whether the corresponding residual is positive or negative according to the value of the flag bit of each symbol. For example, when reading the residual, first read the 1-bit sign flag, if it is 0, it means the residual is positive, if it is 1, it means the residual is negative, and then read the following residual value. In this way, when performing the inverse operation of the residual calculation, the residual contains positive/negative information, and more accurate results can be obtained.
  • Step S1020 can be implemented in the following ways:
  • the information of the Huffman table is coded and placed before the actual code stream.
  • the Huffman table can be read first, and then according to the Huffman table, the data to be decoded can be decoded one by one in a forward matching manner.
  • Candidate coding methods can also include numerical segment coding.
  • the target encoding method is numerical segmented encoding
  • its corresponding target decoding method is numerical segmented decoding.
  • Step S1020 can be implemented in the following ways:
  • the original data is decoded from the data to be decoded according to the bit length occupied by the original data.
  • the value interval may be obtained by dividing the preset value range by the preset dividing point.
  • the preset value range is the value range of the original data.
  • the parameters of the neural network are usually within [0,255], and [0,255] can be used as the preset value range.
  • the dividing point can be an integer power of 2, such as 2, 4, 8, etc., and numerical intervals such as [0,2), [2,4), and [4,8) can be obtained, so that each data interval The bit length occupied by the original data is the same.
  • the numerical interval itself can be coded and represented. For example, setting the interval flag bit is used to mark the numerical interval in which the original data is located. Then, the bit length occupied by the corresponding original data can be determined according to the value of the flag bit of each interval in the data to be decoded.
  • bit length value After reading the value of each interval flag bit, according to the bit length occupied by the corresponding original data, the bit length value is sequentially read from the data to be decoded to decode the corresponding original data.
  • the number of numerical intervals can be an integer power of 2, which is convenient for encoding the numerical interval itself, especially when the interval flag bit is set, the interval flag bit can be fully utilized Each bit of, the coding efficiency is higher.
  • the target decoding method is determined according to the encoding method flag bit, and then the data to be decoded is decoded according to the above method process.
  • the generated code stream structure can be referred to as shown in FIG. 9.
  • the decoder After receiving the Frame, it regards the Frame as the code stream data to be decoded, which includes multiple sets of data to be decoded (Slice_data) of the size flags (Width and Height).
  • Slice_data data to be decoded
  • Each group of to-be-decoded data can be decoded separately to obtain its corresponding original data, and then the original data corresponding to each group of to-be-decoded data can be merged into data blocks according to the value of the size flag to obtain the parameters of the neural network. For example, referring to FIG.
  • the original data corresponding to each group of data to be decoded is used as a data block to restore the original two-dimensional structure of the neural network parameters.
  • the target decoding methods may be different. Referring to FIG. 9, the target decoding mode can be determined according to the encoding mode flag (Mode) in each group of data to be decoded, and decoded accordingly.
  • the data encoding method is the above-mentioned residual encoding, and includes the following steps S1110 and S1120:
  • Step S1110 Obtain the data block to be encoded
  • Step S1120 Determine the total coding bit length required for row coding and the total coding bit length required for column coding for the residuals in the data block to be coded.
  • the coding method in which the total coding bit length is smaller is used, and the data block to be coded is The residuals are encoded.
  • determining the total coding bit length required for row coding and the total coding bit length required for column coding of the residuals in the data block to be coded may include:
  • the total bit length of the code stream of each row is counted to obtain the coding overhead of the row coding, and the total bit length of the code stream of each column is counted to obtain the coding overhead of the column coding.
  • encoding the residual in the data block to be encoded in a manner in which the encoding overhead is relatively small may include:
  • bit stream bit length required for each residual in each line is calculated according to the maximum residual of each line, so as to encode each residual in each line separately.
  • the data encoding method further includes:
  • the data encoding method further includes:
  • a value length flag is set in the code stream structure of each row of the data block to be coded, which is used to record the bit length of the code stream required for each residual of the row.
  • adopting a mode in which the coding overhead is relatively small to perform column coding of the residuals in the data block to be coded may include:
  • bit stream bit length required for each residual in each column is calculated according to the maximum residual of each column, so as to encode each residual in each column separately.
  • the data encoding method further includes:
  • the data encoding method further includes:
  • a value length flag is set in the code stream structure of each column of the data block to be coded, which is used to record the bit length of the code stream required for each residual of the column.
  • the data encoding method further includes:
  • the sign flag bit is set in the code stream structure of each residual to record whether the residual is positive or negative.
  • the data decoding method is the above-mentioned residual decoding, and includes the following steps S1210 to S1230:
  • Step S1210 Obtain the to-be-decoded data obtained by encoding the original data block by residual coding
  • Step S1220 When the residual coding is line coding, read the reference data and the residual from the data to be decoded, and perform the inverse operation of the residual calculation on the reference data and the residual line by line to obtain the original data block corresponding to the data to be decoded ;
  • Step S1230 when the residual coding is column coding, read the reference data and the residual from the data to be decoded, and perform the inverse operation of the residual calculation on the reference data and the residual column by column to obtain the original data block corresponding to the data to be decoded .
  • the data decoding method further includes:
  • the bit length occupied by the residual is first read, and then the residual is read according to the bit length.
  • the residual when the residual is read from the data to be decoded, it is determined whether the corresponding residual is positive or negative according to the value of the flag bit of each symbol.
  • the data encoding method is the above-mentioned numerical value segment encoding, and includes the following steps S1310 and S1320:
  • Step S1310 Obtain the data block to be encoded
  • Step S1320 Divide the data in the data block to be encoded into multiple numerical intervals, and encode the data in different numerical intervals with different bit lengths.
  • dividing the data in the data block to be encoded into multiple numerical intervals includes:
  • the data in the data block to be encoded is divided into corresponding numerical intervals.
  • the preset numerical range is the numerical range of the data in the data block to be encoded; the dividing points are all powers of two.
  • the split point is determined in the following manner:
  • the number of numerical intervals is an integer power of two.
  • the code stream structure of the data block to be encoded after numerical segment coding includes numerical bits; the data of different numerical intervals are encoded with different bit lengths, including:
  • Each data in the data block to be encoded is encoded according to the bit length of the numerical bit corresponding to each numerical interval.
  • the code stream structure after the data block to be encoded is numerically segmented and encoded further includes interval flag bits, which are used to mark the numerical interval in which the data is located; for data in different numerical intervals, use Encoding with different bit lengths also includes:
  • bit length of the interval flag Q is the number of numerical intervals; the bit length of the numerical bits corresponding to the numerical interval Si max(Si) represents the upper limit value of the numerical interval Si.
  • the data decoding method is the above-mentioned numerical segmented decoding, and includes the following steps S1410 to S1430:
  • Step S1410 obtain the data to be decoded
  • Step S1420 Determine the bit length occupied by the original data corresponding to the data to be decoded, and the original data in different numerical ranges have different bit lengths;
  • step S1430 the original data is decoded from the data to be decoded according to the bit length occupied by the original data.
  • the numerical interval is obtained by dividing the preset numerical range through preset dividing points.
  • the preset numerical range is the numerical range of the original data, and the dividing points are all powers of two.
  • the number of numerical intervals is an integer power of two.
  • obtaining the bit length occupied by the original data corresponding to the data to be decoded includes:
  • the bit length occupied by the corresponding original data is determined according to the value of the flag bit of each interval in the data to be decoded.
  • decoding the original data from the data to be decoded according to the bit length occupied by the original data includes:
  • bit length value After reading the value of each interval flag bit, according to the bit length occupied by the corresponding original data, the bit length value is sequentially read from the data to be decoded to decode the corresponding original data.
  • Exemplary embodiments of the present disclosure also provide a data processing method, which is applied to the data processing system 1500 as shown in FIG. 15.
  • the data processing system 1500 includes: a configurator 1510, a memory 1520, and a processor 1530 connected in sequence.
  • the flow of the data processing method can be referred to as shown in FIG. 16, including the following steps S1610 to S1630:
  • step S1610 any one of the data encoding methods in the exemplary embodiments of the present disclosure (the method shown in FIG. 3, FIG. 11 or FIG. 13) is executed by the configurator, and the data block to be encoded composed of preset data is encoded To generate code stream data;
  • Step S1620 Write the code stream data into the memory to reduce the writing bandwidth to the memory
  • step S1630 the code stream data in the memory is read by the processor, and the code stream data is decoded to reduce the read bandwidth of the memory.
  • the preset data is data that needs to be read and written between the processor and the configurator, for example, it may be a parameter of a neural network.
  • the parameters of the neural network may be divided into blocks to obtain the aforementioned data block to be encoded.
  • the configurator 1510 may include an encoder 1511, so that the configurator 1510 specifically encodes the data block to be encoded through the encoder 1511.
  • the processor 1530 may include a decoder 1531, so that the processor 1530 specifically decodes the code stream data through the decoder 1531.
  • the processor 1530 may further include a static random access memory 1532, and the static random access memory 1532 is configured to read code stream data from the memory 1520, so that the processor 1530 can pass through the decoder 1530 decodes the code stream data in the SRAM 1532 to obtain the data block to be encoded.
  • the configurator 1510 writes the code stream data into the memory 1520, which can take up less write bandwidth than directly writing the original data in the data block to be encoded; the processor 1530 reads the code stream data from the memory 1520, compared to Directly reading the original data in the data block to be encoded can take up less reading bandwidth. If the data block to be coded is a parameter of a neural network, the processor 1530 is decoding the data block to be coded, and may run the neural network based on the data block to be coded.
  • Exemplary embodiments of the present disclosure also provide an encoder.
  • the encoder may refer to the encoder 1511 in FIG. 15 and execute any data encoding method in the exemplary embodiments of the present disclosure (as shown in FIG. 3 and FIG. 11). Or the method shown in Figure 13), the data block to be encoded is encoded.
  • Fig. 17 shows an exemplary architecture of an encoder, which mainly includes an encoding overhead calculation module, an encoding method selection module, and a data encoding module for each candidate encoding method.
  • the encoding overhead is calculated first, the target encoding method is selected according to the calculation result, and then in the data encoding module of the target encoding method, the data block to be encoded is encoded to obtain the bitstream data; if all are calculated
  • the coding rate of the candidate coding methods is greater than or equal to 1, then the Bypass mode is selected, no coding is performed, and the original data of the data block to be coded is written into the code stream data.
  • Exemplary embodiments of the present disclosure also provide a decoder.
  • the decoder may refer to the decoder 1531 in FIG. 15 to execute any data encoding method in the exemplary embodiments of the present disclosure (as shown in FIG. 10 and FIG. 12). Or the method shown in Figure 14), the data to be decoded is decoded.
  • FIG. 18 shows an exemplary architecture of a decoder, which mainly includes an encoding method analysis module, a decoding method selection module, and a data decoding module of each decoding method.
  • the data processing system 1500 may include: a configurator 1510, a memory 1520, and a processor 1530 connected in sequence. among them:
  • the configurator 1510 is used to execute any data encoding method in the exemplary embodiments of the present disclosure (the method shown in FIG. 3, FIG. 11 or FIG. 13), and to encode a data block to be encoded composed of preset data , Generate code stream data and write the code stream data into the memory 1520 to reduce the write bandwidth to the memory 1520;
  • the processor 1530 is used to read the code stream data in the memory 1520 and decode the code stream data to reduce the read bandwidth of the memory.
  • the processor 1530 When the processor 1530 decodes the code stream data, it may adopt a decoding method corresponding to the encoding of the configurator 1510, such as the method shown in FIG. 4, FIG. 10, or FIG.
  • Exemplary embodiments of the present disclosure also provide a movable platform.
  • the movable platform may include:
  • the power system 1920 is set in the body 1910, and the power system 1920 is used to provide power for the movable platform;
  • the above-mentioned data processing system 1930 may be applied to a functional system of a movable platform such as a power system, an operating system, and the like.
  • the data processing system uses a neural network for data processing, it can achieve lossless encoding and decoding of the parameters of the neural network, ensuring that the parameters will not introduce additional errors and do not need to retrain the neural network, and Reduce system bandwidth overhead. Can satisfy the use of hardware resources with lower conditions to realize the operation of the neural network.
  • Exemplary embodiments of the present disclosure also provide a computer-readable medium on which a computer program is stored.
  • any data encoding method or data decoding method in the exemplary embodiments of the present disclosure can be implemented, for example, Perform the method steps in Figure 3, Figure 10, Figure 11, Figure 12, Figure 13, or Figure 14.
  • the computer-readable medium may be included in the movable object described in the foregoing embodiments; or may exist alone without being assembled into the movable object.
  • the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable removable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
  • the example embodiments described here can be implemented by software, or can be implemented by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, U disk, mobile hard disk, etc.) or on the network , Including several instructions to make a computing device (which may be a personal computer, a server, a terminal device, or a network device, etc.) execute the method according to the exemplary embodiment of the present disclosure.
  • a computing device which may be a personal computer, a server, a terminal device, or a network device, etc.
  • modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory.
  • the features and functions of two or more modules or units described above may be embodied in one module or unit.
  • the features and functions of a module or unit described above can be further divided into multiple modules or units to be embodied.

Abstract

一种数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质。其中一种数据编码方法包括:获取多个候选编码方式对于待编码数据块的编码开销,从所述多个候选编码方式中确定编码开销最小的目标编码方式;通过所述目标编码方式对所述待编码数据块进行编码;其中,所述候选编码方式包括残差编码和哈夫曼编码。通过无损编码的方式对数据进行编码,以减小码流数据读写所占的位宽,从而加快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。

Description

数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质 技术领域
本公开涉及数据处理技术领域,尤其涉及数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质。
背景技术
随着大数据和人工智能技术的发展,计算机需要处理的数据量越来越庞大。以CNN(Convolutional Neural Networks,卷积神经网络)网络为例,权重数据为主要参数,参数规模非常大,通常达到百万甚至千万的级别。如此庞大的数据量,在读写过程中占用带宽高,对硬件的计算和存储能力要求较高,进而限制了数据处理及使用的应用场景。
因此,如何在不影响数据准确率的前提下,减小数据读写的规模,对加快硬件设备的计算处理速度、节省存储资源以及拓宽数据应用场景,具有重要的意义。
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本公开的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。
发明内容
本公开提供了数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质,进而至少在一定程度上改善现有技术中数据读写占用带宽高的问题。
本公开的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本公开的实践而习得。
根据本公开的第一方面,提供一种数据编码方法,包括:获取多个候选编码方式对于待编码数据块的编码开销,从所述多个候选编码方式中确定编码开销最小的目标编码方式;通过所述目标编码方式对所述待编码数据块进行编码;其中,所述候选编码方式包括残差编码和哈夫曼编码。
根据本公开的第二方面,提供一种数据解码方法,包括:对待解码数据进行解析,确定多个候选编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;通过所述目标解码方式对所述待解码数据进行解码,得到所述待解码数据对应的原始数据;其中,所述候选编码方式包括残差编码和哈夫曼编码。
根据本公开的第三方面,提供一种数据编码方法,包括:获取待编码数据块;确定对所述待编码数据块中的残差进行行编码所需的编码总位长和列编码所需的编码总位长,采用其中编码总位长较小的编码方式,对所述待编码数据块中的残差进行编码。
根据本公开的第四方面,提供一种数据解码方法,包括:获取由残差编码对原始数据块 进行编码所得到的待解码数据;当所述残差编码为行编码时,从所述待解码数据中读取参考数据和残差,逐行对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块;当所述残差编码为列编码时,从所述待解码数据中读取参考数据和残差,逐列对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块。
根据本公开的第五方面,提供一种数据编码方法,包括:获取待编码数据块;将所述待编码数据块中的数据划分为多个数值区间,对不同数值区间的数据采用不同位长进行编码。
根据本公开的第六方面,提供一种数据解码方法,包括:获取待解码数据;确定所述待解码数据所对应的原始数据所占的位长,处于不同数值区间的原始数据具有不同的位长;按照所述原始数据所占的位长从所述待解码数据中解码出所述原始数据。
根据本公开的第七方面,提供一种数据处理方法,应用于依次连接的配置器、存储器和处理器,所述方法包括:通过所述配置器执行上述第一、第三或第五方面提供的数据编码方法,对由预设数据所构成的待编码数据块进行编码,生成码流数据;将所述码流数据写入所述存储器,以降低对所述存储器的写带宽;通过所述处理器读取所述存储器内的码流数据,并对所述码流数据进行解码,以降低对所述存储器的读带宽。
根据本公开的第八方面,提供一种编码器,所述编码器通过执行上述第一、第三或第五方面提供的数据编码方法,对待编码数据块进行编码。
根据本公开的第九方面,提供一种解码器,所述解码器通过执行上述第二、第四或第六方面提供的数据解码方法,对待解码数据进行解码。
根据本公开的第十方面,提供一种数据处理系统,包括:依次连接的配置器、存储器和处理器;所述配置器用于执行上述第一、第三或第五方面提供的数据编码方法,对由预设数据所构成的待编码数据块进行编码,生成码流数据,并将所述码流数据写入所述存储器,以降低对所述存储器的写带宽;所述处理器用于读取所述存储器内的码流数据,并对所述码流数据进行解码,以降低对所述存储器的读带宽。
根据本公开的第十一方面,提供一种可移动平台,包括:机体;动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,上述第十方面提供的数据处理系统。
根据本公开的第十二方面,提供一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述第一至第六方面提供的任一种方法。
本公开的技术方案具有以下有益效果:
根据上述数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读存储介质,一方面,通过设置多种候选编码方式,采用编码开销最小的目标编码方式对待编码数据块进行编码,具有较高的灵活性,可以针对待编码数据块的特点,选择最合适的编码方式,使编码后的码流位长最低,以减小码流数据读写所占的位宽,从而加 快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。另一方面,各候选编码方式,包括残差编码、哈夫曼编码、数值分段编码等均为无损编码,能够保证待编码数据块经过编码和解码后的准确率;特别适用于对神经网络的参数进行编码,和相关技术中采用权重剪枝和共享的方式相比,本示例性实施方式不会降低网络的收敛速度,也无需精调超参数,无需反复训练,具有更高的实用性。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施方式,并与说明书一起用于解释本公开的原理。显而易见地,下面描述中的附图仅仅是本公开的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出LeNet的结构示意图;
图2示出CNN硬件计算平台框架的示意图;
图3示出本示例性实施方式中一种数据编码方法的流程图;
图4示出CNN的卷积核示意图;
图5示出本示例性实施方式中对数据块分块的示意图;
图6示出本示例性实施方式中计算残差的示意图;
图7示出本示例性实施方式中计算行/列残差的示意图;
图8示出本示例性实施方式中进行数值分段编码的示意图;
图9示出本示例性实施方式中码流结构的示意图;
图10示出本示例性实施方式中一种数据解码方法的流程图;
图11示出本示例性实施方式中另一种数据编码方法的流程图;
图12示出本示例性实施方式中另一种数据解码方法的流程图;
图13示出本示例性实施方式中再一种数据编码方法的流程图;
图14示出本示例性实施方式中再一种数据解码方法的流程图;
图15示出本示例性实施方式中数据处理系统的结构示意图;
图16示出本示例性实施方式中一种数据处理方法的流程图;
图17示出本示例性实施方式中一种编码器的架构图;
图18示出本示例性实施方式中一种解码器的架构图;
图19示出本示例性实施方式中一种可移动平台的结构图。
具体实施方式
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本公开将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施方式中。
CNN是一种前馈神经网络,是深度学习技术中极具代表的网络结构之一,它提供了一种端到端的处理方式,在图像和语音处理领域取得了很大的成功,在国际标准的ImageNet数据集上,许多成功的模型都是基于CNN,相比传统神经网络提升计算机视觉任务的精度。
图1所示是LeNet(一种经典的CNN模型)的组成结构,主要由以下五种结构组成:输入层(Input)、卷积层(Convolution,图中C1表示第1个中间层为卷积层)、池化层(或称下采样层,Subsampling,图中S2表示第2个中间层为池化层)、全连接层(Full Connection,图1中F6表示第6个中间层为全连接层)和输出层(Output)。输入层是整个神经网络的输入,一般代表一张图像的像素矩阵;卷积层是通过每个卷积核对输入特征图进行卷积计算,试图将神经网络中的每一小块进行更加深入地分析,从而得到抽象程度更高的特征;池化层不会改变三维矩阵的深度,但可以缩小矩阵的大小,类似下采样;全连接层的目的是完成分类任务,前面的卷积层和池化层是自动图像特征提取的过程,在特征提取完成后需要进行分类;输出层用于分类问题,全连接层的输出经过高斯连接(Gaussian Connection),再经过归一化处理(如采用归一化指数函数softmax),得到当前样例属于不同种类的概率分布情况,进而完成整个网络的任务。如图1所示,输入层是大小为32x32x1的单通道图像,使用6个5x5x1大小的卷积核,通过卷积可以得到C1层的6@28x28特征图(feature map),数字6代表C1层特征图的通道数,同时也是卷积层使用的卷积核个数。每层的所有卷积核包含了大量的参数。
LeNet是早期较为简单的CNN结构,按照目前CNN的发展趋势,网络层数在逐渐加深,使得整个网络的参数模型尺寸较大,在芯片应用时占用的系统带宽很高,这对设备功耗和运行速度带来了巨大的挑战。图2示出CNN硬件计算平台框架,其中配置器的任务是分配CNN的参数,并按规定格式写入DDR(Double Data Rate Synchronous Dynamic Random Access Memory,双倍数据率同步动态随机存取存储器,通常简称为DDR),CNN计算核在计算过程中会将DDR中存储的参数读取至SRAM(Static Random Access Memory,静态随机存取存储器)中。以VGG16网络(另一种经典的CNN模型)为例,CNN计算核需要从DDR载入的原始权重总数据量约为132.81MB,以帧率30计算得到其占用的DDR读带宽为31.13Gbps,如果发生反复读取的时候,带宽会更大,可见降低权重数据占用的带宽是十分必要的。
相关技术中,大多采用权重剪枝和共享的方式来减少参数规模,属于网络模型修改的范畴,这种方式可能会降低网络的收敛速度,也可能影响网络精度,而且剪枝需要手动设置层的敏感度,即需要精调超参数,在某些应用中需要不断的反复训练,增加资源开销。
鉴于上述一个或多个问题,本公开的示例性实施方式提供一种数据编码方法、数据解码 方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读存储介质。下面对本示例性实施方式的各个方面进行具体说明。
图3示出了本示例性实施方式中一种数据编码方法的流程图。参照图3所示,该方法包括以下步骤S310和S320:
步骤S310,获取多个候选编码方式对于待编码数据块的编码开销,从多个候选编码方式中确定编码开销最小的目标编码方式。
本示例性实施方式中,待编码的数据为数据块的形式,呈现出行列的排布,例如可以是矩阵、数据表等。
在一种可选的实施方式中,待编码数据块可以通过以下方式获取:
获取待压缩的神经网络,将神经网络的参数排列为数据块;
按照预设尺寸将数据块分块,将每个分块分别作为待编码数据块。
以CNN为例进行示意性说明,图4示出了CNN的权重参数格式,由N个卷积核组成,每个卷积核是大小为C*Kh*Kw的三维结构,其中,N为下一层特征图的通道数,C为当前层特征图的通道数,Kw和Kh分别为卷积核的宽和高。权重参数的总数量为N*C*Kh*Kw,将这些参数按照一定的顺序展开为二维的数据块,例如可以以Kw为行宽,得到列高为N*C*Kh的数据块。
在数据读写中,是以数据包为单位进行数据传输的,对于较大的数据块,无法一次传输完,因此可以对其进行分块。具体而言,可以根据数据特点,结合实际需求与硬件条件,确定用于数据分块的预设尺寸,将数据块分割为预设尺寸的多个数据分块,每个数据分块为一个待编码数据块。预设尺寸一般包括预设宽度和预设高度,例如分别为M和N,则可以按照M*N的预设尺寸,将上述Kw*N*C*Kh的数据块分成一个个M*N的待编码数据块。
进一步的,在按照预设尺寸将数据块分块时,如果数据块的尺寸不满足为预设尺寸的整数倍,则对数据块进行数据填充,使填充后的数据块的尺寸满足为预设尺寸的整数倍。参照图5所示,以M=N=4为例,数据块的宽度(Width)为10,高度(Height)为7,在按照4*4的预设尺寸分块时,会产生剩余的部分。因此可以将数据块填充为4*4的整数倍,例如填充两列数值和一行数值,得到12*8的数据块,则可以恰好被4*4分块。
更进一步的,在对数据块进行数据填充时,可以在数据块的下方增加新的行,在新的行中填充其上方相邻的数据,及/或在数据块的右侧增加新的列,在新的列中填充其左侧相邻的数据。参照上述图5所示,在数据块下方增加第8行,其数据可以复制第7行中的数据,在数据块右侧增加第11列和第12列,其数据均可以复制第10列的数据。需要说明的是,根据实际需要,可以仅增加新的行或新的列;如果需要同时增加新的行和新的列,则无论先增加行还是先增加列,得到的填充结果相同,因此本公开对于顺序不做限定。
编码开销是指对待编码数据块进行编码后所生成的码流数据所占的位宽。候选编码方式至少包括残差编码和哈夫曼编码,也可以包括其他编码方式,如数值分段编码等。本示例 性实施方式中,设置多个候选编码方式,分别确定每种候选编码方式对待编码数据块进行编码后,得到的码流数据的数据量,选择其中数据量最小的候选编码方式,作为目标编码方式。
需要说明的是,在计算编码开销时,通常采用压缩率进行度量,即编码后数据与编码前数据的数据大小之比,压缩率越低,编码开销越小。本示例性实施方式可以计算出每种候选编码方式对待编码数据块进行编码的压缩率,选取压缩率最低的候选编码方式作为目标编码方式;如果所有候选编码方式的压缩率均大于或等于1,表示采用任意一种候选编码方式进行编码后,数据量反而增加,则可以采取Bypass(跳过)模式,即不对待编码数据块进行编码,直接传输原始数据。
步骤S320,通过目标编码方式对待编码数据块进行编码。
本示例性实施方式中,在候选编码方式中,选择编码开销最小的目标编码方式对待编码数据块进行编码,可以使压缩效果达到最佳。
针对不同的待编码数据块,所确定出的目标编码方式可能是不同的,进而通过为待编码数据块选择合适的、压缩效果最优的目标编码方式进行编码,使压缩后得到的码流数据的数据量最小。
一般的,数值分段编码和残差编码的实现复杂度相对较低,例如可以适用于图像复杂度较低的权重数据编码,其中数值分段编码特别适用于数值集中分布在较小范围的数据,残差编码特别适用于数据邻域相关性较强的数据;而哈夫曼编码适用于更加复杂的数据编码,例如数值分布较为分散、或者数据邻域相关性较弱的数据等;可见,每种候选编码方式分别具有各自的特点以及适用性。因此,本示例性实施方式通过设置多种候选编码方式,采用编码开销最小的目标编码方式对待编码数据块进行编码,具有较高的灵活性,可以针对待编码数据块的特点,选择最合适的编码方式,使编码后的码流位长最低,以减小码流数据读写所占的位宽,从而加快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。
下面对每种候选编码方式分别进行说明。
(一)残差编码
当目标编码方式为残差编码时,步骤S320可以通过以下方式实现:
获取对待编码数据块中的残差进行行编码的编码开销和列编码的编码开销,采用其中编码开销较小的方式对待编码数据块中的残差进行编码。
其中,残差是指待编码数据块中相邻两数据之差。如图6所示,待编码数据的初始值为p1、p2、p3、p4,选定一参考值p0,分别计算相邻两数据之差,得到残差值d1、d2、d3、d4。
待编码数据块中存在两种残差:行残差,即每个数据与其左侧相邻数据之差;列残差,即每个数据与其上方相邻数据之差。因而也存在对应的两种残差编码方式:行编码,即对行残差进行编码;列编码,即对列残差进行编码。针对不同的待编码数据块,行编码和列编码所得到的码流数据的数据量可能是不同的,因此选择其中数据量较小,即编码开销较小的方 式,进行残差编码。
在一种可选的实施方式中,可以通过以下方式获取行编码和列编码的编码开销:
以参考数据为起始,在待编码数据块的每一行中计算每个数据与其左侧相邻数据之间的残差,以及在待编码数据块的每一列中计算每个数据与其上方相邻数据之间的残差;
分别计算每一行的最大残差和每一列的最大残差,根据每一行的最大残差确定每一行的码流位长,根据每一列的最大残差确定每一列的码流位长;
统计各行的码流总位长,得到行编码的编码开销,统计各列的码流总位长,得到列编码的编码开销。
其中,参考数据可以选择待编码数据块中的第一个数据(即左上角的数据),或者根据编码习惯设置为其他位置的数据,也可以选择任意指定的数值,例如0、1等。
参照图7所示,以4*4的待编码数据块为例,选择左上角的数据为参考数据,分别计算行残差和列残差;然后确定每一行的最大残差和每一列的最大残差(maxDiff);对每一行或每一列,采用二进制的定长编码方式对每个残差进行编码,由此可以计算编码所需的码流位长,例如第一行的最大残差为1,则对第一行中的每个残差编码需要位长为1,第二行的最大残差为5,则对第二行中的每个残差编码需要位长为3。计算方法可以如下公式(1)所示:
Figure PCTCN2019126393-appb-000001
利用公式(1)可以计算出行编码和列编码的编码开销,对图7中的数据进行计算,可得:
行编码,
Figure PCTCN2019126393-appb-000002
列编码,
Figure PCTCN2019126393-appb-000003
Figure PCTCN2019126393-appb-000004
因此可以确定图7中行编码的编码开销较小。
在确定采用行编码或列编码后,对待编码数据块进行实际编码,具体过程如下:
当采用行编码时,根据每一行的最大残差计算每一行中的每个残差所需的码流位长,以对每一行中的每个残差分别进行编码;
当采用列编码时,根据每一列的最大残差计算每一列中的每个残差所需的码流位长,以对每一列中的每个残差分别进行编码。
其中,码流位长的计算方式可以参见公式(1),举例而言,对于残差5,其码流位长为3bit,可以编码为101;对于残差126,其码流位长为7bit,可以编码为1111110。
为了标识出采用的是行编码还是列编码,在一种可选的实施方式中,可以在待编码数据块的码流结构中设置行列方式标志位,用于记录行编码或列编码所对应的数值。例如,行列方式标志位可以为1bit,0代表行编码,1代表列编码。这样便于在解码时根据行列方式标志位确定所采用的是行编码还是列编码,从而能够还原出待编码数据块。行列方式标志位可 以设置于残差编码的码流结构中的起始位置,也可以设置于其他指定位置。
在一种可选的实施方式中,当采用行编码时,可以在待编码数据块的每一行的码流结构中设置数值长度标志位,用于记录该行的每个残差所需的码流位长。当采用列编码时,可以在待编码数据块的每一列的码流结构中设置数值长度标志位,用于记录该列的每个残差所需的码流位长。例如在图7中,对第一行进行残差编码时,确定第一行的每个残差需要1bit,则数值长度标志位可以设为0,表示1bit。
进一步的,在计算残差时,是使用后一数值减去前一数值,因此残差可能为正也可能为负。为了区别残差的正负,可以在每个残差的码流结构中设置符号标志位,用于记录该残差为正或负。例如,符号标志位可以为1bit,0代表残差为正,1代表残差为负。一般的,将每个残差的码流结构中,对残差数值进行编码的部分称为数值位,则符号标志位可以设置于每个残差的数值位之前或数值位之后。
在加入符号标志位的情况下,每个残差的码流结构中增加1bit,因此可以将公式(1)转变为以下公式(2):
Figure PCTCN2019126393-appb-000005
在对神经网络的参数进行编码时,由于神经网络的参数一般在[0,255]范围内,因此残差的范围为[-255,255],每个残差的码流位长在2-9之间。可以在每个残差的码流结构之前,采用3bit的数值长度标志位表示残差的码流位长,其对应关系可以参考表1所示。
表1
Figure PCTCN2019126393-appb-000006
在一种可选的实施方式中,可以在残差编码的码流结构中依次设置行列方式标志位、每个残差的数值长度标志位、符号标志位和数值位。以图7中采用行编码为例进行说明,可以采用以下两种编码方式:
1、码流结构中,依次为:行列方式标志位为0,表示采用行编码,然后是第一行的数值长度标志位,为000,然后是第一行中每个残差的符号标志位和数值位;然后是第二行的数值长度标志位,以及第二行中每个残差的符号标志位和数值位…,完整的码流结构如下:
0,
000,00,00,01,00,
010,0000,0000,0001,0101,
100,000001,000000,000110,010101,
110,00000001,01111110,00100101,00111100,
共93个bit。
2、与1不同的是,对每个残差均设置数值长度标志位。码流结构中,依次为:行列方式标志位为0,表示采用行编码,然后是第一个残差(0)的数值长度标志位,为000,其符号标志位为0,数值为0;然后是第二个残差的数值长度标志位、符号标志位和数值位…,完整的码流结构如下:
0,
00000,00000,00001,00000,
00000,00000,01001,0100101,
00001,00000,0100110,100010101,
00001,11001111110,1010100101,1010111100,
共105个bit。
对待编码数据块采用常规的8bit进行编码,共4*4*8=128个bit。可见,残差编码能够减少码流数据的位宽,当待编码数据块的尺寸较大时,效果更佳明显。
需要说明的是,上述两种编码方式中码流结构中增加间隔符,且分行表示,是为了便于理解。在实际编码中,码流结构是完全连续的二进制数值。
一般来说,上述方式1的码流位长更低,解码速度更快,但是需要获知待编码数据块的尺寸,特别是每一行或每一列有多少个数据。在一种可选的实施方式中,可以在待编码数据块的码流结构中设置尺寸标志位,用于记录待编码数据块的原始尺寸。例如可以在码流结构的起始位置设置16bit的尺寸标志位,其中8bit用于记录待编码数据块的宽度,另外8bit用于记录待编码数据块的高度。
基于上述残差编码,在未进行编码的情况下,可以通过以下方式确定其编码开销:
计算采用行编码或列编码对待编码数据块中的残差进行编码所需的码流总位长,获取其中较小的码流总位长,作为残差编码对于待编码数据块的编码开销。
举例来说,若待编码数据块的尺寸为M*N,记每一行的最大残差分别为Max Diff(R1)、Max Diff(R2)、…、Max Diff(RN),每一列的最大残差分别为Max Diff(C1)、Max Diff(C2)、…、Max Diff(CM),采用公式(2)计算行编码和列编码所需的码流总位长,分别为:
Figure PCTCN2019126393-appb-000007
Figure PCTCN2019126393-appb-000008
其中,Row表示行编码,Column表示列编码。以行编码为例,1表示行列方式标志位的位长,3表示每一行的数值长度标志位的位长,
Figure PCTCN2019126393-appb-000009
表示每个残差的位长。通过公式(3)和(4),可以准确计算出残差编码对于待编码数据块的编码开销。
本示例性实施方式所提供的上述残差编码,针对二维结构的待编码数据块,可以较为灵活地选择行编码或列编码的方式进行编码,以进一步减小编码开销。
(二)哈夫曼编码
当目标编码方式为哈夫曼编码时,步骤S320可以通过以下方式实现:
统计待编码数据块中的数据出现频次,根据数据出现频次生成哈夫曼树;
根据哈夫曼树中各个叶子节点的路径生成哈夫曼树对应的哈夫曼表;
采用哈夫曼表对待编码数据块中的数据进行编码。
其中,数据出现频次是指在整个待编码数据块中,每个数据出现的次数。可以按照出现频次由低到高(或由高到低)排列各数据,然后生成哈夫曼树:将频次最低的两个数据作为树的两个叶子节点,合并生成这两个节点的父节点,父节点的频次为两个子节点的频次之和,将父节点到两个子节点的支路分别进行编码,例如可以编码为0和1;将父节点取代两个子节点的数据,重新排列,并重复上述过程;多次合并直到合并概率为1,合并得到根节点,此时将所有数据均映射为哈夫曼树的节点,得到哈夫曼树。哈夫曼树中,每一条支路都有编码,以数据A为例,从根节点开始,到数据A所在节点的路径中,将所有支路的编码连接起来,就是数据A的编码,由此可以得到每个数据的编码,记录在哈夫曼表中。哈夫曼表实际是一张编码映射表,记录了每个数据及其对应的编码。采用哈夫曼表可以对待编码数据块中的数据进行编码。
基于上述哈夫曼编码,在未进行编码的情况下,可以通过以下方式确定其编码开销:
计算采用哈夫曼编码对待编码数据块进行编码时,哈夫曼表所需的码流位长以及待编码数据块中的每个数据所需的码流位长,统计码流总位长,作为哈夫曼编码对于待编码数据块的编码开销。
其中,根据哈夫曼表可以确定每个数据所需的码流位长。由于解码时也需要用到哈夫曼表,待编码数据块的码流结构中需要记录哈夫曼表的信息,可以计算将哈夫曼表通过二进制的定长编码等方式进行编码所需的码流位长。由此可以统计哈夫曼表和每个数据所需的码流总位长,得到哈夫曼编码对于待编码数据块的编码开销。
需要说明的是,除了上述哈夫曼表和每个数据外,码流结构中还可以包含其他信息,例如可以在待编码数据块的码流结构中设置尺寸标志位,用于记录待编码数据块的原始尺寸等等。本公开对此不做限定。
(三)数值分段编码
除了上述残差编码和哈夫曼编码外,候选编码方式还可以包括数值分段编码。当目标编码方式为数值分段编码时,步骤S320可以通过以下方式实现:
将待编码数据块中的数据划分为多个数值区间,对不同数值区间的数据采用不同位长进行编码。
概括来说,按照每个数据的数值大小,将其划入不同的数值区间,若数值较大,则需要较多的bit,若数值较小,则需要较少的bit。相比于现有技术中对所有数据均采用8bit、16bit进行编码的方式,具有更强的针对性,可以减少大量的冗余位长,提高编码效率。
在一种可选的实施方式中,将待编码数据块中的数据划分为多个数值区间,包括:
通过预设的分割点将预设数值范围划分为多个数值区间;
将待编码数据块中的数据分别划分至对应的数值区间内。
其中,预设数值范围可以是待编码数据块中的数据所处的数值范围,例如神经网络的参数通常处于[0,255]内,则可以以[0,255]为预设数值范围。分割点均可以是2的整数次幂,例如2、4、8等,可以得到诸如[0,2)、[2,4)、[4,8)等数值区间,这样使每个数值区间的数据所需的编码位长相同。根据每个数据的数值,划入对应的数值区间。
进一步的,上述分割点可以通过以下方式确定:
统计待编码数据块中的数据分布,根据数据分布确定分割点。
一般的,对于数据分布较为集中的数值段,可以单独划分出一个数值区间,对于数据分布较为分散的数值段,可以将多个数值段合并为一个数值区间。
在一种可选的实施方式中,数值区间的数量可以是2的整数次幂。这样便于对数值区间本身进行编码表示。
在一种可选的实施方式中,待编码数据块进行数值分段编码后的码流结构可以包括数值位,数值位用于记录数据编码。对不同数值区间的数据采用不同位长进行编码,可以通过以下方式实现:
根据每个数值区间的上限数值确定每个数值区间对应的数值位的位长;
根据每个数值区间对应的数值位的位长对待编码数据块中的每个数据进行编码。
举例来说,若数据处于数值区间[4,8)中,该数值区间的上限数值为7(假设数据均为正整数),7需要3bit的位长进行编码(7的编码为111),因此为该数值区间的每个数据分配3bit,作为其数值位;若数据处于数值区间[8,16)中,该数值区间的上限数值为15,15需要4bit的位长进行编码(15的编码为1111),因此为该数值区间的每个数据分配4bit,作为其数值位。
在一种可选的实施方式中,待编码数据块进行数值分段编码后的码流结构还可以包括区间标志位,区间标志位用于标志数据所处的数值区间。对不同数值区间的数据采用不同位长进行编码,还可以包括以下步骤:
根据数值区间的数量确定区间标志位的位长;
根据每个数据所处的数值区间确定每个数据的区间标志位。
其中,区间标志位需要对每个数值区间能够唯一表示,因此数值区间的数量越多,所需的区间标志位的位长越高。例如,若数值区间的数量为2,则区间标志位用1bit即可,0、1分别表示两个数值区间;若数值区间的数量为4,则区间标志位需要2bit,00、01、10、11分别表示4个数值区间。每个数据的区间标志位可以位于数值位之前,以便于在解码时,先确定数据处在哪个数值区间,然后确定数值位的位长,根据该位长进行解码。
进一步的,区间标志位的位长可以满足以下公式(5):
Figure PCTCN2019126393-appb-000010
Q为数值区间的数量。可见,当Q处于(2i,2i+1](i为正整数)时,所需的区间标志位的位长均为i+1,例如数值区间为3个或4个时,所需的区间标志位均为2bit。由此,设置数值区间的数量为2的整数次幂,可以充分地利用区间标志位的每个bit,提高编码效率。
数值区间Si对应的数值位的位长可以满足以下公式(6):
Figure PCTCN2019126393-appb-000011
max(Si)表示数值区间Si的上限数值。在获知数值分段信息的情况下,根据数值区间Si可以确定其上限数值max(Si),进而确定数值位的位长。
下面参照图8对数值分段编码进行示例性说明,图8中的待编码数据块和图7相同。图8示出了两种数值分段方式:第一种是将预设数值范围[0,255]分为两个数值区间,分别为[0,8)和[8,255],区间标志位可以为1bit,0表示[0,8),1表示[8,255];第二种是将预设数值范围[0,255]分为四个数值区间,分别为[0,2)、[2,8)、[8,32)和[32,255],区间标志位可以为2bit,00表示[0,2),01表示[2,8),10表示[8,32),11表示[32,255]。图8示出了在两种数值分段方式下,每个数据的区间标志位。
在第一种数值分段方式下,1的编码为0,001,6的编码为0,110,28的编码为1,00011100,127的编码为1,01111111。每个数据的编码中,第一位为区间标志位,后面的为数值位。
在第二种数值分段方式下,1的编码为00,1,6的编码为01,110,28的编码为10,11100,127的编码为11,01111111。每个数据的编码中,第一位和第二位为区间标志位,后面的为数值位。
基于上述数值分段编码,在未进行编码的情况下,可以通过以下方式确定其编码开销:
根据待编码数据块中的每个数据所处的数值区间,计算每个数据所需的码流位长,统计码流总位长,作为数值分段编码对于待编码数据块的编码开销。
其中,码流结构除了包含每个数据的区间标志位和数值位以外,还可以包含其他信息,例如可以在待编码数据块的码流结构中设置尺寸标志位,用于记录待编码数据块的原始尺寸等等。本公开对此不做限定。
此外,由图8可知,不同的数值分段方式,对于编码结果有直接的影响。在一种可选的实施方式中,可以在码流结构中设置分段方式标志位,用于记录编码时采取了哪种数值分段方式。 下面对数值分段方式做进一步说明。
实际应用中,若待编码数据块中的数据均处于[0,255]以内,该范围内,以2的整数次幂作为候选分割点,有2、4、8、16、32、64、128共7个候选分割点。其中,通过实践与计算发现,将128作为分割点,所能实现编码效果为负,即会导致位长增加,因此将128删除,剩余2、4、8、16、32、64共6个候选分割点。在这6个候选分割点中,为了将数值区间的数量控制为2的整数次幂,可以选择两个数值区间或四个数值区间,即从6个候选分割点中选择1个分割点或者选择3个分割点,这样共有
Figure PCTCN2019126393-appb-000012
种数值分段方式。通过实践进一步发现,在选择3个分割点的所有组合方式中,有10种方式是较为有效的,因此共有16种数值分段方式。可以将16种数值分段方式按顺序排列,并编号1-16,记录为映射表。设置4bit的分段方式标志位,0000表示第1种数值分段方式,0001表示第2种,…,1111表示第16种,因此在解码时,通过解码出分段方式标志位的数值,再查找映射表,可以确定编码时使用了哪种方式,进而确定每个数值区间及其数值位的位长,以便于解码数值位。
对16种数值分段方式,以R_h(h=1、2、…、16)分别表示其压缩率,以Z表示待编码数据块的数据数量,则Z*R_h为编码后的码流位长,即编码开销。在编码前,先计算16种数值分段方式的Z*R_h,选取其中的最小值,作为数值分段编码对于待编码数据块的编码开销。
本示例性实施方式所提供的上述数值分段编码,针对待编码数据块中数值分布的特征,可以较为灵活地选择一种数值分段方式,以进一步减小编码开销。
上面介绍了本示例性实施方式中三种候选编码方式及其编码开销的计算方法。在编码前,可以分别计算每种候选编码方式的编码开销,选择最小的候选编码方式作为目标编码方式,进行编码。需要说明的是,在对神经网络的参数编码时,将神经网络的参数分割为多个待编码数据块,可以对不同的待编码数据块,选择不同的目标编码方式。
在一种可选的实施方式中,在通过目标编码方式对待编码数据块进行编码时,可以在待编码数据块进行编码后的码流结构中设置编码方式标志位,编码方式标志位用于记录目标编码方式所对应的数值。例如可以设置2bit的编码方式标志位,00表示残差编码,01表示哈夫曼编码,10表示数值分段编码,11表示未采用编码(即Bypass模式,码流结构中为原始的待编码数据块);或者设置1bit的编码标志位,0表示未采用编码,1表示采用了编码,然后将编码方式标志位与残差编码中的行列方式标志位合并,00表示残差编码中的行编码,01表示残差编码中的列编码,10表示哈夫曼编码,11表示数值分段编码。如果还有其他候选编码方式,则可以按照候选编码方式的数量,调整编码方式标志位的位长。
图9示出了对神经网络的参数进行编码的码流结构的示意图。Frame表示原始的参数对应的码流结构,其中包括尺寸信息(Width和Height),哈夫曼表信息(Huffman_table,起始位置通常包括1bit标志位,标志是否使用了哈夫曼表),每个待编码数据块的码流结构(Slice_data)。每个待编码数据块的码流结构由编码方式标志位(Mode)和实际码流(Bit_stream)组成。
本公开上述实施方式中,一方面,通过设置多种候选编码方式,采用编码开销最小的目标编码方式对待编码数据块进行编码,具有较高的灵活性,可以针对待编码数据块的特点,选择最合适的编码方式,使编码后的码流位长最低,以减小码流数据读写所占的位宽,从而加快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。另一方面,各候选编码方式,包括残差编码、哈夫曼编码、数值分段编码等均为无损编码,能够保证待编码数据块经过编码和解码后的准确率;特别适用于对神经网络的参数进行编码,和相关技术中采用权重剪枝和共享的方式相比,本示例性实施方式不会降低网络的收敛速度,也无需精调超参数,无需反复训练,具有更高的实用性。
针对于经过上述实施方式的数据编码方法编码后的数据,本公开的示例性实施方式还提供了对应的数据解码方法。图10示出了本示例性实施方式中一种数据解码方法的流程图。参照图10所示,该方法包括以下步骤S1010和S1020:
步骤S1010,对待解码数据进行解析,确定多个候选编码方式中与待解码数据对应的目标编码方式,根据目标编码方式确定对应的目标解码方式。
其中,待解码数据一般是一维的连续二进制数值,并非像待编码数据块那样具有行列的排布。候选编码方式至少包括残差编码和哈夫曼编码,也可以包括其他编码方式,如数值分段编码等。
在一种可选的实施方式,待解码数据可以包括编码方式标志位,编码方式标志位具有固定位长,例如可以是2bit。步骤S1010可以对通过以下方式实现:
根据编码方式标志位的数值和候选编码方式的映射关系,确定出与待解码数据对应的目标编码方式。
例如读取编码方式标志位的数值为00,其对应的编码方式为残差编码,则确定目标编码方式为残差编码。
在确定出与所述待解码数据对应的目标编码方式,根据该目标编码方式可以确定对应的目标解码方式。示例性的,目标解码方式可以是目标编码方式的逆运算。
步骤S1020,通过目标解码方式对待解码数据进行解码,得到待解码数据对应的原始数据。
在确定目标解码方式后,采用目标解码方式对待解码数据按顺序进行解码。由于待解码数据是一维结构的,解码出的原始数据也是一维结构的。在一种可选的实施方式中,若原始数据本身为原始数据块的形式,原始数据块具有预设尺寸,在对待解码数据进行解码时,可以将解码得到的原始数据按照预设尺寸排列为原始数据块。例如预设尺寸为M*N,在解码出原始数据后,可以将其排列为M*N的数据块。
其中,预设尺寸可以记录于待解码数据的尺寸标志位中,通过读取尺寸标志位的数值,得到对应的尺寸信息,也可以由解码方在接收待解码数据前,通过配置表等方式获取到预设尺寸的信息。
对于不同的目标编码方式,其对应的目标解码方式也不同。下面分别对残差编码、哈夫曼编码、数值分段编码三种方式对应的解码方式,即残差解码、哈夫曼解码、数值分段解码,做具体说明。
(一)残差解码
当目标编码方式为残差编码时,其对应的目标解码方式为残差解码。步骤S1020可以通过以下方式实现:
当残差编码为行编码时,从待解码数据中读取参考数据和残差,逐行对参考数据和残差执行残差计算的逆运算,得到待解码数据对应的原始数据块;
当残差编码为列编码时,从待解码数据中读取参考数据和残差,逐列对参考数据和残差执行残差计算的逆运算,得到待解码数据对应的原始数据块。
其中,残差编码具体是行编码还是列编码,可以根据待解码数据中行列方式标志位的数值确定,例如读取行列方式标志位的数值,若为0,表示采用了行编码,若为1,表示采用了列编码;或者编码方式标志位可以包含行/列编码的信息,可以根据编码方式标志位的数值确定是行编码还是列编码,例如读取编码方式标志位的数值,若为00,表示采用了行编码,若为01,表示采用了列编码。
在确定行/列编码后,依次对待解码数据进行解码,将二进制数值转换为原始数据本身的格式,例如十进制等。解码得到的数据为残差,按照预设尺寸将其排列为残差数据块,其形式可以参照图7中所示。一般的,第一个残差可以是参考数据,也是第一个原始数据,也可以采用固定的数值(如0)作为参考数据。从参考数据开始,执行残差计算的逆运算。若为行编码,则依次将每个残差与其左侧相邻的数值相加,得到对应的原始数据;若为列编码,则依次将每个残差与其上方相邻的数值相加,得到对应的原始数据。
需要说明的是,残差解码用于解码出原始数据块,若原始数据本身是一维结构,则无法通过行/列的排布执行残差计算的逆运算。
在一种可选的实施方式中,在从待解码数据中读取残差时,可以先读取残差所占的位长,再根据该位长读取残差。具体而言,待解码数据中可以包括数值长度标志位,其具有固定位长,例如可以是3bit,用于记录残差所占的位长(即残差码流位长)。数值长度标志位有两种设置方式:
第一种是每一行(行编码时)或每一列(列编码时)前设置一个,以行编码为例:若原始数据块的预设尺寸为M*N,即每行有N个数据,则在读取行列方式标志位后,按顺序读取3bit数据;可以按照表1的对应关系确定第一行的残差码流位长,例如数值长度标志位为000,确定第一行的每个残差为2bit;然后依次读取N个2bit,为第一行的N个残差;再读取接下来的3bit数据,为第二行的数值长度标志位,并依此类推。
第二种是每个残差前设置一个,则在解码每个残差时,先读取数值长度标志位,以确定残差的位长,再读取该位长的数值,以解码出对应的残差。
在一种可选的实施方式中,待解码数据中还可以包括每个残差的符号标志位,一般位于残差的数值位之前,用于记录残差为正或负。因此在从待解码数据中读取残差时,可以根据每个符号标志位的数值确定其对应的残差为正或负。例如,在读取残差时,先读取1bit的符号标志位,若为0,表示残差为正,若为1,表示残差为负,然后读取后面的残差数值。这样在执行残差计算的逆运算时,残差包含正/负信息,可以得到更加准确的结果。
(二)哈夫曼解码
当目标编码方式为哈夫曼编码时,其对应的目标解码方式为哈夫曼解码。步骤S1020可以通过以下方式实现:
从待解码数据中读取哈夫曼表,根据哈夫曼表从待解码数据中解码出原始数据。
通常,采用哈夫曼编码时,将哈夫曼表的信息进行编码后,置于实际码流之前。这样在解码时,可以先读取哈夫曼表,然后根据哈夫曼表,可以采用正向匹配的方式对待解码数据逐个进行解码。
(三)数值分段解码
候选编码方式还可以包括数值分段编码。当目标编码方式为数值分段编码时,其对应的目标解码方式为数值分段解码。步骤S1020可以通过以下方式实现:
获取待解码数据所对应的原始数据所占的位长,处于不同数值区间的原始数据具有不同的位长;
按照原始数据所占的位长从待解码数据中解码出原始数据。
示例性的,数值区间可以是:通过预设的分割点对预设数值范围进行划分所得到的。其中,预设数值范围为原始数据所处的数值范围,例如神经网络的参数通常处于[0,255]内,则可以以[0,255]为预设数值范围。分割点均可以是2的整数次幂,例如2、4、8等,可以得到诸如[0,2)、[2,4)、[4,8)等数值区间,这样每个数据区间内的原始数据所占的位长相同。
在编码中,可以对数值区间本身进行编码表示。例如设置区间标志位,用于标志原始数据所处的数值区间。则可以根据待解码数据中每个区间标志位的数值确定对应的原始数据所占的位长。
在读取每个区间标志位的数值后,根据其对应的原始数据所占的位长,从待解码数据中顺次读取该位长的数值,以解码出对应的原始数据。
在一种可选的实施方式中,数值区间的数量可以是2的整数次幂,这样便于对数值区间本身进行编码表示,特别是设置区间标志位的的情况下,可以充分地利用区间标志位的每个bit,编码效率较高。
上面介绍了本示例性实施方式中三种解码方式,实际应用中,根据编码方式标志位确定目标解码方式,然后根据上述方法过程对待解码数据进行解码。
在一种可选的实施方式中,如果对神经网络的参数进行编码,生成的码流结构可以参 照图9所示。对于解码方而言,其接收到Frame后,将Frame作为待解码的码流数据,其中包括尺寸标志位(Width和Height)多组待解码数据(Slice_data)。可以分别对每组待解码数据解码,得到其对应的原始数据,然后根据尺寸标志位的数值将每组待解码数据对应的原始数据合并为数据块,以得到神经网络的参数。例如可以参照图5,将每组待解码数据对应的原始数据作为一个数据分块,还原出神经网络参数的原始二维结构。需要说明的是,对于同一码流结构中的不同组待解码数据,其目标解码方式可能不同。参照图9所示,可以根据每组待解码数据中的编码方式标志位(Mode)确定目标解码方式,并对应解码。
参照图11所示的实施方式,提供了一种数据编码方法,该数据编码方法即上述残差编码,包括以下步骤S1110和S1120:
步骤S1110,获取待编码数据块;
步骤S1120,确定对待编码数据块中的残差进行行编码所需的编码总位长和列编码所需的编码总位长,采用其中编码总位长较小的编码方式,对待编码数据块中的残差进行编码。
在一种可选的实施方式中,确定对待编码数据块中的残差进行行编码所需的编码总位长和列编码所需的编码总位长,可以包括:
以参考数据为起始,在待编码数据块的每一行中计算每个数据与其左侧相邻数据之间的残差,以及在待编码数据块的每一列中计算每个数据与其上方相邻数据之间的残差;
分别计算每一行的最大残差和每一列的最大残差,根据每一行的最大残差确定每一行的码流位长,根据每一列的最大残差确定每一列的码流位长;
统计各行的码流总位长,得到行编码的编码开销,统计各列的码流总位长,得到列编码的编码开销。
在一种可选的实施方式中,采用其中编码开销较小的方式对待编码数据块中的残差进行编码,可以包括:
当采用行编码时,根据每一行的最大残差计算每一行中的每个残差所需的码流位长,以对每一行中的每个残差分别进行编码。
在一种可选的实施方式中,当采用行编码时,数据编码方法还包括:
在待编码数据块的码流结构中设置行列方式标志位,用于记录行编码所对应的数值。
在一种可选的实施方式中,当采用行编码时,数据编码方法还包括:
在待编码数据块的每一行的码流结构中设置数值长度标志位,用于记录该行的每个残差所需的码流位长。
在一种可选的实施方式中,采用其中编码开销较小的方式对待编码数据块中的残差进列编码,可以包括:
当采用列编码时,根据每一列的最大残差计算每一列中的每个残差所需的码流位长,以对每一列中的每个残差分别进行编码。
在一种可选的实施方式中,当采用列编码时,数据编码方法还包括:
在待编码数据块的码流结构中设置行列方式标志位,用于记录列编码所对应的数值。
在一种可选的实施方式中,当采用列编码时,数据编码方法还包括:
在待编码数据块的每一列的码流结构中设置数值长度标志位,用于记录该列的每个残差所需的码流位长。
在一种可选的实施方式中,数据编码方法还包括:
在每个残差的码流结构中设置符号标志位,用于记录该残差为正或负。
参照图12所示的实施方式,提供了一种数据解码方法,该数据解码方法即上述残差解码,包括以下步骤S1210至S1230:
步骤S1210,获取由残差编码对原始数据块进行编码所得到的待解码数据;
步骤S1220,当残差编码为行编码时,从待解码数据中读取参考数据和残差,逐行对参考数据和残差执行残差计算的逆运算,得到待解码数据对应的原始数据块;
步骤S1230,当残差编码为列编码时,从待解码数据中读取参考数据和残差,逐列对参考数据和残差执行残差计算的逆运算,得到待解码数据对应的原始数据块。
在一种可选的实施方式中,数据解码方法还包括:
根据待解码数据中行列方式标志位的数值确定残差编码为行编码或者列编码。
在一种可选的实施方式中,在从待解码数据中读取残差时,先读取残差所占的位长,再根据该位长读取残差。
在一种可选的实施方式中,在从待解码数据中读取残差时,根据每个符号标志位的数值确定其对应的残差为正或负。
参照图13所示的实施方式,提供了一种数据编码方法,该数据编码方法即上述数值分段编码,包括以下步骤S1310和S1320:
步骤S1310,获取待编码数据块;
步骤S1320,将待编码数据块中的数据划分为多个数值区间,对不同数值区间的数据采用不同位长进行编码。
在一种可选的实施方式中,将待编码数据块中的数据划分为多个数值区间,包括:
通过预设的分割点将预设数值范围划分为多个数值区间;
将待编码数据块中的数据分别划分至对应的数值区间内。
其中,预设数值范围为待编码数据块中的数据所处的数值范围;分割点均为2的整数次幂。
在一种可选的实施方式中,分割点通过以下方式确定:
统计待编码数据块中的数据分布,根据数据分布确定分割点。
在一种可选的实施方式中,数值区间的数量为2的整数次幂。
在一种可选的实施方式中,待编码数据块进行数值分段编码后的码流结构包括数值位;对不同数值区间的数据采用不同位长进行编码,包括:
根据每个数值区间的上限数值确定每个数值区间对应的数值位的位长;
根据每个数值区间对应的数值位的位长对待编码数据块中的每个数据进行编码。
在一种可选的实施方式中,待编码数据块进行数值分段编码后的码流结构还包括区间标志位,区间标志位用于标志数据所处的数值区间;对不同数值区间的数据采用不同位长进行编码,还包括:
根据数值区间的数量确定区间标志位的位长;
根据每个数据所处的数值区间确定每个数据的区间标志位。
在一种可选的实施方式中,区间标志位的位长
Figure PCTCN2019126393-appb-000013
Q为数值区间的数量;数值区间Si对应的数值位的位长
Figure PCTCN2019126393-appb-000014
max(Si)表示数值区间Si的上限数值。
参照图14所示的实施方式,提供了一种数据解码方法,该数据解码方法即上述数值分段解码,包括以下步骤S1410至S1430:
步骤S1410,获取待解码数据;
步骤S1420,确定待解码数据所对应的原始数据所占的位长,处于不同数值区间的原始数据具有不同的位长;
步骤S1430,按照原始数据所占的位长从待解码数据中解码出原始数据。
在一种可选的实施方式中,数值区间为:通过预设的分割点对预设数值范围进行划分所得到的。其中,预设数值范围为原始数据所处的数值范围,分割点均为2的整数次幂。
在一种可选的实施方式中,数值区间的数量为2的整数次幂。
在一种可选的实施方式中,获取待解码数据所对应的原始数据所占的位长,包括:
根据待解码数据中每个区间标志位的数值确定对应的原始数据所占的位长。
在一种可选的实施方式中,按照原始数据所占的位长从待解码数据中解码出原始数据,包括:
在读取每个区间标志位的数值后,根据其对应的原始数据所占的位长,从待解码数据中顺次读取该位长的数值,以解码出对应的原始数据。
本公开示例性实施方式还提供一种数据处理方法,应用于如图15所示的数据处理系统1500。该数据处理系统1500包括:依次连接的配置器1510、存储器1520和处理器1530。该数据处理方法的流程可以参照图16所示,包括以下步骤S1610至S1630:
步骤S1610,通过配置器执行本公开示例性实施方式中任一种数据编码方法(如图3、图11或图13所示的方法),对由预设数据所构成的待编码数据块进行编码,生成码流数据;
步骤S1620,将码流数据写入存储器,以降低对存储器的写带宽;
步骤S1630,通过处理器读取存储器内的码流数据,并对码流数据进行解码,以降低对存储器的读带宽。
其中,预设数据为处理器和配置器之间需要读写的数据,例如可以是神经网络的参数。在一种可选的实施方式中,可以对神经网络的参数进行分块,以得到上述待编码数据块。
在一种可选的实施方式中,配置器1510可以包括编码器1511,使配置器1510具体通过编码器1511编码待编码数据块。
在一种可选的实施方式中,处理器1530可以包括解码器1531,使处理器1530具体通过解码器1531解码码流数据。
在一种可选的实施方式中,处理器1530还可以包括静态随机存取存储器1532,该静态随机存取存储器1532用于从存储器1520中读取码流数据,以使得处理器1530通过解码器1530对静态随机存储器1532中的码流数据进行解码得到待编码数据块。
配置器1510将码流数据写入存储器1520,相比于直接写入待编码数据块中的原始数据,可以占用更少的写带宽;处理器1530从存储器1520读取码流数据,相比于直接读取待编码数据块中的原始数据,可以占用更少的读带宽。如果待编码数据块为神经网络的参数,处理器1530在解码得到待编码数据块,可以基于待编码数据块运行神经网络。
本公开示例性实施方式还提供一种编码器,该编码器可以参照图15中的编码器1511所示,通过执行本公开示例性实施方式中任一种数据编码方法(如图3、图11或图13所示的方法),对待编码数据块进行编码。
图17示出编码器的一种示例性架构,主要包括编码开销计算模块、编码方式选择模块以及各个候选编码方式的数据编码模块。待编码数据块进入编码器后,首先进行编码开销的计算,根据计算结果选择目标编码方式,再在目标编码方式的数据编码模块中,对待编码数据块进行编码,得到码流数据;如果计算所有候选编码方式的编码率均大于或等于1,则选择Bypass模式,不进行编码,将待编码数据块的原始数据写入码流数据。需要说明的是,本实施方式仅为示例性说明,不应当看作是对本公开的限定。
本公开示例性实施方式还提供一种解码器,该解码器可以参照图15中的解码器1531所示,通过执行本公开示例性实施方式中任一种数据编码方法(如图10、图12或图14所示的方法),对待解码数据进行解码。
图18示出解码器的一种示例性架构,主要包括编码方式解析模块、解码方式选择模块以及各个解码方式的数据解码模块。待解码数据进入解码器后,首先解析采用了哪种编码方式,以确定目标编码方式;然后选择目标编码方式对应的目标解码方式;再在目标解码方式的数据解码模块中,对待解码数据进行编码,得到原始数据;如果确定在编码时采取Bypass模式,则在解码时也对应采取Bypass模式,不进行解码,直接从待解码数据中读取原始数据。需要说明的是,本实施方式仅为示例性说明,不应当看作是对本公开的限定。
本公开示例性实施方式还提供一种数据处理系统。可以参照上述图15所示,该数据处理系统1500可以包括:依次连接的配置器1510、存储器1520和处理器1530。其中:
配置器1510,用于执行本公开示例性实施方式中任一种数据编码方法(如图3、图11或图13所示的方法),对由预设数据所构成的待编码数据块进行编码,生成码流数据,并将码流数据写入存储器1520,以降低对存储器1520的写带宽;
处理器1530用于读取存储器1520内的码流数据,并对码流数据进行解码,以降低对存储器的读带宽。
处理器1530在对码流数据进行解码时,可以采用与配置器1510编码对应的解码方法,例如图4、图10或图14所示的方法等。
本公开示例性实施方式还提供一种可移动平台。参照图19所示,该可移动平台可以包括:
机体1910;
动力系统1920,设于机体1910,动力系统1920用于为可移动平台提供动力;
数据处理系统1930,其结构可以参照图15。
示例性的,上述数据处理系统1930可以应用于动力系统、作业系统等等可移动平台的功能系统中。
本示例性实施方式提供的数据处理系统在使用神经网络进行数据处理时,能够实现对神经网络的参数进行无损的编码与解码,保证参数不会引入额外的误差且不需要重新训练神经网络,并且降低系统带宽开销。能够满足使用条件较低的硬件资源实现神经网络的运行。
本公开示例性实施方式还提供一种计算机可读介质,其上存储有计算机程序,计算机程序被处理器执行时实现本公开示例性实施方式中任一种数据编码方法或数据解码方法,例如可以执行图3、图10、图11、图12、图13或图14中的方法步骤。该计算机可读介质可以是上述实施方式中描述的可移动物体中所包含的;也可以是单独存在,而未装配入该可移动物体中。
需要说明的是,本公开所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本公开实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、终端装置、或者网络设备等)执行根据本公开示例性实施例的方法。
此外,上述附图仅是根据本公开示例性实施例的方法所包括的处理的示意性说明,而不是限制目的。易于理解,上述附图所示的处理并不表明或限制这些处理的时间顺序。另外,也易于理解,这些处理可以是例如在多个模块中同步或异步执行的。
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本公开的示例性实施例,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其他实施例。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限。

Claims (71)

  1. 一种数据编码方法,其特征在于,包括:
    获取多个候选编码方式对于待编码数据块的编码开销,从所述多个候选编码方式中确定编码开销最小的目标编码方式;
    通过所述目标编码方式对所述待编码数据块进行编码;
    其中,所述候选编码方式包括残差编码和哈夫曼编码。
  2. 根据权利要求1所述的方法,其特征在于,当所述目标编码方式为所述残差编码时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:
    获取对所述待编码数据块中的残差进行行编码的编码开销和列编码的编码开销,采用其中编码开销较小的方式对所述待编码数据块中的残差进行编码。
  3. 根据权利要求2所述的方法,其特征在于,所述获取对所述待编码数据块中的残差进行行编码的编码开销和列编码的编码开销,包括:
    以参考数据为起始,在所述待编码数据块的每一行中计算每个数据与其左侧相邻数据之间的残差,以及在所述待编码数据块的每一列中计算每个数据与其上方相邻数据之间的残差;
    分别计算所述每一行的最大残差和所述每一列的最大残差,根据所述每一行的最大残差确定所述每一行的码流位长,根据所述每一列的最大残差确定所述每一列的码流位长;
    统计各行的码流总位长,得到行编码的编码开销,统计各列的码流总位长,得到列编码的编码开销。
  4. 根据权利要求3所述的方法,其特征在于,所述采用其中编码开销较小的方式对所述待编码数据块中的残差进行编码,包括:
    当采用所述行编码时,根据所述每一行的最大残差计算所述每一行中的每个残差所需的码流位长,以对所述每一行中的每个残差分别进行编码。
  5. 根据权利要求4所述的方法,其特征在于,当采用所述行编码时,所述方法还包括:
    在所述待编码数据块的码流结构中设置行列方式标志位,用于记录所述行编码所对应的数值。
  6. 根据权利要求4所述的方法,其特征在于,当采用所述行编码时,所述方法还包括:
    在所述待编码数据块的每一行的码流结构中设置数值长度标志位,用于记录该行的每个残差所需的码流位长。
  7. 根据权利要求3所述的方法,其特征在于,所述采用其中编码开销较小的方式对所述待编码数据块中的残差进列编码,包括:
    当采用所述列编码时,根据所述每一列的最大残差计算所述每一列中的每个残差所需的码流位长,以对所述每一列中的每个残差分别进行编码。
  8. 根据权利要求7所述的方法,其特征在于,当采用所述列编码时,所述方法还包括:
    在所述待编码数据块的码流结构中设置行列方式标志位,用于记录所述列编码所对应的数值。
  9. 根据权利要求7所述的方法,其特征在于,当采用所述列编码时,所述方法还包括:
    在所述待编码数据块的每一列的码流结构中设置数值长度标志位,用于记录该列的每个残差所需的码流位长。
  10. 根据权利要求4至9任一项所述的方法,其特征在于,所述方法还包括:
    在每个残差的码流结构中设置符号标志位,用于记录该残差为正或负。
  11. 根据权利要求1所述的方法,其特征在于,当所述目标编码方式为所述哈夫曼编码时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:
    统计所述待编码数据块中的数据出现频次,根据所述数据出现频次生成哈夫曼树;
    根据所述哈夫曼树中各个叶子节点的路径生成所述哈夫曼树对应的哈夫曼表;
    采用所述哈夫曼表对所述待编码数据块中的数据进行编码。
  12. 根据权利要求1所述的方法,其特征在于,所述候选编码方式还包括:数值分段编码;
    当所述目标编码方式为所述数值分段编码时,所述通过所述目标编码方式对所述待编码数据块进行编码,包括:
    将所述待编码数据块中的数据划分为多个数值区间,对不同数值区间的数据采用不同位长进行编码。
  13. 根据权利要求12所述的方法,其特征在于,所述将所述待编码数据块中的数据划分为多个数值区间,包括:
    通过预设的分割点将预设数值范围划分为多个数值区间,所述分割点均为2的整数次幂;所述预设数值范围为所述待编码数据块中的数据所处的数值范围;
    将所述待编码数据块中的数据分别划分至对应的所述数值区间内。
  14. 根据权利要求13所述的方法,其特征在于,所述分割点通过以下方式确定:
    统计所述待编码数据块中的数据分布,根据所述数据分布确定所述分割点。
  15. 根据权利要求13所述的方法,其特征在于,所述数值区间的数量为2的整数次幂。
  16. 根据权利要求13至15任一项所述的方法,其特征在于,所述待编码数据块进行数值分段编码后的码流结构包括数值位;所述对不同数值区间的数据采用不同位长进行编码,包括:
    根据每个数值区间的上限数值确定每个数值区间对应的所述数值位的位长;
    根据所述每个数值区间对应的所述数值位的位长对所述待编码数据块中的每个数据进行编码。
  17. 根据权利要求16所述的方法,其特征在于,所述待编码数据块进行数值分段编码后的码流结构还包括区间标志位,所述区间标志位用于标志所述数据所处的数值区间;所述对不同数值区间的数据采用不同位长进行编码,还包括:
    根据所述数值区间的数量确定所述区间标志位的位长;
    根据所述每个数据所处的数值区间确定所述每个数据的区间标志位。
  18. 根据权利要求17所述的方法,其特征在于,所述区间标志位的位长
    Figure PCTCN2019126393-appb-100001
    Q为所述数值区间的数量;数值区间Si对应的数值位的位长
    Figure PCTCN2019126393-appb-100002
    表示数值区间Si的上限数值。
  19. 根据权利要求1所述的方法,其特征在于,在通过所述目标编码方式对所述待编码数据块进行编码时,所述方法还包括:
    在所述待编码数据块进行编码后的码流结构中设置编码方式标志位,所述编码方式标志位用于记录所述目标编码方式所对应的数值。
  20. 根据权利要求1所述的方法,其特征在于,所述待编码数据块通过以下方式获取:
    获取待压缩的神经网络,将所述神经网络的参数排列为数据块;
    按照预设尺寸将所述数据块分块,将每个分块分别作为所述待编码数据块。
  21. 根据权利要求20所述的方法,其特征在于,在按照预设尺寸将所述数据块分块时,如果所述数据块的尺寸不满足为所述预设尺寸的整数倍,则对所述数据块进行数据填充,使填充后的所述数据块的尺寸满足为所述预设尺寸的整数倍。
  22. 根据权利要求20所述的方法,其特征在于,所述对所述数据块进行数据填充,包括:
    在所述数据块的下方增加新的行,在所述新的行中填充其上方相邻的数据;及/或
    在所述数据块的右侧增加新的列,在所述新的列中填充其左侧相邻的数据。
  23. 根据权利要求1所述的方法,其特征在于,在对所述待编码数据块进行编码时,所述方法还包括:
    在所述待编码数据块进行编码后的码流结构中设置尺寸标志位,用于记录所述待编码数据块的原始尺寸。
  24. 根据权利要求1所述的方法,其特征在于,所述获取多个候选编码方式对于待编码数据块的编码开销,包括:
    计算采用行编码或列编码对所述待编码数据块中的残差进行编码所需的码流总 位长,获取其中较小的码流总位长,作为所述残差编码对于所述待编码数据块的编码开销。
  25. 根据权利要求1所述的方法,其特征在于,所述获取多个候选编码方式对于待编码数据块的编码开销,包括:
    计算采用哈夫曼编码对所述待编码数据块进行编码时,哈夫曼表所需的码流位长以及所述待编码数据块中的每个数据所需的码流位长,统计码流总位长,作为所述哈夫曼编码对于所述待编码数据块的编码开销。
  26. 根据权利要求12所述的方法,其特征在于,所述获取多个候选编码方式对于待编码数据块的编码开销,包括:
    根据所述待编码数据块中的每个数据所处的数值区间,计算所述每个数据所需的码流位长,统计码流总位长,作为所述数值分段编码对于所述待编码数据块的编码开销。
  27. 一种数据解码方法,其特征在于,包括:
    对待解码数据进行解析,确定多个候选编码方式中与所述待解码数据对应的目标编码方式,根据所述目标编码方式确定对应的目标解码方式;
    通过所述目标解码方式对所述待解码数据进行解码,得到所述待解码数据对应的原始数据;
    其中,所述候选编码方式包括残差编码和哈夫曼编码。
  28. 根据权利要求27所述的方法,其特征在于,所述待解码数据对应的原始数据为原始数据块,所述原始数据块具有预设尺寸;
    在对所述待解码数据进行解码时,将解码得到的原始数据按照所述预设尺寸排列为所述原始数据块。
  29. 根据权利要求28所述的方法,其特征在于,当所述目标编码方式为所述残差编码时,其对应的目标解码方式为残差解码;所述通过所述目标解码方式对所述待解码数据进行解码,得到所述待解码数据对应的原始数据,包括:
    当所述残差编码为行编码时,从所述待解码数据中读取参考数据和残差,逐行对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块;
    当所述残差编码为列编码时,从所述待解码数据中读取参考数据和残差,逐列对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块。
  30. 根据权利要求29所述的方法,其特征在于,所述通过所述目标解码方式对所述待解码数据进行解码,还包括:
    根据所述待解码数据中行列方式标志位的数值确定所述残差编码为行编码或者 列编码。
  31. 根据权利要求29所述的方法,其特征在于,在从所述待解码数据中读取残差时,先读取残差所占的位长,再根据该位长读取残差。
  32. 根据权利要求29至31任一项所述的方法,其特征在于,在从所述待解码数据中读取残差时,根据每个符号标志位的数值确定其对应的残差为正或负。
  33. 根据权利要求27所述的方法,其特征在于,当所述目标编码方式为所述哈夫曼编码时,其对应的目标解码方式为哈夫曼解码;所述通过所述目标解码方式对所述待解码数据进行解码,得到所述待解码数据对应的原始数据,包括:
    从所述待解码数据中读取哈夫曼表,根据所述哈夫曼表从所述待解码数据中解码出所述原始数据。
  34. 根据权利要求27所述的方法,其特征在于,所述候选编码方式包括:数值分段编码;
    当所述目标编码方式为所述数值分段编码时,其对应的目标解码方式为数值分段解码;所述通过所述目标解码方式对所述待解码数据进行解码,得到所述待解码数据对应的原始数据,包括:
    获取所述待解码数据所对应的原始数据所占的位长,处于不同数值区间的原始数据具有不同的位长;
    按照所述原始数据所占的位长从所述待解码数据中解码出所述原始数据。
  35. 根据权利要求34所述的方法,其特征在于,所述数值区间为:通过预设的分割点对预设数值范围进行划分所得到的,所述分割点均为2的整数次幂;所述预设数值范围为所述原始数据所处的数值范围。
  36. 根据权利要求34所述的方法,其特征在于,所述数值区间的数量为2的整数次幂。
  37. 根据权利要求34至36任一项所述的方法,其特征在于,所述获取所述待解码数据所对应的原始数据所占的位长,包括:
    根据所述待解码数据中每个区间标志位的数值确定对应的原始数据所占的位长。
  38. 根据权利要求37所述的方法,其特征在于,所述按照所述原始数据所占的位长从所述待解码数据中解码出所述原始数据,包括:
    在读取每个区间标志位的数值后,根据其对应的原始数据所占的位长,从所述待解码数据中顺次读取该位长的数值,以解码出对应的原始数据。
  39. 根据权利要求27所述的方法,其特征在于,所述待解码数据包括编码方式标志位,所述编码方式标志位具有固定位长;所述对待解码数据进行解析,确定多个候选编码方式中与所述待解码数据对应的目标编码方式,包括:
    根据所述编码方式标志位的数值和所述候选编码方式的映射关系,确定出与所述待解码数据对应的目标编码方式。
  40. 根据权利要求27所述的方法,其特征在于,所述待解码数据通过以下方式获取:
    获取待解码的码流数据,所述码流数据中包括尺寸标志位和多组待解码数据;
    在分别获得每组所述待解码数据对应的原始数据后,所述方法还包括:
    根据所述尺寸标志位的数值将每组所述待解码数据对应的原始数据合并为数据块,以得到神经网络的参数。
  41. 一种数据编码方法,其特征在于,包括:
    获取待编码数据块;
    确定对所述待编码数据块中的残差进行行编码所需的编码总位长和列编码所需的编码总位长,采用其中编码总位长较小的编码方式,对所述待编码数据块中的残差进行编码。
  42. 根据权利要求41所述的方法,其特征在于,所述确定对所述待编码数据块中的残差进行行编码所需的编码总位长和列编码所需的编码总位长,包括:
    以参考数据为起始,在所述待编码数据块的每一行中计算每个数据与其左侧相邻数据之间的残差,以及在所述待编码数据块的每一列中计算每个数据与其上方相邻数据之间的残差;
    分别计算所述每一行的最大残差和所述每一列的最大残差,根据所述每一行的最大残差确定所述每一行的码流位长,根据所述每一列的最大残差确定所述每一列的码流位长;
    统计各行的码流总位长,得到行编码的编码开销,统计各列的码流总位长,得到列编码的编码开销。
  43. 根据权利要求42所述的方法,其特征在于,所述采用其中编码开销较小的方式对所述待编码数据块中的残差进行编码,包括:
    当采用所述行编码时,根据所述每一行的最大残差计算所述每一行中的每个残差所需的码流位长,以对所述每一行中的每个残差分别进行编码。
  44. 根据权利要求43所述的方法,其特征在于,当采用所述行编码时,所述方法还包括:
    在所述待编码数据块的码流结构中设置行列方式标志位,用于记录所述行编码所对应的数值。
  45. 根据权利要求43所述的方法,其特征在于,当采用所述行编码时,所述方法还包括:
    在所述待编码数据块的每一行的码流结构中设置数值长度标志位,用于记录该行的每个残差所需的码流位长。
  46. 根据权利要求42所述的方法,其特征在于,所述采用其中编码开销较小的 方式对所述待编码数据块中的残差进列编码,包括:
    当采用所述列编码时,根据所述每一列的最大残差计算所述每一列中的每个残差所需的码流位长,以对所述每一列中的每个残差分别进行编码。
  47. 根据权利要求46所述的方法,其特征在于,当采用所述列编码时,所述方法还包括:
    在所述待编码数据块的码流结构中设置行列方式标志位,用于记录所述列编码所对应的数值。
  48. 根据权利要求46所述的方法,其特征在于,当采用所述列编码时,所述方法还包括:
    在所述待编码数据块的每一列的码流结构中设置数值长度标志位,用于记录该列的每个残差所需的码流位长。
  49. 根据权利要求43至48任一项所述的方法,其特征在于,所述方法还包括:
    在每个残差的码流结构中设置符号标志位,用于记录该残差为正或负。
  50. 一种数据解码方法,其特征在于,包括:
    获取由残差编码对原始数据块进行编码所得到的待解码数据;
    当所述残差编码为行编码时,从所述待解码数据中读取参考数据和残差,逐行对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块;
    当所述残差编码为列编码时,从所述待解码数据中读取参考数据和残差,逐列对所述参考数据和所述残差执行残差计算的逆运算,得到所述待解码数据对应的原始数据块。
  51. 根据权利要求50所述的方法,其特征在于,所述方法还包括:
    根据所述待解码数据中行列方式标志位的数值确定所述残差编码为行编码或者列编码。
  52. 根据权利要求50所述的方法,其特征在于,在从所述待解码数据中读取残差时,先读取残差所占的位长,再根据该位长读取残差。
  53. 根据权利要求50至52任一项所述的方法,其特征在于,在从所述待解码数据中读取残差时,根据每个符号标志位的数值确定其对应的残差为正或负。
  54. 一种数据编码方法,其特征在于,包括:
    获取待编码数据块;
    将所述待编码数据块中的数据划分为多个数值区间,对不同数值区间的数据采用不同位长进行编码。
  55. 根据权利要求54所述的方法,其特征在于,所述将所述待编码数据块中的 数据划分为多个数值区间,包括:
    通过预设的分割点将预设数值范围划分为多个数值区间,所述分割点均为2的整数次幂;所述预设数值范围为所述待编码数据块中的数据所处的数值范围;
    将所述待编码数据块中的数据分别划分至对应的所述数值区间内。
  56. 根据权利要求55所述的方法,其特征在于,所述分割点通过以下方式确定:
    统计所述待编码数据块中的数据分布,根据所述数据分布确定所述分割点。
  57. 根据权利要求55所述的方法,其特征在于,所述数值区间的数量为2的整数次幂。
  58. 根据权利要求55至57任一项所述的方法,其特征在于,所述待编码数据块进行数值分段编码后的码流结构包括数值位;所述对不同数值区间的数据采用不同位长进行编码,包括:
    根据每个数值区间的上限数值确定每个数值区间对应的所述数值位的位长;
    根据所述每个数值区间对应的所述数值位的位长对所述待编码数据块中的每个数据进行编码。
  59. 根据权利要求58所述的方法,其特征在于,所述待编码数据块进行数值分段编码后的码流结构还包括区间标志位,所述区间标志位用于标志所述数据所处的数值区间;所述对不同数值区间的数据采用不同位长进行编码,还包括:
    根据所述数值区间的数量确定所述区间标志位的位长;
    根据所述每个数据所处的数值区间确定所述每个数据的区间标志位。
  60. 根据权利要求59所述的方法,其特征在于,所述区间标志位的位长
    Figure PCTCN2019126393-appb-100003
    Q为所述数值区间的数量;数值区间Si对应的数值位的位长
    Figure PCTCN2019126393-appb-100004
    表示数值区间Si的上限数值。
  61. 一种数据解码方法,其特征在于,包括:
    获取待解码数据;
    确定所述待解码数据所对应的原始数据所占的位长,处于不同数值区间的原始数据具有不同的位长;
    按照所述原始数据所占的位长从所述待解码数据中解码出所述原始数据。
  62. 根据权利要求61所述的方法,其特征在于,所述数值区间为:通过预设的分割点对预设数值范围进行划分所得到的,所述分割点均为2的整数次幂;所述预设数值范围为所述原始数据所处的数值范围。
  63. 根据权利要求61所述的方法,其特征在于,所述数值区间的数量为2的整数次幂。
  64. 根据权利要求61至63任一项所述的方法,其特征在于,所述获取所述待解 码数据所对应的原始数据所占的位长,包括:
    根据所述待解码数据中每个区间标志位的数值确定对应的原始数据所占的位长。
  65. 根据权利要求64所述的方法,其特征在于,所述按照所述原始数据所占的位长从所述待解码数据中解码出所述原始数据,包括:
    在读取每个区间标志位的数值后,根据其对应的原始数据所占的位长,从所述待解码数据中顺次读取该位长的数值,以解码出对应的原始数据。
  66. 一种数据处理方法,其特征在于,应用于依次连接的配置器、存储器和处理器,所述方法包括:
    通过所述配置器执行权利要求1至26、41至49、54至60任一项所述的数据编码方法,对由预设数据所构成的待编码数据块进行编码,生成码流数据;
    将所述码流数据写入所述存储器,以降低对所述存储器的写带宽;
    通过所述处理器读取所述存储器内的码流数据,并对所述码流数据进行解码,以降低对所述存储器的读带宽。
  67. 一种编码器,其特征在于,所述编码器通过执行权利要求1至26、41至49、54至60任一项所述的数据编码方法,对待编码数据块进行编码。
  68. 一种解码器,其特征在于,所述解码器通过执行权利要求27至40、50至53、61至65任一项所述的数据解码方法,对待解码数据进行解码。
  69. 一种数据处理系统,其特征在于,包括:依次连接的配置器、存储器和处理器;
    所述配置器用于执行权利要求1至26、41至49、54至60任一项所述的数据编码方法,对由预设数据所构成的待编码数据块进行编码,生成码流数据,并将所述码流数据写入所述存储器,以降低对所述存储器的写带宽;
    所述处理器用于读取所述存储器内的码流数据,并对所述码流数据进行解码,以降低对所述存储器的读带宽。
  70. 一种可移动平台,其特征在于,包括:
    机体;
    动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,
    如权利要求69所述的数据处理系统。
  71. 一种计算机可读介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至65任一项所述的方法。
PCT/CN2019/126393 2019-12-18 2019-12-18 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质 WO2021120067A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/126393 WO2021120067A1 (zh) 2019-12-18 2019-12-18 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2019/126393 WO2021120067A1 (zh) 2019-12-18 2019-12-18 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质

Publications (1)

Publication Number Publication Date
WO2021120067A1 true WO2021120067A1 (zh) 2021-06-24

Family

ID=76477034

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/126393 WO2021120067A1 (zh) 2019-12-18 2019-12-18 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质

Country Status (1)

Country Link
WO (1) WO2021120067A1 (zh)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1605213A (zh) * 2001-12-17 2005-04-06 微软公司 跳过宏块编码
CN101390158A (zh) * 2006-02-24 2009-03-18 法国电信公司 信号包络的量化索引的二进制编码方法、解码信号包络的方法、及相应的编码和解码模块
CN102215384A (zh) * 2010-04-02 2011-10-12 富士通株式会社 图像压缩方法和系统
CN104392725A (zh) * 2014-12-02 2015-03-04 中科开元信息技术(北京)有限公司 多声道无损音频混合编解码方法及装置
US20180115787A1 (en) * 2015-04-12 2018-04-26 Lg Electronics Inc. Method for encoding and decoding video signal, and apparatus therefor
CN109474281A (zh) * 2018-09-30 2019-03-15 湖南瑞利德信息科技有限公司 数据编码、解码方法及装置
CN110263917A (zh) * 2019-06-06 2019-09-20 深圳前海微众银行股份有限公司 一种神经网络压缩方法及装置
CN110290382A (zh) * 2019-05-10 2019-09-27 同济大学 一种残差数据编码和解码方法

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1605213A (zh) * 2001-12-17 2005-04-06 微软公司 跳过宏块编码
CN101390158A (zh) * 2006-02-24 2009-03-18 法国电信公司 信号包络的量化索引的二进制编码方法、解码信号包络的方法、及相应的编码和解码模块
CN102215384A (zh) * 2010-04-02 2011-10-12 富士通株式会社 图像压缩方法和系统
CN104392725A (zh) * 2014-12-02 2015-03-04 中科开元信息技术(北京)有限公司 多声道无损音频混合编解码方法及装置
US20180115787A1 (en) * 2015-04-12 2018-04-26 Lg Electronics Inc. Method for encoding and decoding video signal, and apparatus therefor
CN109474281A (zh) * 2018-09-30 2019-03-15 湖南瑞利德信息科技有限公司 数据编码、解码方法及装置
CN110290382A (zh) * 2019-05-10 2019-09-27 同济大学 一种残差数据编码和解码方法
CN110263917A (zh) * 2019-06-06 2019-09-20 深圳前海微众银行股份有限公司 一种神经网络压缩方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
LIU, JING; XIANG, MIN; GU, FANGYONG: "An Encryption Method Based on Data Segmentation", COMMAND INFORMATION SYSTEM AND TECHNOLOGY, vol. 1, no. 4, 31 August 2010 (2010-08-31), pages 64 - 67, XP009528496, DOI: 10.15908/j.cnki.cist.2010.04.018 *

Similar Documents

Publication Publication Date Title
US20220012593A1 (en) Neural network accelerator and neural network acceleration method based on structured pruning and low-bit quantization
US10496336B2 (en) K-D tree encoding for point clouds using deviations
CN107565971B (zh) 一种数据压缩方法及装置
CN107294539B (zh) 一种准动态霍夫曼硬件编码器及编码方法
US10430975B2 (en) Advanced k-D tree encoding for point clouds by most significant axis selection
CN110473251B (zh) 基于网格空间索引的自定义范围空间数据面积统计方法
JP7027520B2 (ja) Polar符号化方法および装置
US11395010B2 (en) Massive picture processing method converting decimal element in matrices into binary element
CN112991472A (zh) 一种基于残差稠密阈值网络的图像压缩感知重建方法
WO2020207410A1 (zh) 一种数据压缩方法、电子设备及存储介质
CN114691108A (zh) 一种神经网络加速器自动化代码生成方法
CN104125475A (zh) 一种多维量子数据压缩、解压缩方法及装置
CN106227881A (zh) 一种信息处理方法及服务器
CN101467459B (zh) 信号的矢量量化字典生成方法、编解码器及编解码方法
CN112488287A (zh) 卷积神经网络压缩方法、系统、设备及介质
WO2021120067A1 (zh) 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质
CN111190896B (zh) 数据处理方法、装置、存储介质和计算机设备
CN112884120A (zh) 图神经网络表示架构
CN115438114B (zh) 存储格式转换方法、系统、装置、电子设备及存储介质
CN106372213A (zh) 一种位置分析方法
CN111275166A (zh) 基于卷积神经网络的图像处理装置、设备及可读存储介质
CN111797991A (zh) 一种深度网络模型压缩系统、方法及装置
CN112200275B (zh) 人工神经网络的量化方法及装置
CN113609126B (zh) 一种众源时空数据的一体化存储管理方法及系统
CN112712855B (zh) 一种基于联合训练的含缺失值基因微阵列的聚类方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19956989

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19956989

Country of ref document: EP

Kind code of ref document: A1