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

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

Info

Publication number
WO2021237870A1
WO2021237870A1 PCT/CN2020/099495 CN2020099495W WO2021237870A1 WO 2021237870 A1 WO2021237870 A1 WO 2021237870A1 CN 2020099495 W CN2020099495 W CN 2020099495W WO 2021237870 A1 WO2021237870 A1 WO 2021237870A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
decoded
residual
block
value
Prior art date
Application number
PCT/CN2020/099495
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
Priority claimed from PCT/CN2020/092627 external-priority patent/WO2021237513A1/zh
Priority claimed from PCT/CN2020/092640 external-priority patent/WO2021237518A1/zh
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Publication of WO2021237870A1 publication Critical patent/WO2021237870A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/184Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being bits, e.g. of the compressed video stream

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
  • Feature Map feature maps
  • 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 improving at least to a certain extent the occupation of data read and write in the prior art The problem of high bandwidth.
  • a data encoding method including: dividing data to be encoded into a plurality of data blocks, each of the data blocks including at least two data; according to the data in each of the data blocks For the consistency feature, each of the data blocks is respectively coded through a corresponding coding method.
  • a data encoding method including: dividing data to be encoded into a plurality of data blocks, each of the data blocks including at least three data; in each of the data blocks, calculating The residuals of the first data are calculated, and the residuals between each data except the first data and the first data are respectively calculated; and the residuals are encoded.
  • a data decoding method including: analyzing the data to be decoded, and determining the data consistency characteristics of the original data block corresponding to each data segment to be decoded in the data to be decoded; wherein, The data to be decoded includes a plurality of data segments to be decoded, and each data segment to be decoded corresponds to an original data block formed by at least two original data; according to the data consistency of each original data block Characteristically, each of the data segments to be decoded is decoded by corresponding decoding methods to obtain each of the original data blocks; each of the original data blocks is combined to obtain all the original data corresponding to the data to be decoded.
  • a data decoding method including: decoding data in each data segment to be decoded in the data to be decoded to obtain the residual of each data segment to be decoded; wherein, the The data to be decoded includes a plurality of data segments to be decoded, and each data segment to be decoded corresponds to an original data block formed by at least three original data; according to the first data segment of each data segment to be decoded Residuals, determine the first data in the original data block corresponding to each data segment to be decoded; compare each residual in each data segment to be decoded with the exception of the first residual.
  • the first data in the original data blocks corresponding to the data segment to be decoded is summed to obtain the original data block corresponding to each data segment to be decoded; the original data blocks are combined to obtain the data corresponding to the data to be decoded Raw data.
  • a data processing method which is applied to a configurator, a memory, and a processor connected in sequence, and the method includes: executing the data encoding method of the first or second aspect through the configurator Or its possible implementation manner, encode preset data to be encoded to generate code stream data; write the generated code stream data into the memory to reduce the write bandwidth to the memory; through the configurator At least part of the code stream data in the memory is read, and the read code stream data is decoded to reduce the read bandwidth of the memory; the processor runs the decoded data.
  • an encoder which encodes data to be encoded by executing the data encoding method of the first or second aspect or a possible implementation manner thereof.
  • a decoder which decodes data to be decoded by executing the data decoding method of the third or fourth aspect or possible implementations thereof.
  • 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 of the first or second aspect or its possible implementation
  • the preset data to be encoded is encoded, code stream data is generated, and the generated code stream data is written into the memory to reduce the write bandwidth to the memory
  • the configurator is also used for reading At least part of the code stream data in the memory is decoded, and the read code stream data is decoded, so that the processor runs the decoded data, so as 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, as in the eighth aspect described above Data processing system.
  • a computer-readable medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned first, second, third, fourth or fifth aspect is realized Data encoding method, data decoding method, data processing method or possible implementations thereof.
  • the corresponding encoding method is adopted for encoding.
  • the data consistency of the data block is relatively high, such as all the data in the data block When the same or all of them are 0, the bit length of the bit stream required for encoding is lower, thereby reducing the bit width occupied by the bit stream data reading and writing, speeding up the calculation and processing speed of the hardware device, saving storage resources, and broadening the data application scenarios.
  • the adopted encoding method is adapted to the data consistency characteristics of each data block, thereby improving the flexibility of data encoding, so that each data block achieves a better balance between encoding performance and resource overhead. And integrate the advantages of multiple encoding methods to improve the inherent shortcomings of a single encoding method in related technologies.
  • the data encoding method adopted in this solution is lossless encoding, which can ensure data accuracy and meet the needs of various scenarios.
  • This solution is suitable for data processing of CNN feature images.
  • By performing low-overhead lossless coding on feature images it can reduce the system resources occupied by feature image data in reading and writing between the computing core and the memory, on-chip memory and off-chip memory. Thereby improving the efficiency of CNN operation, which is conducive to deployment in lightweight scenarios such as mobile terminals.
  • Figure 1 shows a schematic diagram of the structure of LeNet
  • Figure 2 shows a schematic diagram of feature images in the Resnet 18 network
  • Figure 3 shows a schematic diagram of the CNN hardware computing platform framework
  • FIG. 4 shows a flowchart of a data encoding method in this exemplary embodiment
  • Figure 5 shows a schematic diagram of a feature image of CNN
  • Fig. 6 shows a schematic diagram of adding a new column to an image to be coded in this exemplary embodiment
  • Fig. 7 shows a flowchart of a data block encoding in this exemplary embodiment
  • Fig. 8 shows a flow chart of residual coding in this exemplary embodiment
  • FIG. 9 shows a schematic diagram of calculating residuals in this exemplary embodiment
  • FIG. 10 shows another schematic diagram of calculating residuals in this exemplary embodiment
  • FIG. 11 shows another schematic diagram of calculating residuals in this exemplary embodiment
  • Fig. 12 shows a flowchart of another residual coding in this exemplary embodiment
  • FIG. 13 shows a flowchart of still another residual coding in this exemplary embodiment
  • FIG. 14 shows a schematic diagram of data encoding in different situations in this exemplary embodiment
  • FIG. 15 shows a flowchart of another data block encoding in this exemplary embodiment
  • FIG. 16 shows a flowchart of yet another data block encoding in this exemplary embodiment
  • FIG. 17 shows a flowchart of a data decoding method in this exemplary embodiment
  • FIG. 18 shows a flowchart of determining data consistency characteristics in this exemplary embodiment
  • Fig. 19 shows a flow chart of residual decoding in this exemplary embodiment
  • FIG. 20 shows a flowchart of determining a residual decoding manner in this exemplary embodiment
  • FIG. 21 shows a sub-flow chart of the data decoding method in this exemplary embodiment
  • FIG. 22 shows a flowchart of another data encoding method in this exemplary embodiment
  • FIG. 23 shows a flowchart of another data decoding method in this exemplary embodiment
  • FIG. 24 shows a schematic structural diagram of a data processing system in this exemplary embodiment
  • FIG. 25 shows a flowchart of a data processing method in this exemplary embodiment
  • FIG. 26 shows an architecture diagram of an encoder in this exemplary embodiment
  • FIG. 27 shows an architecture diagram of a decoder in this exemplary embodiment
  • Fig. 28 shows a schematic structural diagram of a movable platform in this exemplary embodiment.
  • Example embodiments will now be described more fully with reference to the accompanying drawings.
  • the example embodiments can be implemented in various forms, and should not be construed as being limited to the examples set forth herein; on the contrary, the provision of these embodiments makes the present disclosure more comprehensive and complete, and fully conveys the concept of the example embodiments To those skilled in the art.
  • the described features, structures or characteristics can be combined in one or more embodiments in any suitable way.
  • CNN is a feedforward neural network, 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, Convolution, and 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).
  • 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 perform more in-depth calculations on each small block in the neural network.
  • 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 (if normalized 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, using six 5x5x1 convolution kernels, through convolution, the 6@28x28 feature image of the C1 layer can be obtained, and the number 6 represents the channel of the feature image of the C1 layer
  • Feature images are abstract representations of input images to varying degrees.
  • Figure 2 shows the Resnet 18 network (a classic residual network). The feature images of different layers in the model), it can be seen that as the number of layers deepens, the more abstract the features extracted by CNN, the local individual features or global features are extracted, and the corresponding feature images become more and more abstract visually.
  • LeNet and Resnet 18 are relatively simple CNN structures. According to the current development trend of CNN, the number of network layers is gradually deepening and the number of channels is gradually increasing, resulting in a sharp increase in the scale of feature image data of the entire network, which is occupied in chip applications. The system bandwidth is very high, which brings huge challenges to the power consumption and operating speed of the equipment.
  • Figure 3 shows the framework of the CNN hardware computing platform. The feature images generated during the CNN computing core running CNN are first written into the on-chip memory, such as SRAM (Static Random Access Memory).
  • SRAM Static Random Access Memory
  • DMA Direct Memory Access
  • DDR Double Data Rate Synchronous Dynamic Access Memory, double data rate synchronous dynamic random access memory
  • the CNN computing core needs to load the feature image data from DDR to 153.26MB, and the DDR read bandwidth occupied by it is calculated at a frame rate of 30 to be 35.92Gbps. If it happens When reading repeatedly, the bandwidth will be higher, which shows that it is necessary to reduce the bandwidth occupied by the characteristic image data.
  • lossy compression In related technologies, compression methods for image data are divided into two types: lossy compression and lossless compression. There is a certain deviation between the characteristic image data recovered by lossy compression and the original data, which leads to changes in the existing network parameters and the adaptability of the characteristic image, which may have a greater impact on network performance, such as affecting the convergence speed and accuracy of the network. Therefore, it is seldom used in the processing of CNN feature images.
  • Lossless compression includes commonly used Huffman (Huffman) and LZ77 algorithms. Its main disadvantages are high complexity and complex hardware implementation, which leads to a decrease in the throughput rate of the codec system, which limits the performance of the CNN computing core and is difficult to meet the actual requirements. Application requirements.
  • 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. It should be noted that the exemplary embodiments of the present disclosure can be applied to processing CNN feature image data, and can also be applied to processing other types of data. Various aspects of the exemplary embodiments of the present disclosure will be described in detail below.
  • Fig. 4 shows a flowchart of a data encoding method in this exemplary embodiment.
  • the method includes the following steps S410 and S420:
  • Step S410 Divide the to-be-encoded data into multiple data blocks, and each data block includes at least two pieces of data.
  • the data to be encoded represents a group of data, which is the basic coding unit of data, which can be one-dimensional data (such as a one-dimensional array), two-dimensional data (such as a two-dimensional data table, a single-channel image), or three-dimensional data. (Such as multi-channel images) and so on.
  • the data volume of the data to be encoded can be determined according to the hardware performance, and the appropriate value is determined by comprehensively considering the performance of encoding and transmission. Generally, it includes at least 4 data. When the total amount of data to be encoded is large, it can be divided into multiple groups of to-be-encoded data, and each group of to-be-encoded data is used as a unit for encoding.
  • the image to be coded may be divided into multiple sub-images, and the data in each sub-image is used as one piece of data to be coded. for example:
  • the size of the sub-image can be N*1, and N can be the width of the image to be coded, which is a positive integer greater than or equal to 4, that is, each row of the image to be coded is used as a piece of data to be coded. N may also be other values, for example, a value set to facilitate subsequent division of data blocks, or 1/2, 1/4, etc. of the width of the image to be encoded. Further, when the image to be encoded is divided into N*1 sub-images, if the width of the image to be encoded does not satisfy an integer multiple of N, the image to be encoded can be filled with data to make the width of the image to be encoded after filling Satisfaction is an integer multiple of N.
  • Figure 5 shows a schematic diagram of a multi-channel feature image in CNN.
  • W (Width) and H (Height) represent the width and height of the feature image, respectively
  • C (Channel) represents the number of channels, that is, W*H *C pieces of data are encoded.
  • a new data column can be added to the right side of the image to be coded. For example, the 11th and 12th columns are added to the right to form a 12*7 image to be coded.
  • each row can be divided into 3 data to be encoded.
  • the sub-image can also be a row block formed by several rows in the image to be coded, or a column block formed by several columns.
  • the size of the sub-image is W*Q, that is, a line block formed by Q lines, or Q*H, that is A block of columns formed by Q columns.
  • the image to be encoded can be Perform data padding, so that the total number of rows of the image to be encoded after padding is an integer multiple of Q.
  • a new data row can be added below the image to be encoded, and the adjacent data above it or other preset data, such as null value, 0, etc., can be filled.
  • the data to be coded needs to be divided into data blocks.
  • the data block is the smallest coding unit, and each data block is coded in the same way.
  • Data blocks can be divided according to the characteristics of the data to be encoded, such as one-dimensional data to be encoded is divided into multiple one-dimensional data blocks, two-dimensional data to be encoded is divided into multiple one-dimensional data blocks or two-dimensional data blocks, three-dimensional
  • the data to be encoded is divided into multiple one-dimensional data blocks, two-dimensional data blocks or three-dimensional data blocks.
  • the present disclosure does not limit the specific method of dividing data blocks and the number of data blocks.
  • the data to be encoded may be evenly divided into multiple data blocks, so that each data block has the same amount of data, for example, N*1 data to be encoded is evenly divided into 3 data blocks, Each data block is (N/3)*1, which facilitates the determination of the data amount of each data block during decoding, and further facilitates the combination of different data blocks into the original data to be encoded.
  • the data to be encoded may also be divided into two data blocks, which facilitates subsequent encoding of the types of data blocks.
  • each sub-image is a piece of data to be coded, and then divide each piece of data to be coded into two (N/2)*1 data blocks .
  • W*Q sub-images that is, the above-mentioned line blocks
  • each sub-image is a piece of data to be encoded, and then divide the data blocks according to the lines, so that each line of data forms a data block, so that each data block Represents the pixel value of a line in the image, has high continuity, is easy to encode, and the data is easy to arrange.
  • each data block is respectively coded in a corresponding coding manner.
  • the data consistency feature refers to whether the data in the data block are all the same, or whether all the data are a certain value. According to the data consistency characteristics in each data block, the corresponding encoding method is determined.
  • step S420 may include the following steps S710 and S720:
  • Step S710 when the data in the data block is all 0, the data block is encoded by the first encoding mode
  • Step S720 When the data in the data block is not all 0, the data block is encoded by the second encoding method.
  • step S420 may further include: encoding the data block according to the data feature flag bit.
  • the feature flag bit of the corresponding length can be set according to the number of data blocks.
  • the corresponding data feature flag bit is set to the first preset value (such as 0).
  • the corresponding data feature flag is set to the second preset value (such as 1).
  • the data characteristic flag includes the following four values:
  • the data feature flag of each data block may be continuously set at the front end of the code stream structure of the data to be encoded. In this way, it is convenient to decode the data feature flag bit to determine the data consistency feature of each data block when decoding, and then it is convenient to determine the corresponding decoding method.
  • the foregoing encoding of the data block by the first encoding method may include: setting the data feature flag to a first preset value, and encoding the data block according to the first preset value. That is, for a data block whose data is all 0, the code stream structure only needs one bit of the data characteristic flag bit, thereby greatly reducing the code stream overhead.
  • the foregoing encoding of the data block in the second encoding manner may include the following steps S810 to S830:
  • Step S810 Set the data feature flag to a second preset value
  • Step S820 Calculate the residual of each data in the data block
  • step S830 the data block is coded according to the second preset value and the residual.
  • the data in the data block are p1, p2, p3, and p4.
  • the residual inverse operation can be performed on the subsequent data at the same time, without the need to decode and calculate one by one, thereby improving the decoding efficiency.
  • the preset reference data can be any value such as 0, 1.
  • the preset reference data can be the median value of the value range of the data to be encoded, for example, the value range of the data to be encoded is [-127,127 ], the preset reference data can be 0, when the value range of the data to be encoded is [0,255], the preset reference data can be 127, so that when calculating the residual, the value of the residual can be reduced as much as possible to facilitate subsequent matching Residual coding.
  • method 4 is used to calculate the residual of the first data in the data block
  • method 2 is used to calculate the residual of each subsequent data in the data block, so that it can be decoded To achieve a higher degree of parallelism when the time.
  • the data to be encoded may be one of multiple sets of data to be encoded, for example, it may be N*1 sub-images in the image to be encoded.
  • each M groups of data to be coded can be used as a residual calculation data group, and the residual is calculated for each data in each data block of the residual calculation data group; M is greater than Or a positive integer equal to 2.
  • the residual calculation data group can be regarded as the basic unit of residual calculation. Compared with the data or data block to be coded as the data coding unit, the data scale of the residual calculation data group is larger. This is because the residual calculation is relatively large.
  • a residual calculation data group can use the same preset reference data, calculate the residual of the first data of each data block and the preset reference data, and obtain the first residual of each data block.
  • a residual calculation data group includes four data blocks, the first of which The difference between the first data p1 of the data block and the preset reference data p0 is obtained, and the first residual d1 is obtained; for the following three data blocks, the difference between the first data and the last data of the previous data block can be made.
  • each residual in the residual calculation data group can be obtained .
  • step S830 may include:
  • Step S1210 when the residuals in the data blocks are completely the same, the residual characteristic flag is set to a third preset value
  • step S1220 the data block is encoded according to the second preset value, the third preset value, and the encoding of any residual in the data block.
  • the residual characteristic flag is used to characterize the consistency characteristics of the residuals in the data block. For example, when the residuals in the data block are completely the same, the residual characteristic flag is set to the third preset value 0, and the third preset The value can also be other values such as 1. Since the residuals in the data blocks are all the same, it is sufficient to encode any one of the residuals. For example, if the four residuals in a certain data block are all 1, set the data feature flag to the second preset value, and the residual feature flag to the third preset value, and then encode the residual 1. These three parts together form the code stream structure of the data block. It can be seen that one residual coding can represent four residuals, so the code stream overhead of this part is greatly reduced.
  • bitLen_Diff When encoding any residual (expressed in Diff) in the data block, the bitLen_Diff required by the bit stream can be calculated by the following formula (1):
  • the residual coding also includes a 1-bit sign bit, usually 0 means +, 1 means -.
  • a value length flag can also be set, and the bit length of the code stream required for encoding of any of the foregoing residuals can be recorded according to the value length flag.
  • the bit stream bit length of the value length flag itself can be determined according to the value range of the bitLen_Diff bitLen_Diff of the above residual bit stream to ensure that there is enough bit length to represent the largest bitLen.
  • the data to be encoded Generally in the range of [0,255], the residual is generally in the range of [-255,255], so the value range of bitLen_Diff is [2,9], and the corresponding 3bit value length flag can be used to represent bitLen_Diff.
  • Table 1 Shown.
  • the code stream structure of the data block includes four parts: data feature flags, residual feature flags, value length flags, and residual coding.
  • step S830 may include:
  • Step S1310 when the residuals in the data blocks are not completely the same, the residual characteristic flag is set to a fourth preset value
  • Step S1320 encoding the data block according to the second preset value, the fourth preset value, and the coding of each residual in the data block.
  • the fourth preset value indicates that the residuals in the data block are not completely the same, and should be different from the foregoing third preset value, for example, the third preset value is 0 and the fourth preset value is 1. Since the residuals are not exactly the same, each residual needs to be coded separately.
  • the data feature flag is set to the second preset value
  • the residual feature flag is set to the fourth preset value
  • each residual is separately coded, and these three parts together form the code stream structure of the data block.
  • bitLen_Diff bitLen_Diff
  • the residual coding also includes a 1-bit sign bit, usually 0 means positive sign +, 1 means negative sign -.
  • a value length flag can also be set, and the bit length of the code stream required for encoding of the largest residual error can be recorded according to the value length flag bit.
  • the value length flag bit can refer to the content in Table 1. For example, when the maximum residual is 7, 4 bits are needed to encode, the value length flag bit can be set to 010, and each other residual error also uses 4 bits To code. Therefore, the code stream structure of the data block includes four parts: data feature flag, residual feature flag, value length flag, and the code of each residual.
  • the corresponding residual coding method is determined, and the data block with a higher degree of residual consistency is encoded with a lower occupied bit length, thereby saving code stream overhead.
  • the data to be encoded when the data to be encoded is encoded, the data can be scanned twice, the first scan for the data consistency of each data block, and the second scan for the residual consistency of each data block (for the first scan Data blocks that meet data consistency do not need to be scanned a second time). According to the results of the two scans, the corresponding encoding method is adopted. Taking the 8*1 to-be-encoded data divided into two 4*1 data blocks as an example, as shown in Figure 14, the specific encoding process is:
  • the data in one data block is all 0 and the data in the other data block is not all 0, refer to (2) in Figure 14 and set the data feature flag to 01 or 10; take the data in the first data block The data is all 0, the data in the second data block is not all 0 as an example, calculate the residual in the second data block, and then scan the residual; if the residuals are all the same, refer to (2-1 in Figure 14) ), set the residual feature flag bit to 0, the value length flag bit records the bit stream bit length Rb of the residual (where Rb has the same meaning as bitLen_Diff above), the value length flag bit is 3bit, and the residual coding part only needs To encode a residual and occupy Rb bits, the code stream structure of the data to be encoded requires a total of 6+Rb bits; if the residuals are not all the same, refer to (2-2) in Figure 14 and set the residual feature flag bit Is 1, the value length flag bit records the bit stream bit length Rb of the maximum residual error, and the value length flag bit is 3 bits.
  • step S420 may include the following steps S1510 and S1520:
  • Step S1510 when the data in the data block are completely the same, the data feature flag is set to the fifth preset value
  • step S1520 the data block is encoded according to the fifth preset value and the encoding of any data in the data block.
  • the fifth preset value is used to indicate that the data in the data block is completely the same. Since Figure 14 and Figure 7 are different classification standards for the data block, the fifth preset value is different from the first preset value and the second preset value. It does not matter if the value is set, the fifth preset value can be set to 0. Since the data in the data block are exactly the same, it is sufficient to encode any of the data. For example, the four data in a certain data block are all 1, and the data feature flag is set to the third preset value, and then data 1 is encoded. The two parts together form the code stream structure of the data block. It can be seen that the code of one data can represent four data, so the code stream overhead of this part is greatly reduced.
  • bit length bitLen_Data When encoding any data (represented by Data) in the data block, the bit length bitLen_Data required by it can be calculated by the following formula (3):
  • a value length flag can also be set, and the bit length of the code stream required for the encoding of any of the above-mentioned data is recorded according to the value length flag.
  • the bit length of the bit stream bit length of the value length flag itself can be determined according to the bitLen_Data value range of the bit length bitLen_Data of the above data to ensure that there is enough bit length to represent the largest bitLen_Data.
  • the data to be coded is generally In the range of [0,255], so the value range of bitLen is [1,8], and the corresponding 3bit value length flag bit can be used to represent bitLen_Data.
  • Table 2 The corresponding relationship is shown in Table 2.
  • the value length flag can be set to 000
  • the residual is 2 or 3 bits are needed to encode
  • the value length The flag bit can be set to 001, and so on. Therefore, in the code stream structure of the data block, there are three parts including the data feature flag bit, the value length flag bit and the data encoding.
  • step S420 may include the following steps S1610 to S1630:
  • Step S1610 when the data in the data block are not completely the same, the data characteristic flag is set to a sixth preset value
  • Step S1620 calculating the residual of each data in the data block
  • Step S1630 encoding the data block according to the sixth preset value and the residual in the data block.
  • the sixth preset value is used to indicate that the data in the data block is not completely the same, and should be different from the fifth preset value.
  • the sixth preset value can be set to 1. Since the data in the data block is not exactly the same, the data block is further encoded by residual coding.
  • the specific method can refer to the content of Figure 8. According to whether the residuals are all the same, there are two cases, and the corresponding method is adopted. coding.
  • each residual feature flag can be continuously set in the data After the feature flag.
  • the first is the data feature flag of each data block, then the residual feature flag of each data block, and then the data feature flag of each data block.
  • the value length flag, and finally the code of the residual In this way, it is convenient to determine the consistency feature of the residual before the residual is decoded during decoding, so as to determine the residual value faster and improve the decoding efficiency.
  • a size flag can also be set, and the original size of the data to be encoded is recorded according to the size flag. For example, before the data feature flag bit, according to the data volume of the data to be encoded, the size flag bit of a certain number of bits is determined, and the width, height, number of channels or the size of the divided data block of the data to be encoded are recorded. Make specific restrictions. In this way, it is convenient to determine the original size of the data during decoding, and then arrange the decoded data in an orderly manner to restore the original data.
  • the data when encoding the data, can also be divided into multiple parts, and the base address of each part is recorded in the code stream structure to indicate that the code stream data of each part is in the entire code stream.
  • the starting storage address in the stream structure is convenient to find the code stream data corresponding to a specific part of the data according to the base address during decoding, and decode it to obtain the required data. For unnecessary data, there is no need to decode, so Reduce the resource overhead required for decoding and improve decoding efficiency. for example:
  • each row block or column block is used as a piece of data to be encoded, and each row block or column block is recorded in the code stream structure of the feature image.
  • the base address of the code stream data corresponding to the data to be encoded For example, to encode a 64*8 single-channel feature image, each Q line (here Q takes 4) as a line block can be divided into two line blocks, denoted as slice0 and slice1 respectively, where slice0 includes the feature image The first 4 rows of, are denoted as row0 ⁇ row3, slice1 includes the last 4 rows in the feature image, denoted as row4 ⁇ row7.
  • Each row of data is encoded separately, for example, each row of data is used as a data block, and the corresponding encoding method is adopted according to its data consistency characteristics.
  • the code stream data of each row block can include the data feature flag and residual feature of each row. The flag bit and the actual code stream data; the header code stream and the code stream data of each line block are merged into a complete code stream structure of the characteristic image, where the start storage address of the code stream data of each line block and each line code The length information of the stream data is recorded in the header code stream.
  • the base address of each data block can also be recorded in the code stream structure of the data to be encoded to indicate the initial storage address of each data block in the code stream structure, for example, in the code stream structure.
  • the base address flag bit is set in the stream structure, which can be located before the data feature flag bit. It is used to record the base address information of each data block. This part of the data is decoded during decoding to determine the base address of each data block. According to the required data Block, read the data from the corresponding base address and decode it to get the original data of the required data block.
  • the corresponding encoding method is adopted for encoding.
  • the bit length of the bit stream required for encoding is lower, thereby reducing the bit width occupied by the bit stream data reading and writing, speeding up the calculation and processing speed of the hardware device, and saving storage Resources to broaden data application scenarios.
  • the adopted encoding method is adapted to the data consistency characteristics of each data block, thereby improving the flexibility of data encoding, so that each data block achieves a better balance between encoding performance and resource overhead. And integrate the advantages of multiple encoding methods to improve the inherent shortcomings of a single encoding method in related technologies.
  • the data encoding method adopted in this solution is lossless encoding, which can ensure data accuracy and meet the needs of various scenarios.
  • This solution is suitable for data processing of CNN feature images.
  • By performing low-overhead lossless coding on feature images it can reduce the system resources occupied by feature image data in reading and writing between the computing core and the memory, on-chip memory and off-chip memory. Thereby improving the efficiency of CNN operation, which is conducive to deployment in lightweight scenarios such as mobile terminals.
  • the exemplary embodiment of the present disclosure also provides a corresponding data decoding method. As shown in FIG. 17, the method includes the following steps S1710 and S1720:
  • Step S1710 Analyze the to-be-decoded data, and determine the data consistency characteristics of the original data block corresponding to each to-be-decoded data segment in the to-be-decoded data.
  • the data to be decoded is generally a one-dimensional binary value, which may include multiple data segments to be decoded.
  • Each data segment to be decoded corresponds to an original data block formed by at least two original data, that is, the original data corresponding to the data to be decoded. That is, for the data to be encoded in FIG. 4, each data segment to be decoded corresponds to each data block in FIG. 4.
  • the data to be decoded may include two data segments to be decoded, which facilitates the determination of the data consistency characteristics of the original data block corresponding to each data segment to be decoded.
  • each original data block may have the same amount of data, which facilitates the determination of the data amount of each original data block, and also facilitates the subsequent combination of different original data blocks.
  • the length of each data segment to be decoded can be determined according to the decoded parameters, and then the data included in each data segment to be decoded can be determined, or a partition can be set between the data segments to be decoded.
  • the delimiter is used to determine which data each data segment to be decoded includes to facilitate decoding.
  • the data consistency feature of the original data block refers to whether the data in the original data block are all the same, or whether all the data is a certain value.
  • the data consistency feature of the original data block corresponding to each data segment to be decoded can be determined by the value of the data feature flag bit in the data to be decoded.
  • the data feature flag can be located at any designated position in the data to be decoded, such as the start position, a specific position at a certain interval from the start position, an end position, a specific position at a certain interval from the end position, and so on. Taking the starting position as an example, referring to FIG. 18, step S1710 may include the following steps S1810 and S1820:
  • Step S1810 sequentially reading the first preset number of values from the start position of the data to be decoded to obtain the value of the data characteristic flag of each data segment to be decoded;
  • Step S1820 Analyze the value of each data feature flag bit to determine the data consistency feature of the original data block corresponding to each data segment to be decoded.
  • the first preset number is the length of the data feature flag.
  • the number of data segments to be decoded is K
  • the original data block corresponding to each data segment to be decoded requires 1 bit of data feature flags
  • the first preset number Is K read the top K values in the data to be decoded, and analyze the data consistency characteristics of each original data block corresponding to it.
  • the value of the data feature flag is the first preset value (such as 0)
  • it is determined that the corresponding data segment to be decoded is the first type of data segment to be decoded, and its corresponding original data
  • the data in the block are all 0
  • the value of the data feature flag is the second preset value (such as 1)
  • it is determined that the corresponding data segment to be decoded is the second type of data segment to be decoded, and the corresponding original data block is The data is not all 0.
  • Step S1720 According to the data consistency characteristics of each original data block, each data segment to be decoded is decoded by a corresponding decoding method to obtain each original data block.
  • the decoding can be performed through the following steps S1910 and S1920:
  • Step S1910 decode the second type of data segment to be decoded to obtain the residual
  • the corresponding residual decoding method can be used to decode each second type of data segment to be decoded respectively by using the value of the residual characteristic flag in the data to be decoded to obtain the residual.
  • the residual characteristic flag is used to characterize whether the residuals in each original data block are all the same.
  • the residual feature flag can be located at any designated position in the data to be decoded. In an alternative implementation, the residual feature flag can be located after the data feature flag. As shown in FIG. 20, the following step S2010 Determine the decoding method with S2020:
  • Step S2010 after the data feature flags, sequentially read the second preset number of values to obtain the value of the residual feature flags of each second type of data segment to be decoded;
  • Step S2020 Analyze the value of each residual feature flag bit to determine the residual decoding mode corresponding to each second type of data segment to be decoded.
  • the second preset number is the length of the residual feature flag.
  • the number of the second type of data segment to be decoded is F
  • each second type of data segment to be decoded occupies 1 bit of the residual feature flag
  • the second The preset number is F
  • F values are read after the data feature flag bit, and the residual decoding method corresponding to each second type of data segment to be decoded is obtained by analysis.
  • the residual decoding methods mainly include two: when the residuals in the original data block are all the same, only one of the residuals can be encoded, which can represent all the residuals, and only needs to be decoded during decoding. For a residual, copy the residual to get all other residuals; when the residuals in the original data block are not all the same, each residual needs to be encoded, and each residual needs to be decoded separately when decoding.
  • the corresponding second type of data segment to be decoded can be decoded to obtain a residual, and the residual of the second type of data segment to be decoded can be determined Are equal to the residual. For example, if you decode a certain second type of data segment to be decoded, a residual error of 3 is obtained.
  • the original data block corresponding to the second type of data segment to be decoded includes 4 data, then the second type of data segment to be decoded
  • the residual of the data segment is '3333';
  • the corresponding second type of data segment to be decoded can be decoded to obtain each residual of the second type of data segment to be decoded, such as decoding a certain A second type of data segment to be decoded, 4 residuals '3110' are obtained, which are the residuals of the second type of data segment to be decoded.
  • the residual coding bit length in the second type of data segment to be decoded can also be determined according to the value of the numerical length flag bit, and then the corresponding residual coding bit length can be read and decoded according to the residual coding bit length.
  • the value length flag bit can be located after the residual feature flag bit, and the value length flag bit of each second type of data segment to be decoded occupies 3 bits.
  • step S1920 the inverse operation of the residual is performed on the residual to obtain the original data block corresponding to the second type of data segment to be decoded.
  • the first residual in the second type of data segment to be decoded and the last data in the original data block corresponding to the previous data segment to be decoded are summed to obtain the second type of data to be decoded
  • the first residual in the second type of data segment to be decoded is summed with the preset reference data to obtain the first data in the original data block corresponding to the second type of data segment to be decoded .
  • p1 p0+d1.
  • the preset reference data p0 may be any predetermined data, for example, may be the middle value of the numerical range of the original data.
  • each residual in the second type of data segment to be decoded except the first residual is subjected to the inverse operation of the residual one by one to obtain the original corresponding to the second type of data segment to be decoded data block.
  • p2 p1+d2
  • p3 p1+d3
  • p4 p1+d4.
  • each residual in the second type of data segment to be decoded except the first residual is respectively corresponded to the first in the original data block corresponding to the second type of data segment to be decoded
  • the data is summed to obtain the original data block corresponding to the second type of data segment to be decoded.
  • p2 p1+d2
  • p3 p2+d3
  • p4 p3+d4.
  • the above-mentioned data to be decoded may be one group of a plurality of groups of data to be decoded, and each group of data to be decoded includes a plurality of data segments to be decoded.
  • each M groups of to-be-decoded data can be used as a residual decoded data group, and the residual in the residual decoded data group can be subjected to the inverse operation of the residual to obtain the residual decoded data
  • M is a positive integer greater than or equal to 2.
  • M is 2, and two sets of to-be-encoded data form a residual coded data group, which includes a total of 4 data blocks.
  • two groups of to-be-decoded data can be used to form a residual decoded data group, which includes a total of 4 to-be-decoded data segments (each group of to-be-decoded data includes two to-be-decoded data segments);
  • the decoded data group is a unit, and the inverse operation of the residual is performed. For example, the operation can be performed in the reverse direction shown in FIG. 11 to restore all the residuals to the original data.
  • Step S1730 Combine the original data blocks to obtain all original data corresponding to the data to be decoded.
  • step S1730 may include the following Steps S2110 and S2120:
  • Step S2110 Combine each original data block in the original data corresponding to each group of data to be decoded to obtain a sub-image corresponding to each group of data to be decoded;
  • step S2120 the sub-images are arranged according to the size of the original image to obtain the original image.
  • the size of the original image can be predetermined according to the application scenario.
  • the size of the feature image that is, the size of the original image
  • the size of the original image can be predetermined according to the structure of the CNN.
  • the size of the original image can be determined according to the value of the size flag in the data to be decoded.
  • the size flag bit can be located before the data feature flag bit.
  • the size flag bit of a certain number of bits is determined, and the width, height, channel number of the original image or the size of the divided original data block are recorded. There is no specific restriction on this publicly.
  • the sub-images corresponding to the data to be decoded are arranged to obtain the original image.
  • the data to be decoded includes data filling related information, such as setting a certain bit flag to record the original image size before and after filling, then this information You can determine the part of data filling, delete this part of the data, and get the original image before filling; if the data to be decoded does not include information about data filling, you can start from the rightmost column of the original image to detect the data in this column Whether the data in the adjacent column on the left is exactly the same, if they are the same, the rightmost column is determined to be the filling column, delete it, and then repeat the process until the current rightmost column is not the same as the data in the left adjacent column Exactly the same so far.
  • data filling related information such as setting a certain bit flag to record the original image size before and after filling
  • the required code stream data can be found according to the base address during decoding, and only decode it, or read at the same time. Take multiple segments of code stream data and perform parallel decoding, thereby further improving decoding efficiency. for example:
  • the entire code stream structure can include the header code stream and multiple pieces of actual code stream data.
  • Each piece of actual code stream data can be the code stream data corresponding to a row block or column block in the feature image.
  • Each piece of actual code stream data includes multiple pieces of sub-stream data.
  • the sub-stream data is the code stream data corresponding to one row or one column of data in the characteristic image.
  • the header code stream may include the size of the characteristic image, the base address of the code stream data of each line block, and the code stream data length of each line.
  • decoding When decoding, first decode the header code stream to obtain information such as size, base address, code stream data length of each line, and then determine its storage address in the code stream structure according to which part of the data is needed, so as to read the corresponding The data is decoded. For example, divide a 64*8 feature image into two 64*4 row blocks, slice0 and slice1, and record each row in the feature image as row0 ⁇ row8.
  • the starting position of the data stream of row6 can be calculated as addr1+len4+len5 , So that you can read the data from this position in the feature image code stream structure and decode it to get the data of row6; or when you need to decode the data of row1 and row6, according to the above method, calculate the starting position of the row1 code stream data as addr0 +len0, the starting position of row6 code stream data is addr1+len4+len5, read the corresponding data from these two addresses respectively, carry out parallel decoding, thus obtain the required two rows of data, the decoding efficiency is very high.
  • the data to be decoded may include the base address of each data segment to be decoded.
  • the information of the base address is located before the data feature flag in the data to be decoded, and the data to be decoded corresponding to the original data block where the target data is located can be found according to the base address.
  • the segment is called the target data segment to be decoded.
  • only the target data segment to be decoded is decoded without decoding other parts, thereby reducing the resource overhead required for decoding and improving the decoding efficiency.
  • each data segment to be decoded is decoded by a corresponding decoding method.
  • the degree of consistency is relatively high. For example, when the data in the original data blocks are all the same or all are 0, the corresponding original data blocks can be decoded in a relatively simple manner, thereby speeding up the calculation and processing speed of the hardware device and improving the decoding efficiency.
  • a data encoding method including the following steps S2210 to S2230:
  • Step S2210 Divide the to-be-encoded data into multiple data blocks, and each data block includes at least three data.
  • the division of the data to be coded can refer to step S410, the difference is that in step S2210, it is necessary to ensure that each data block includes three or more data, so as to calculate the residual for each data block separately.
  • the data to be encoded may be divided into two data blocks.
  • the data to be encoded may be evenly divided into multiple data blocks, so that each data block has the same amount of data.
  • step S2220 in each data block, the residual of the first data is calculated, and the residuals between each data except the first data and the first data are respectively calculated.
  • the method of calculating the residuals can refer to the above calculation method 1, starting from the second data, each data and the first data are used as the difference to obtain the corresponding residuals.
  • the above calculation methods 3 or 4 can be used, including: calculating the residual between the first data and the last data in the previous data block; or calculating the first data The residual error between a data and the preset reference data.
  • the preset reference data may be the middle value of the numerical range of the data to be encoded.
  • the data to be coded may be one group of multiple groups of data to be coded, and each group of data to be coded is divided into multiple data blocks.
  • each M groups of data to be encoded can be used as a residual calculation data group, and the residuals can be calculated for each data in each data block of the residual calculation data group; M is greater than or equal to A positive integer of 2.
  • a residual calculation data group a unified preset reference data is used, and the first data of each data block in the residual calculation data group is compared with the preset reference data to obtain the first data of each data block. The residual of one data, and then calculate the residual of other data through the above calculation method 1.
  • the method shown in FIG. 11 may also be used, which is specifically:
  • each data block except the first data block in the residual calculation data group calculate the residual between the first data and the last data in the previous data block, and calculate separately except for the first data
  • step S2230 the residual is encoded.
  • the residuals in each data block may be respectively coded in a corresponding coding manner according to the data consistency characteristics of the residuals in each data block.
  • the residual feature flag is set to a third preset value; according to the third preset value and any residual in the data block Encoding, to encode the data block.
  • a value length flag when encoding the data block, can also be set, and the bit length of the code stream required for encoding any of the foregoing residuals is recorded according to the value length flag.
  • the residual characteristic flag is set to a fourth preset value; according to the fourth preset value and each residual in the data block The encoding to encode the data block.
  • a value length flag bit when encoding the data block, can also be set, and the bit length of the code stream required for encoding the largest residual error is recorded according to the value length flag bit.
  • a data decoding method is provided, which is a decoding method corresponding to the data encoding method shown in FIG. 22, and includes the following steps S2310 to S2340:
  • step S2310 the data in each data segment to be decoded in the data to be decoded is decoded to obtain the residual of each data segment to be decoded; wherein the data to be decoded includes a plurality of data segments to be decoded, and each data segment to be decoded corresponds to It is an original data block formed by at least three original data.
  • the data to be decoded includes two data segments to be decoded.
  • each original data block has the same amount of data.
  • the value of the residual characteristic flag in the data to be decoded may be used to decode each data segment to be decoded in a corresponding residual decoding manner to obtain the residual.
  • the third preset number of values can be read sequentially from the starting position of the data to be decoded to obtain the value of the residual characteristic flag bit of each data segment to be decoded;
  • the value of the residual characteristic flag is analyzed to determine the residual decoding method for each data segment to be decoded.
  • the corresponding data segment to be decoded is decoded to obtain a residual, and it is determined that the residuals of the data segment to be decoded are all equal to one Residual.
  • the corresponding data segment to be decoded is decoded to obtain each residual of the data segment to be decoded.
  • the residual coding bit length in the data segment to be decoded can also be determined according to the value of the value length flag in the data segment to be decoded; read from the data segment to be decoded according to the residual coding bit length Take the residual coding and decode it.
  • Step S2320 Determine the first data in the original data block corresponding to each data segment to be decoded according to the first residual of each data segment to be decoded.
  • the first residual in each data segment to be decoded may be summed with the last data in the original data block corresponding to the previous data segment to be decoded to obtain each data segment to be decoded.
  • the first data in the original data block corresponding to each segment; or the first residual in each data segment to be decoded and the preset reference data are summed to obtain the first data in the original data block corresponding to each data segment to be decoded A piece of data.
  • the preset reference data may be the middle value of the numerical range of the original data.
  • Step S2330 each residual error in each data segment to be decoded except the first residual is respectively summed with the first data in the original data block corresponding to the data segment to be decoded to obtain each data to be decoded The original data block corresponding to the segment.
  • each residual is summed with the first data of the data segment to be decoded, that is, the inverse operation of the residual is performed to obtain the data corresponding to each residual, Then, the original data block corresponding to each data segment to be decoded is obtained.
  • the data to be decoded may be one group of a plurality of groups of data to be decoded, and each group of data to be decoded includes a plurality of data segments to be decoded. Based on this, when determining the original data block corresponding to each data segment to be decoded, each M groups of data to be decoded can be used as a residual decoding data group, and the residual in the residual decoding data group can be calculated to obtain the residual The original data block corresponding to each data segment to be decoded in the decoded data group; M is a positive integer greater than or equal to 2.
  • Step S2340 Combine the original data blocks to obtain the original data corresponding to the data to be decoded.
  • the original data blocks can be arranged according to the size of the original data to obtain the complete original data corresponding to the data to be decoded, thereby completing the data decoding process.
  • Exemplary embodiments of the present disclosure also provide a data processing method, which is applied to the data processing system as shown in FIG. 24.
  • the data processing system includes: a configurator 2410, a memory 2420, and a processor 2430 connected in sequence.
  • the configurator 2410 may be set in a DMA module;
  • the memory 2420 may be an off-chip memory, such as DDR, etc.;
  • the processor 2430 may be a CNN computing core, including an on-chip memory, such as SRAM.
  • the flow of the data processing method can be referred to as shown in FIG. 25, including the following steps S2510 to S2540:
  • step S2510 any one of the data encoding methods in the exemplary embodiments of the present disclosure (the method shown in FIG. 4 or FIG. 22) is executed by the configurator to encode preset data to be encoded to generate code stream data;
  • Step S2520 Write the generated code stream data into the memory to reduce the write bandwidth to the memory
  • Step S2530 read at least part of the code stream data in the memory through the configurator, and decode the read code stream data, so as to reduce the read bandwidth of the memory;
  • step S2540 the processor runs the decoded data.
  • the preset data to be encoded is data that needs to be read and written between the processor and the configurator, for example, it may be the characteristic image data in the CNN.
  • the configurator 2410 may include an encoder 2411, so that the configurator 2410 specifically encodes the data to be encoded through the encoder 2411.
  • the configurator 2410 may further include a decoder 2412, so that the configurator 2410 specifically decodes the read code stream data through the decoder 2412.
  • the processor 2430 may further include an SRAM 2431, which serves as an on-chip memory, so that the processor 2430 specifically reads and writes data with the configurator 2410 through the SRAM 2431.
  • the data encoding method of this exemplary embodiment can reduce the overhead of code stream data, when the configurator 2410 writes code stream data into the memory 2420, it can take up less write bandwidth; the configurator 2410 reads the code stream data from the memory 2420 When, it can take up less read bandwidth.
  • Exemplary embodiments of the present disclosure also provide an encoder.
  • the encoder may refer to the encoder 2411 shown in FIG. 24, by executing any data encoding method in the exemplary embodiments of the present disclosure (as shown in FIG. 4 or FIG. 22). The method shown), the data to be encoded is encoded.
  • Fig. 26 shows an exemplary architecture of an encoder.
  • the data to be encoded is first divided into multiple data blocks by the data dividing module; then the data consistency feature is scanned by the data scanning module, and if the conditions are met (such as all 0, or all the same), it is directly Enter the coding method selection module and determine the coding method for data consistency (such as run-length coding); if the data consistency feature does not meet the conditions, the residual calculation module will perform the residual calculation; and then the residual scanning module (which can be combined with the data The scanning module is the same module) scanning the residual consistency feature; then the encoding mode selection module determines the corresponding encoding method according to the residual consistency feature; finally, the data encoding module executes the corresponding encoding method to obtain the corresponding code stream data.
  • this embodiment is only an exemplary description, and should not be regarded as a limitation of the present disclosure.
  • Exemplary embodiments of the present disclosure also provide a decoder.
  • the decoder may refer to the decoder 2412 in FIG. 24, by executing any data encoding method in the exemplary embodiments of the present disclosure (as shown in FIG. 17 or FIG. 23). The method shown), the data to be decoded is decoded.
  • Fig. 27 shows an exemplary architecture of a decoder.
  • the encoding method analysis module first analyzes which encoding method is used for the original data block corresponding to each data segment to be decoded; then the decoding method selection module determines the corresponding decoding method; then the data decoding module Perform corresponding decoding methods, including data consistency decoding (such as run-length decoding), residual decoding, etc.; if residual decoding is used, residual inverse operation is also required by the residual calculation module; the original data corresponding to the data to be decoded is finally obtained .
  • data consistency decoding such as run-length decoding
  • residual decoding residual inverse operation is also required by the residual calculation module
  • the original data corresponding to the data to be decoded is finally obtained .
  • Exemplary embodiments of the present disclosure also provide a data processing system.
  • the data processing system may include: a configurator 2410, a memory 2420, and a processor 2430 connected in sequence. in:
  • the configurator 2410 is used to execute any data encoding method (the method shown in FIG. 4 or FIG. 22) in the exemplary embodiments of the present disclosure, to encode preset data to be encoded, to generate code stream data, and to The generated code stream data is written into the memory 2420 to reduce the write bandwidth to the memory 2420;
  • the configurator 2410 is also used to read at least part of the code stream data in the memory 2420, decode the read code stream data, and make the processor 2430 run the decoded data to reduce the read bandwidth of the memory 2420.
  • the configurator 2410 When the configurator 2410 decodes the code stream data, it may adopt a decoding method corresponding to the encoding, for example, the method shown in FIG. 17 or FIG. 23.
  • Exemplary embodiments of the present disclosure also provide a movable platform.
  • the movable platform may include:
  • the power system 2820 is arranged in the body 2810, and the power system 2820 is used to provide power for the movable platform;
  • the above-mentioned data processing system 2830 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 provided by this exemplary embodiment can reduce the required bandwidth and computing resources when running CNN for data processing, and achieve lossless encoding and decoding of CNN feature image data, ensuring that no additional errors will be introduced And there is no need to retrain the network. Therefore, it can be satisfied to run CNN under the condition of low hardware performance.
  • 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 meet 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, data decoding method, or data processing in the exemplary embodiments of the present disclosure is implemented.
  • the method for example, can execute the method steps in FIG. 4, FIG. 17, FIG. 22, or FIG. 23.
  • the computer-readable medium may be included in the movable platform described in the foregoing embodiments; or may exist alone without being assembled into the movable platform.
  • 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 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.
  • 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 exemplary embodiments described herein 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.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

一种数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质。其中一种数据编码方法包括:将待编码数据划分为多个数据块,每个数据块包括至少两个数据;根据每个数据块中的数据一致性特征,分别通过对应的编码方式对每个数据块进行编码。降低了编码所需的资源开销,提高了编解码的处理效率。

Description

数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质
本申请要求于2020年05月27日提交中国专利局,申请号PCT/CN2020/092627,发明名称为“数据压缩存储的系统、方法、处理器及计算机存储介质”的PCT专利申请的优先权,其全部内容通过引用合并于此。
本申请要求于2020年05月27日提交中国专利局,申请号PCT/CN2020/092640,发明名称为“数据存储的方法、装置、处理器及计算机存储介质”的PCT专利申请的优先权,其全部内容通过引用合并于此。
技术领域
本公开涉及数据处理技术领域,尤其涉及数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质。
背景技术
随着大数据和人工智能技术的发展,计算机需要处理的数据量越来越庞大。以CNN(Convolutional Neural Networks,卷积神经网络)为例,其运行时需要处理大量的特征图像(Feature Map),数据规模非常大,通常达到百万甚至千万的级别。如此庞大的数据量,在读写过程中占用带宽高,对硬件的计算和存储能力要求较高,进而限制了数据处理及使用的应用场景。
因此,如何在不影响数据准确率的前提下,减小数据读写的规模,对加快硬件设备的处理速度、节省存储资源以及拓宽数据应用场景,具有重要的意义。
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本公开的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。
发明内容
本公开提供了数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读介质,进而至少在一定程度上改善现有技术中数据读写占用带宽高的问题。
本公开的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本公开的实践而习得。
根据本公开的第一方面,提供一种数据编码方法,包括:将待编码数据划分为多个数据块,每个所述数据块包括至少两个数据;根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码。
根据本公开的第二方面,提供一种数据编码方法,包括:将待编码数据划分为多个数据 块,每个所述数据块包括至少三个数据;在每个所述数据块中,计算第一个数据的残差,并分别计算除所述第一个数据外的每个数据与所述第一个数据之间的残差;对所述残差进行编码。
根据本公开的第三方面,提供一种数据解码方法,包括:对待解码数据进行解析,确定所述待解码数据中各待解码数据段所对应的原始数据块的数据一致性特征;其中,所述待解码数据包括多个所述待解码数据段,每个所述待解码数据段对应于由至少两个原始数据所形成的一个原始数据块;根据每个所述原始数据块的数据一致性特征,分别通过对应的解码方式对每个所述待解码数据段进行解码,得到每个所述原始数据块;合并各所述原始数据块,得到所述待解码数据对应的全部原始数据。
根据本公开的第四方面,提供一种数据解码方法,包括:对待解码数据中每个待解码数据段中的数据进行解码,得到每个所述待解码数据段的残差;其中,所述待解码数据包括多个所述待解码数据段,每个所述待解码数据段对应于由至少三个原始数据所形成的一个原始数据块;根据每个所述待解码数据段的第一个残差,确定每个所述待解码数据段对应的原始数据块中的第一个数据;将每个所述待解码数据段中除第一个残差外的每个残差,分别与所述待解码数据段对应的原始数据块中的第一个数据求和,得到每个所述待解码数据段对应的原始数据块;合并各所述原始数据块,得到所述待解码数据对应的原始数据。
根据本公开的第五方面,提供一种数据处理方法,应用于依次连接的配置器、存储器和处理器,所述方法包括:通过所述配置器执行上述第一或第二方面的数据编码方法或其可能的实施方式,对预设的待编码数据进行编码,生成码流数据;将所生成的码流数据写入所述存储器,以降低对所述存储器的写带宽;通过所述配置器读取所述存储器内的至少部分码流数据,并对所读取的码流数据进行解码,以降低对所述存储器的读带宽;通过所述处理器运行解码所得到的数据。
根据本公开的第六方面,提供一种编码器,所述编码器通过执行上述第一或第二方面的数据编码方法或其可能的实施方式,对待编码数据进行编码。
根据本公开的第七方面,提供一种解码器,所述解码器通过执行上述第三或第四方面的数据解码方法或其可能的实施方式,对待解码数据进行解码。
根据本公开的第八方面,提供一种数据处理系统,包括:依次连接的配置器、存储器和处理器;所述配置器用于执行上述第一或第二方面的数据编码方法或其可能的实施方式,对预设的待编码数据进行编码,生成码流数据,并将所生成的码流数据写入所述存储器,以降低对所述存储器的写带宽;所述配置器还用于读取所述存储器内的至少部分码流数据,并对所读取的码流数据进行解码,使所述处理器运行解码所得到的数据,以降低对所述存储器的读带宽。
根据本公开的第九方面,提供一种可移动平台,包括:机体;动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,如上述第八方面的数据处理系统。
根据本公开的第十方面,提供一种计算机可读介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述第一、第二、第三、第四或第五方面的数据编码方法、数据解码方法、数据处理方法或其可能的实施方式。
本公开的技术方案具有以下有益效果:
一方面,通过将待编码数据分成多个数据块,根据每个数据块的数据一致性特征,采用对应的编码方式进行编码,当数据块的数据一致程度较高,如数据块中的数据全部相同,或者全部为0时,编码所需的码流位长较低,从而降低码流数据读写所占的位宽,加快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。另一方面,所采用的编码方式与每个数据块的数据一致性特征相适应,从而提高了数据编码的灵活性,使得每个数据块在编码性能与资源开销之间实现较好的平衡,并综合多种编码方式的优点,改善相关技术中单一编码方式的固有缺陷。再一方面,本方案所采用的数据编码方法为无损编码,可以保证数据精度,满足各种场景的需求。
本方案适用于对CNN特征图像的数据处理,通过对特征图像进行低开销的无损编码,能够降低特征图像数据在计算核与存储器、片上存储器与片外存储器之间读写所占用的系统资源,从而提高CNN运行的效率,有利于部署在移动终端等轻量化场景中。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施方式,并与说明书一起用于解释本公开的原理。显而易见地,下面描述中的附图仅仅是本公开的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出LeNet的结构示意图;
图2示出Resnet 18网络中特征图像的示意图;
图3示出CNN硬件计算平台框架的示意图;
图4示出本示例性实施方式中一种数据编码方法的流程图;
图5示出CNN的特征图像示意图;
图6示出本示例性实施方式中对待编码图像增加新的列的示意图;
图7示出本示例性实施方式中一种数据块编码的流程图;
图8示出本示例性实施方式中一种残差编码的流程图;
图9示出本示例性实施方式中一种计算残差的示意图;
图10示出本示例性实施方式中另一种计算残差的示意图;
图11示出本示例性实施方式中再一种计算残差的示意图;
图12示出本示例性实施方式中另一种残差编码的流程图;
图13示出本示例性实施方式中再一种残差编码的流程图;
图14示出本示例性实施方式中不同情况下数据编码的示意图;
图15示出本示例性实施方式中另一种数据块编码的流程图;
图16示出本示例性实施方式中再一种数据块编码的流程图;
图17示出本示例性实施方式中一种数据解码方法的流程图;
图18示出本示例性实施方式中确定数据一致性特征的流程图;
图19示出本示例性实施方式中一种残差解码的流程图;
图20示出本示例性实施方式中确定残差解码方式的流程图;
图21示出本示例性实施方式中数据解码方法的子流程图;
图22示出本示例性实施方式中另一种数据编码方法的流程图;
图23示出本示例性实施方式中另一种数据解码方法的流程图;
图24示出本示例性实施方式中一种数据处理系统的结构示意图;
图25示出本示例性实施方式中数据处理方法的流程图;
图26示出本示例性实施方式中一种编码器的架构图;
图27示出本示例性实施方式中一种解码器的架构图;
图28示出本示例性实施方式中一种可移动平台的结构示意图。
具体实施方式
现在将参考附图更全面地描述示例实施方式。然而,示例实施方式能够以多种形式实施,且不应被理解为限于在此阐述的范例;相反,提供这些实施方式使得本公开将更加全面和完整,并将示例实施方式的构思全面地传达给本领域的技术人员。所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施方式中。
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特征图像,数字6代表C1层特征图像的通道数,C1层的特征图像数据总量为6*28*28=4704;在S2层产生6通道的14*14特征图像;在C3层产生16通道的10*10特征图像;在S4层产生16通道的5*5特征图像。可见,每层的特征图像包含了大量的数据。
实际应用中,CNN对图像的处理主要体现为对每层特征图像的处理,特征图像是对输入图像在不同程度上的抽象表示,图2示出了Resnet 18网络(一种经典的残差网络模型)中不同层的特征图像,可见随着层数的加深,CNN所提取特征的抽象程度越高,提取了局部的个别特征或全局特征,对应的特征图像在视觉上也越来越抽象。
LeNet和Resnet 18都是相对较为简单的CNN结构,按照目前CNN的发展趋势,网络层数在逐渐加深,通道数在逐渐增多,导致整个网络的特征图像数据规模急剧升高,在芯片应用时占用的系统带宽很高,这对设备功耗和运行速度带来了巨大的挑战。图3示出CNN硬件计算平台框架,CNN计算核运行CNN过程中产生的特征图像先写入片上存储器,如SRAM(Static Random Access Memory,静态随机存取存储器)中,由于SRAM容量有限,因此需要将部分特征图像数据通过DMA(Direct Memory Access,直接存储器访问)模块搬运至片外存储器,如DDR(Double Data Rate Synchronous Dynamic Random Access Memory,双倍数据率同步动态随机存取存储器,通常简称为DDR);使用这些特征图像数据时,则执行上述搬运过程的逆过程。可见,在CNN运行过程中,SRAM和DDR之间会发生较为频繁的特征图像数据读写。以Yolo_v3为例(一种经典的目标检测网络模型),CNN计算核需要从DDR载入的特征图像数据量为153.26MB,以帧率30计算得到其占用的DDR读带宽为35.92Gbps,如果发生反复读取的时候,带宽会更高,可见降低特征图像数据占用的带宽是十分必要的。
相关技术中,针对图像数据的压缩方法分为有损压缩和无损压缩两类。有损压缩恢复出的特征图像数据和原始数据存在一定偏差,导致已有网络参数和特征图像的适配性发生变化,可能对网络性能造成较大的影响,如影响网络的收敛速度和精度,因此在CNN特征图像的处理中较少使用。无损压缩包括常用的哈夫曼(Huffman)和LZ77算法,其主要缺点是复杂度较高,硬件实现上较为复杂,导致编解码系统的吞吐率降低,限制了CNN计算核的性能,难以满足实际应用的需求。
鉴于上述一个或多个问题,本公开的示例性实施方式提供一种数据编码方法、数据解码方法、数据处理方法、编码器、解码器、数据处理系统、可移动平台与计算机可读存储介质。需要说明的是,本公开的示例性实施方式可以应用于对CNN特征图像数据的处理,也可以应用于对其他类型数据的处理。下面对本公开的示例性实施方式的各个方面进行具体说明。
图4示出了本示例性实施方式中一种数据编码方法的流程图。参考图4所示,该方法包 括以下步骤S410和S420:
步骤S410,将待编码数据划分为多个数据块,每个数据块包括至少两个数据。
本示例性实施方式中,待编码数据表示一组数据,是数据的基本编码单元,可以是一维数据(如一维数组),二维数据(如二维数据表、单通道图像),三维数据(如多通道图像)等。待编码数据的数据量可以根据硬件性能决定,综合考虑编码与传输两方面性能确定合适的数值,一般至少包括4个数据。当需要编码的数据总量较多时,可以将其首先划分为多组待编码数据,以每组待编码数据为单元分别进行编码处理。
在一种可选的实施方式中,当需要对单通道或多通道图像进行编码时,可以将待编码图像划分多个子图像,将每个子图像中的数据分别作为一个待编码数据。举例来说:
子图像的尺寸可以为N*1,N可以是待编码图像的宽度,为大于或等于4的正整数,即以待编码图像的每一行作为一个待编码数据。N也可以是其他数值,例如为便于后续划分数据块而设置的数值,或者是待编码图像的宽度的1/2、1/4等。进一步的,在将待编码图像划分为N*1的子图像时,如果待编码图像的宽度不满足为N的整数倍,则可以对待编码图像进行数据填充,使填充后的待编码图像的宽度满足为N的整数倍。举例来说,图5示出了CNN中多通道特征图像的示意图,W(Width)和H(Height)分别表示特征图像的宽和高,C(Channel)表示通道数,即需要对W*H*C个数据进行编码。以每张W*H的特征图像作为待编码图像,假设W=10,H=7,N=4,即需要将待编码图像划分为4*1的子图像,则每一行会剩余两个数据。参考图6所示,可以在待编码图像的右侧增加新的数据列,如在右侧增加第11列和第12列,形成12*7的待编码图像,则可以将每一行刚好划分为3个待编码数据。对于所增加的新的数据列,可以填充其左侧相邻的数据,如第11列和第12列复制第10列的数据,也可以填充其他预设数据,如空值、0等。
子图像也可以是待编码图像中若干行形成的行块,或者若干列形成的列块,如子图像的尺寸为W*Q,即由Q行形成的行块,或者为Q*H,即由Q列形成的列块。进一步的,以划分行块为例,在将待编码图像划分为W*Q的子图像时,如果待编码图像的总行数(即高度H)不满足为Q的整数倍,则可以对待编码图像进行数据填充,使填充后的待编码图像的总行数满足为Q的整数倍。通常可以在待编码图像的下方增加新的数据行,并填充其上方相邻的数据或其他预设数据,如空值、0等。
以上说明了如何确定待编码数据。本示例性实施方式中,需要对待编码数据划分数据块。数据块是最小编码单元,每个数据块采用相同的方法编码。可以按照待编码数据排布的特点划分数据块,如一维的待编码数据划分为多个一维数据块,二维的待编码数据划分为多个一维数据块或二维数据块,三维的待编码数据划分为多个一维数据块、二维数据块或三维数据块。本公开对于划分数据块的具体方式,以及数据块的数量不做限定。
在一种可选的实施方式中,可以将待编码数据均匀划分为多个数据块,使各数据块具有相同数量的数据,如将N*1的待编码数据均匀划分为3个数据块,每个数据块均为(N/3)*1, 这样便于在解码时确定每个数据块的数据量,进而便于将不同数据块组合为原始的待编码数据。
在一种可选的实施方式中,也可以将待编码数据划分为两个数据块,这样便于后续对数据块的类型进行编码。
以CNN特征图像为例,将图像首先划分为N*1的子图像,每个子图像为一个待编码数据,然后再将每个待编码数据划分为两个(N/2)*1的数据块。或者将特征图像划分为W*Q的子图像(即上述行块),每个子图像为一个待编码数据,然后再按照行划分数据块,使每一行数据形成一个数据块,这样每个数据块表示图像中一行的像素值,具有较高的连续性,易于编码,且数据易于排布。
步骤S420,根据每个数据块中的数据一致性特征,分别通过对应的编码方式对每个数据块进行编码。
其中,数据一致性特征是指数据块中的数据是否全部相同,或者是否全部为某个数值。根据每个数据块中的数据一致性特征,确定对应的编码方式。
在一种可选的实施方式中,参考图7所示,步骤S420可以包括以下步骤S710和S720:
步骤S710,当数据块中的数据全部为0时,通过第一编码方式对数据块进行编码;
步骤S720,当数据块中的数据不全为0时,通过第二编码方式对数据块进行编码。
其中,数据块中的数据是否全部为0,可以通过在待编码数据的码流结构中设置数据特征标志位来进行表征。即步骤S420还可以包括:根据数据特征标志位对数据块进行编码。具体来说,可以按照数据块的数量设置相应长度的特征标志位,当数据块中的数据全部为0时,将对应的数据特征标志位设为第一预设数值(如0),当数据块中的数据不全为0时,将对应的数据特征标志位设为第二预设数值(如1)。举例来说,将8*1的待编码数据均匀划分为两个4*1的数据块,可以设置两个bit的特征标志位,分别表示第一个数据块、第二个数据块的数据一致性特征,例如0代表数据块中的数据全部为0,1代表不全为0,则数据特征标志位包括以下四种数值:
00:表示整个8*1的待编码数据全部为0,即‘0000 0000’;
01:表示前4*1的数据块全部为0,后4*1的数据块不全为0,如‘0000 0xx0’(x表示非零值);
10:表示前4*1的数据块不全为0,后4*1的数据块全部为0,如‘0xx0 0000’;
11:表示前后两个4*1的数据块都不全为0,如‘xxx0 0xx0’。
在一种可选的实施方式中,在待编码数据的码流结构中,可以将各数据块的数据特征标志位连续设置于待编码数据的码流结构的前端。这样便于在解码时,先解码数据特征标志位以确定各数据块的数据一致性特征,进而便于确定对应的解码方式。
由上可知,对于数据全部为0的数据块,在解码时通过解码数据特征标志位即可确定数据全部为0,因而无需对每个数据进行编码,解码时也无需对每个数据进行解码。基于此,上述通过第一编码方式对数据块进行编码,可以包括:将数据特征标志位设为第一预设数值, 并根据第一预设数值对数据块进行编码。即对于数据全部为0的数据块,其码流结构只需要数据特征标志位这1个bit,从而大大降低了码流开销。
在一种可选的实施方式中,参考图8所示,上述通过第二编码方式对数据块进行编码,可以包括以下步骤S810至S830:
步骤S810,将数据特征标志位设为第二预设数值;
步骤S820,计算数据块中每个数据的残差;
步骤S830,根据第二预设数值和残差,对数据块进行编码。
对于数据块中每个数据的残差计算,下面提供两种计算方式:
①参考图9所示,数据块中的数据为p1、p2、p3、p4,从p2开始,计算每个数据与数据块中第一个数据p1之间的残差,得到残差d2=p2-p1,d3=p3-p1,d4=p4-p1。这样在解码时,得到第一个数据后,可以同时对后面的数据执行残差逆运算,无需逐个解码并计算,从而提高解码效率。
②参考图10所示,计算数据块中每个数据与其前一数据之间的残差,得到残差d2=p2-p1,d3=p3-p2,d4=p4-p3。由于待编码数据中数据一般具有连续性,特别是在图像数据中,相邻两个数据之间可能相同或相近,由此计算得到的残差较小,便于后续对残差编码。
在上面的计算中,还需要确定第一个数据的残差,下面提供两种计算方式:
③计算第一个数据与前一数据块中最后一个数据之间的残差。一般情况下,第一个数据与前一数据块中最后一个数据之间具有一定的连续性,这样计算得到的第一个数据的残差通常较小,便于对其进行编码。
④如图9和图10所示,计算第一个数据p1与预设基准数据p0之间的残差,得到残差d1=p1-p0。预设基准数据可以是0、1等任意数值,在一种可选的实施方式中,预设基准数据可以是待编码数据的数值范围的中值,如待编码数据的数值范围为[-127,127]时,预设基准数据可以是0,待编码数据的数值范围为[0,255]时,预设基准数据可以是127,这样在计算残差时,可以尽量减小残差的数值,便于后续对残差编码。
实际应用中,可以根据需求对上述计算方式进行任意组合,例如采用方式④计算数据块中第一个数据的残差,采用方式②计算数据块中后面每个数据的残差,这样可以在解码时实现较高的并行度。
待编码数据可以是多组待编码数据中的一组,如可以是待编码图像中的N*1子图像。对于这种情况,在计算残差时,可以以每M组待编码数据为一个残差计算数据组,对残差计算数据组的每个数据块中的每个数据计算残差;M为大于或等于2的正整数。其中,残差计算数据组可视为残差计算的基本单元,与作为数据编码单元的待编码数据或数据块相比,残差计算数据组的数据规模更大,这是由于残差计算相对于编码的计算量较低,采用较大规模的数据进行计算,可以提高效率;特别是在图像数据的编码中,以每一行或每个区域的数据为一个残差计算数据组,进行残差计算,可以实现较高的并行度。一个残差计算数据组可以采用相同的预 设基准数据,计算其中每个数据块的第一个数据与该预设基准数据的残差,得到每个数据块的第一个残差。或者参考图11所示,以两组待编码数据为一个残差计算数据组,每组待编码数据又包括两个数据块,则一个残差计算数据组包括四个数据块,其中第一个数据块的第一个数据p1与预设基准数据p0做差,得到第一个残差d1;对于后面三个数据块,可以将第一个数据与前一数据块的最后一个数据做差,得到相应的第一个残差,如d5=p5-p4,d9=p9-p8;对于各数据块中第一个数据后面的其他数据,将其分别与该数据块的第一个数据做差,得到相应的每个残差,如d2=p2-p1,d3=p3-p1,d6=p6-p5,d7=p7-p5;由此可以得到该残差计算数据组中的每个残差。
以上说明了如何计算残差。下面继续说明如何对残差进行编码,包括两种情况:
情况一、参考图12所示,步骤S830可以包括:
步骤S1210,当数据块中的残差完全相同时,将残差特征标志位设为第三预设数值;
步骤S1220,根据第二预设数值、第三预设数值和数据块中任一残差的编码,对数据块进行编码。
其中,残差特征标志位用于表征数据块中残差的一致性特征,例如数据块中的残差完全相同时,将残差特征标志位设为第三预设数值0,第三预设数值也可以是1等其他数值。由于数据块中的残差都相同,对其中的任一残差进行编码即可。举例来说,某一数据块中的四个残差均为1,设置数据特征标志位为第二预设数值,残差特征标志位为第三预设数值,再对残差1进行编码,这三部分共同形成该数据块的码流结构。可见,一个残差的编码能够代表四个残差,因此这部分的码流开销大大降低。
在对数据块中的任一残差(以Diff表示)编码时,其所需的码流位长bitLen_Diff,可以通过以下公式(1)计算:
Figure PCTCN2020099495-appb-000001
残差的编码中还包括1bit的符号位,通常0表示+,1表示-。
进一步的,在编码时,还可以设置数值长度标志位,根据数值长度标志位记录上述任一残差的编码所需的码流位长。数值长度标志位本身的码流位长,可以根据上述残差的码流位长bitLen_Diff的数值范围来确定,以保证有足够的位长来表示最大的bitLen,例如在特征图像中,待编码数据一般在[0,255]范围内,残差一般在[-255,255]范围内,因此bitLen_Diff的数值范围为[2,9],相应的可以采用3bit的数值长度标志位来表示bitLen_Diff,对应关系如表1所示。
表1
Figure PCTCN2020099495-appb-000002
Figure PCTCN2020099495-appb-000003
举例来说,残差为0或1时,需要2个bit来编码(即bitLen_Diff=2),数值长度标志位可设为000,残差为2或3时,需要3个bit来编码,数值长度标志位可设为001,等等。由此,在数据块的码流结构中,包括数据特征标志位、残差特征标志位、数值长度标志位和残差的编码这四部分。
情况二、参考图13所示,步骤S830可以包括:
步骤S1310,当数据块中的残差不完全相同时,将残差特征标志位设为第四预设数值;
步骤S1320,根据第二预设数值、第四预设数值和数据块中每个残差的编码,对数据块进行编码。
其中,第四预设数值表示数据块中的残差不完全相同,与上述第三预设数值应当不同,例如第三预设数值为0,第四预设数值为1。由于残差不完全相同,需要对每个残差分别进行编码。一般的,设置数据特征标志位为第二预设数值,残差特征标志位为第四预设数值,再对每个残差分别进行编码,这三部分共同形成数据块的码流结构。
在对残差编码时,不同残差可能需要不同的位长,为了统一起见,可以以数据块中最大的残差(以maxDiff表示)为标准,根据最大的残差的编码所需的码流位长确定每个残差的码流位长。码流位长bitLen_Diff的计算方法可以如下公式(2)所示:
Figure PCTCN2020099495-appb-000004
残差的编码中还包括1bit的符号位,通常0表示正号+,1表示负号-。
进一步的,在编码时,还可以设置数值长度标志位,根据数值长度标志位记录最大的残差的编码所需的码流位长。数值长度标志位可以参考表1部分的内容,举例来说,最大的残差为7时,需要4个bit来编码,数值长度标志位可设为010,其他每个残差也采用4个bit来编码。由此,在数据块的码流结构中,包括数据特征标志位、残差特征标志位、数值长度标志位和每个残差的编码这四部分。
以8*1的待编码数据划分为两个4*1的数据块为例,如果两个数据块中的数据均不全为0,则需要通过残差进行编码,通过对残差进行扫描,可以根据其一致性特征,确定残差特征标志位的数值,包括以下四种情况:
00:表示前4个残差全部相同,后4个残差也全部相同,如‘1111 2222’;
01:表示前4个残差全部相同,后4个残差不全相同,如‘1111 1221’;
10:表示前4个残差不全相同,后4个残差全部相同,如‘1221 1111’;
11:表示前4个残差不全相同,后4个残差也不全相同,如‘1221 1212’。
根据残差特征标志位,确定对应的残差编码方式,对残差一致性程度较高的数据块,采用占用位长较低的方式进行编码,从而节省码流开销。
通过上述内容,在对待编码数据进行编码时,可以对数据进行两次扫描,第一次扫描各数据块的数据一致性,第二次扫描各数据块的残差一致性(对于第一次扫描满足数据一致性的数据块,无需进行第二次扫描)。根据两次扫描结果,采取对应的方式编码。以8*1的待编码数据划分为两个4*1的数据块为例,结合图14所示,具体编码过程为:
首先扫描每个数据块中的数据。
如果两个数据块中的数据均全部为0,参考图14中的(1),两个数据块的数据特征标志位均为0,无需再对具体的数据进行编码,码流结构共需要2bit。
如果一个数据块中的数据全部为0,另一个数据块中的数据不全为0,参考图14中的(2),将数据特征标志位设为01或10;以第一个数据块中的数据全部为0,第二个数据块中的数据不全为0为例,计算第二个数据块中的残差,然后扫描残差;如果残差均相同,参考图14中的(2-1),将残差特征标志位设为0,数值长度标志位记录残差的码流位长Rb(这里Rb与上面的bitLen_Diff含义相同),数值长度标志位为3bit,残差的编码部分仅需要编码一个残差,占用Rb个bit,则待编码数据的码流结构共需要6+Rb个bit;如果残差不全相同,参考图14中的(2-2),将残差特征标志位设为1,数值长度标志位记录最大残差的码流位长Rb,数值长度标志位为3bit,残差的编码部分需要编码每个残差,包括R0、R1、R2、R3,每个残差需要Rb个bit,则码流结构共需要6+Rb*4个bit。
如果两个数据块中的数据都不全为0,参考图14中的(3),将数据特征标志位设为11,需要对两个数据块均计算残差,然后扫描残差;再根据残差的一致性特征,分为(3-1)到(3-4)四种情况,其中Rb表示第一个数据块的残差所需的码流位长,R'b表示第二个数据块的残差所需的码流位长,R0、R1、R2、R3表示第一个数据块的残差编码,R'0、R'1、R'2、R'3表示第二个数据块的残差编码。每种情况的码流结构所需的位长如图14中所示。
在图7所示的方法中,根据数据块中的数据是否全部为0,采用不同的编码方式进行编码。除此以外,还可以根据数据块中的数据是否全部相同,采用不同的编码方式进行编码。具体如下:
参考图15所示,步骤S420可以包括以下步骤S1510和S1520:
步骤S1510,当数据块中的数据完全相同时,将数据特征标志位设为第五预设数值;
步骤S1520,根据第五预设数值和数据块中任一数据的编码,对数据块进行编码。
其中,第五预设数值用于表示数据块中的数据完全相同,由于图14和图7是对数据块 的不同的分类标准,因此第五预设数值与第一预设数值、第二预设数值没有关系,可以将第五预设数值设为0。由于数据块中的数据完全相同,对其中任一数据编码即可。举例来说,某一数据块中的四个数据均为1,设置数据特征标志位为第三预设数值,再对数据1进行编码,这两部分共同形成该数据块的码流结构。可见,一个数据的编码能够代表四个数据,因此这部分的码流开销大大降低。
在对数据块中的任一数据(以Data表示)编码时,其所需的码流位长bitLen_Data,可以通过以下公式(3)计算:
Figure PCTCN2020099495-appb-000005
与残差的编码所不同的是,在对数据进行编码时,一般无需设置符号位,因此比残差的码流位长bitLen_Diff少1个bit。当然,在一些特别的情况中,待编码数据携带正负号,则可以设置1bit的符号位,bitLen_Data可以在公式(3)计算值的基础上加1。
进一步的,在编码时,还可以设置数值长度标志位,根据数值长度标志位记录上述任一数据的编码所需的码流位长。数值长度标志位本身的码流位长,可以根据上述数据的码流位长bitLen_Data的数值范围来确定,以保证有足够的位长来表示最大的bitLen_Data,例如在特征图像中,待编码数据一般在[0,255]范围内,因此bitLen的数值范围为[1,8],相应的可以采用3bit的数值长度标志位来表示bitLen_Data,对应关系如表2所示。
表2
Figure PCTCN2020099495-appb-000006
举例来说,数据为0或1时,需要2个bit来编码(即bitLen_Data=2),数值长度标志位可设为000,残差为2或3时,需要3个bit来编码,数值长度标志位可设为001,等等。由此,在数据块的码流结构中,包括数据特征标志位、数值长度标志位和数据的编码这三部分。
对于数据块中的数据不完全相同的情况,参考图16所示,步骤S420可以包括以下步骤S1610至S1630:
步骤S1610,当数据块中的数据不完全相同时,将数据特征标志位设为第六预设数值;
步骤S1620,计算数据块中每个数据的残差;
步骤S1630,根据第六预设数值和数据块中的残差,对数据块进行编码。
其中,第六预设数值用于表示数据块中的数据不完全相同,与第五预设数值应当不同,如可以将第六预设数值设为1。由于数据块中的数据不完全相同,进一步通过残差编码对该数据块进行编码,具体方法可以参考图8部分的内容,根据残差是否全部相同,分为两种情况,并采用对应的方式编码。
在一种可选的实施方式中,如果至少一个数据块的码流结构中包括残差特征标志位,则在待编码数据的码流结构中,可以将各残差特征标志位连续设置于数据特征标志位之后。例如参考上述图14所示,在待编码数据的码流结构中,首先是每个数据块的数据特征标志位,然后是每个数据块的残差特征标志位,然后是每个数据块的数值长度标志位,最后是残差的编码。这样便于在解码时,在解码残差之前即确定残差的一致性特征,从而更快地确定残差数值,提高解码效率。
在一种可选的实施方式中,对待编码数据进行编码时,还可以设置尺寸标志位,根据尺寸标志位记录待编码数据的原始尺寸。例如在数据特征标志位之前,根据待编码数据的数据量,确定一定bit数的尺寸标志位,记录待编码数据的宽度、高度、通道数或者划分的数据块的尺寸等,本公开对此不做具体限定。这样便于在解码时确定数据的原始尺寸,进而将解码得到的数据进行有序的排布,以还原出原始数据。
在一种可选的实施方式中,在对数据进行编码时,还可以将数据划分为多个部分,在码流结构中记录各部分的基地址,以表示各部分的码流数据在全部码流结构中的起始存储地址,便于在解码时根据基地址找到具体某部分数据所对应的码流数据,对其进行解码以得到需要的数据,对于不需要的数据,则无需进行解码,从而降低解码所需的资源开销,提高解码效率。举例来说:
对图5所示的特征图像进行编码时,可以将图像划分为不同的行块或列块,以每个行块或列块为一个待编码数据,在特征图像的码流结构中记录每个待编码数据所对应的码流数据基地址。如对64*8的单通道特征图像进行编码,可以以每Q行(这里Q取4)为一个行块,从而划分为两个行块,分别记为slice0和slice1,其中slice0包括特征图像中的前4行,记为row0~row3,slice1包括特征图像中的后4行,记为row4~row7。将特征图像的尺寸,slice0和slice1的基地址,row0~row7每一行的码流数据长度这些信息进行编码,形成特征图像码流结构中的头部码流;再对每个行块中的每一行数据分别进行编码,例如以每一行数据为一个数据块,根据其数据一致性特征采取对应的编码方式,每个行块的码流数据中可以包括每一行的数据特征标志位、残差特征标志位以及实际码流数据;将头部码流与每个行块的码流数据合并为特征图像的完整码流结构,其中每个行块的码流数据的起始存储地址、每一行码流数据的长度信息记录于头部码流中,解码时只要解码出这部分信息,即可确定所需的数据在码流结构 中的哪个位置。例如,解码时如需特征图像中row6的数据,确定row6属于slice1,根据slice1的基地址(假设为addr1),以及slice1中位于row6之前的row4与row5的长度(假设分别为len4与len5),可以计算出row6码流数据的起始位置为addr1+len4+len5,从而可以在特征图像码流结构中从该位置读取数据进行解码,得到row6的数据,解码效率非常高。
将待编码数据划分为多个数据块时,还可以在待编码数据的码流结构中记录各数据块的基地址,以表示各数据块在码流结构中的起始存储地址,例如在码流结构中设置基地址标志位,可以位于数据特征标志位之前,用于记录每个数据块的基地址信息,在解码时解码这部分数据以确定各数据块的基地址,根据所需的数据块,从对应的基地址读取数据并解码,得到所需数据块的原始数据。
本公开上述数据编码方法中,一方面,通过将待编码数据分成多个数据块,根据每个数据块的数据一致性特征,采用对应的编码方式进行编码,当数据块的数据一致程度较高,如数据块中的数据全部相同,或者全部为0时,编码所需的码流位长较低,从而降低码流数据读写所占的位宽,加快硬件设备的计算处理速度,节省存储资源,拓宽数据应用场景。另一方面,所采用的编码方式与每个数据块的数据一致性特征相适应,从而提高了数据编码的灵活性,使得每个数据块在编码性能与资源开销之间实现较好的平衡,并综合多种编码方式的优点,改善相关技术中单一编码方式的固有缺陷。再一方面,本方案所采用的数据编码方法为无损编码,可以保证数据精度,满足各种场景的需求。
本方案适用于对CNN特征图像的数据处理,通过对特征图像进行低开销的无损编码,能够降低特征图像数据在计算核与存储器、片上存储器与片外存储器之间读写所占用的系统资源,从而提高CNN运行的效率,有利于部署在移动终端等轻量化场景中。
针对于经过上述实施方式的数据编码方法编码后的数据,本公开的示例性实施方式还提供了对应的数据解码方法,参考图17所示,该方法包括以下步骤S1710和S1720:
步骤S1710,对待解码数据进行解析,确定待解码数据中各待解码数据段所对应的原始数据块的数据一致性特征。
待解码数据一般是一维的二进制数值,可以包括多个待解码数据段,每个待解码数据段对应于由至少两个原始数据所形成的一个原始数据块,即待解码数据对应的原始数据即图4中的待编码数据,每个待解码数据段对应于图4中的每个数据块。在一种可选的实施方式中,待解码数据可以包括两个待解码数据段,这样便于确定每个待解码数据段所对应的原始数据块的数据一致性特征。在一种可选的实施方式中,各原始数据块可以具有相同数量的数据,这样便于确定每个原始数据块的数据量,也便于后续对不同的原始数据块进行组合。
本示例性实施方式中,可以在解码过程中,根据解码得到的参数确定各待解码数据段的长度,进而确定每个待解码数据段包括哪些数据,也可以在待解码数据段之间设置分隔符,通过分隔符确定每个待解码数据段包括哪些数据,以便于进行解码。
原始数据块的数据一致性特征,是指原始数据块中的数据是否全部相同,或者是否全部 为某一数值。在一种可选的实施方式中,可以通过待解码数据中数据特征标志位的数值,确定各待解码数据段所对应的原始数据块的数据一致性特征。数据特征标志位可以位于待解码数据中的任意指定位置,例如起始位置、距离起始位置一定间隔的特定位置、末端位置、距离末端位置一定间隔的特定位置等。以起始位置为例,参考图18所示,步骤S1710可以包括以下步骤S1810和S1820:
步骤S1810,从待解码数据的起始位置依次读取第一预设数量的数值,得到每个待解码数据段的数据特征标志位的数值;
步骤S1820,分别对每个数据特征标志位的数值进行解析,确定每个待解码数据段所对应的原始数据块的数据一致性特征。
其中,第一预设数量是数据特征标志位的长度,例如待解码数据段的数量为K,每个待解码数据段对应的原始数据块需要1bit的数据特征标志位,则第一预设数量为K,读取待解码数据中最靠前的K个数值,解析得到对应的每个原始数据块的数据一致性特征。在一种可选的实施方式中,当数据特征标志位的数值为第一预设数值(如0)时,确定对应的待解码数据段为第一类待解码数据段,其对应的原始数据块中的数据均为0;当数据特征标志位的数值为第二预设数值(如1)时,确定对应的待解码数据段为第二类待解码数据段,其对应的原始数据块中的数据不全为0。
步骤S1720,根据每个原始数据块的数据一致性特征,分别通过对应的解码方式对每个待解码数据段进行解码,得到每个原始数据块。
本示例性实施方式中,对于数据均为0的原始数据块,仅通过数据特征标志位进行编码,而不对其中的数据进行具体编码。因此,如果确定某一待解码数据段为第一类待解码数据段,则可以直接确定对应的原始数据块中的数据全部为0。
对于数据不全为0的原始数据块,采用残差编码。因此如果确定某一待解码数据段为第二类待解码数据段,参考图19所示,可以通过以下步骤S1910和S1920进行解码:
步骤S1910,解码第二类待解码数据段,得到残差;
由于在编码时对残差采用不同的方式进行编码,因此在解码时也可以采用对应的方式进行解码。具体地,可以通过待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各第二类待解码数据段,得到残差。其中,残差特征标志位用于表征各原始数据块中的残差是否全部相同。残差特征标志位可以位于待解码数据中的任意指定位置,在一种可选的实施方式中,残差特征标志位可以位于数据特征标志位之后,参考图20所示,可以通过以下步骤S2010和S2020确定解码方式:
步骤S2010,从数据特征标志位之后,依次读取第二预设数量的数值,得到每个第二类待解码数据段的残差特征标志位的数值;
步骤S2020,分别对每个残差特征标志位的数值进行解析,确定每个第二类待解码数据段对应的残差解码方式。
其中,第二预设数量是残差特征标志位的长度,例如第二类待解码数据段的数量为F,每个第二类待解码数据段占用1bit的残差特征标志位,则第二预设数量为F,从数据特征标志位之后读取F个数值,解析得到对应的每个第二类待解码数据段对应的残差解码方式。
本示例性实施方式中,残差解码方式主要包括两种:当原始数据块中的残差全部相同时,可以仅对其中一个残差编码,即可代表所有残差,解码时仅需要解码得到一个残差,复制该残差得到其他所有的残差;当原始数据块中的残差不全相同时,需要对其中每个残差编码,解码时也需要分别解码得到每个残差。
具体地,上述两种解码方式可以通过以下步骤实现:
当残差特征标志位的数值为第三预设数值(如0)时,可以解码对应的第二类待解码数据段,得到一个残差,并确定该第二类待解码数据段的残差均等于该残差,例如解码某一第二类待解码数据段,得到一个残差为3,该第二类待解码数据段对应的原始数据块包括4个数据,则该第二类待解码数据段的残差为‘3333’;
当残差特征标志位的数值为第四预设数值(如1)时,可以解码对应的第二类待解码数据段,得到该第二类待解码数据段的每个残差,例如解码某一第二类待解码数据段,得到4个残差‘3110’,即为该第二类待解码数据段的残差。
实际应用中,还可以根据数值长度标志位的数值确定第二类待解码数据段中的残差编码位长,进而根据残差编码位长读取相应的残差编码并进行解码。例如,数值长度标志位可以位于残差特征标志位之后,每个第二类待解码数据段的数值长度标志位占用3bit,可以参考表1所示,通过对应关系确定残差编码位长,即公式(1)和(2)中的bitLen_Diff,假设读取数值长度标志位的数值为‘001100’,则确定前一个第二类待解码数据段的残差编码位长为3bit,后一个第二类待解码数据段的残差编码位长为6bit,进而按照该位长从待解码数据中读取残差编码并进行解码。
步骤S1920,对残差进行残差的逆运算,得到第二类待解码数据段对应的原始数据块。
在执行残差的逆运算时,首先计算各第二类待解码数据段所对应的原始数据块中的第一个数据。本示例性实施方式中,对于第一个数据的残差提供两种计算方式(参考上述图8部分内容的计算方式③和④),因此也提供两种对应的残差逆运算方式:
对应于上述残差计算方式③,将第二类待解码数据段中第一个残差与前一待解码数据段所对应原始数据块中的最后一个数据求和,得到第二类待解码数据段对应的原始数据块中的第一个数据。
对应于上述残差计算方式④,将第二类待解码数据段中第一个残差与预设基准数据求和,得到第二类待解码数据段对应的原始数据块中的第一个数据。例如参考上述图9与图10,p1=p0+d1。预设基准数据p0可以是预先确定的任意数据,例如可以是原始数据的数值范围的中值。
在确定第一个数据后,再计算后续的数据。由于残差计算包括两种方式(参考上述图8 部分内容的计算方式①和②),因此也提供两种对应的残差逆运算方式:
对应于上述残差计算方式①,将第二类待解码数据段中除第一个残差外的每个残差,逐个进行残差的逆运算,得到第二类待解码数据段对应的原始数据块。例如参考上述图9所示,p2=p1+d2,p3=p1+d3,p4=p1+d4。
对应于上述残差计算方式②,将第二类待解码数据段中除第一个残差外的每个残差,分别与第二类待解码数据段对应的原始数据块中的第一个数据求和,得到第二类待解码数据段对应的原始数据块。例如参考上述图10所示,p2=p1+d2,p3=p2+d3,p4=p3+d4。
在一种可选的实施方式中,上述待解码数据可以是多组待解码数据中的一组,每组待解码数据均包括多个待解码数据段。基于此,在执行残差的逆运算时,可以以每M组待解码数据为一个残差解码数据组,对残差解码数据组中的残差进行残差的逆运算,得到残差解码数据组中每个第二类待解码数据段对应的数据块;M为大于或等于2的正整数。例如,参考上述图11所示,M为2,以两组待编码数据形成一个残差编码数据组,其中共包括4个数据块。相应的,在解码时,可以以两组待解码数据形成一个残差解码数据组,其中共包括4个待解码数据段(每组待解码数据包括两个待解码数据段);以该残差解码数据组为单元,执行残差的逆运算,如可以按照图11所示的逆方向进行运算,以将所有残差恢复为原始数据。
步骤S1730,合并各原始数据块,得到待解码数据对应的全部原始数据。
如果原始数据为一维数据,将各原始数据块按顺序排列即可得到全部原始数据。如果原始数据为二维或三维数据,在排列各原始数据块时,需要考虑原始数据的尺寸。例如,上述待解码数据可以是多组待解码数据中的一组,每组待解码数据对应的原始数据为原始图像中的一个子图像;基于此,参考图21所示,步骤S1730可以包括以下步骤S2110和S2120:
步骤S2110,合并每组待解码数据对应的原始数据中的各原始数据块,得到每组待解码数据对应的子图像;
步骤S2120,按照原始图像的尺寸排列各子图像,得到原始图像。
其中,原始图像的尺寸可以根据应用场景预先确定,例如在CNN特征图像的编解码场景中,根据CNN的结构,可以预先确定特征图像的尺寸,即原始图像的尺寸。或者,可以根据待解码数据中尺寸标志位的数值确定原始图像的尺寸。例如尺寸标志位可以位于数据特征标志位之前,根据原始图像的尺寸数值范围,确定一定bit数的尺寸标志位,记录原始图像的宽度、高度、通道数或者划分的原始数据块的尺寸等,本公开对此不做具体限定。按照原始图像的尺寸,对各待解码数据所对应的子图像进行排列,得到原始图像。
需要说明的是,所得到的原始图像中,可能存在数据填充的情况,如果待解码数据中包括数据填充的相关信息,例如设置一定bit的标志位记录填充前后的原始图像尺寸,则根据该信息可以确定数据填充的部分,删除这部分数据,从而得到填充前的原始图像;如果待解码数据中未包括数据填充的相关信息,则可以从原始图像的最右侧列开始,检测该列的数据与左侧相邻列的数据是否完全相同,若相同,则确定最右侧列为填充列,将其删除,然后 重复该过程,直到当前的最右侧列与其左侧相邻列的数据不完全相同为止。
在一种可选的实施方式中,如果在数据编码时记录了各部分码流数据的基地址,则解码时可以根据基地址找到所需的码流数据,仅对其进行解码,或者同时读取多段码流数据,进行并行解码,从而进一步提高解码效率。举例来说:
在对特征图像的数据解码时,整个码流结构中可以包括头部码流和多段实际码流数据,每段实际码流数据可以是特征图像中的一个行块或者列块对应的码流数据,每段实际码流数据又包括多段子码流数据,子码流数据为特征图像中一行或者一列数据对应的码流数据。下面以行块为例,头部码流可以包括特征图像的尺寸,每个行块的码流数据的基地址,每一行的码流数据长度。在解码时,先解码头部码流,得到尺寸、基地址、每一行的码流数据长度等信息,再根据所需哪一部分数据确定其在码流结构中的存储地址,从而读取相应的数据进行解码。例如,将64*8的特征图像划分为64*4的两个行块slice0和slice1,记特征图像中的每一行分别为row0~row8,如需解码特征图像中row6的数据,确定row6属于slice1,根据slice1的基地址(假设为addr1),以及slice1中位于row6之前的row4与row5的长度(假设分别为len4与len5),可以计算出row6码流数据的起始位置为addr1+len4+len5,从而可以在特征图像码流结构中从该位置读取数据进行解码,得到row6的数据;或者需要解码row1与row6的数据时,按照上述方法,计算出row1码流数据的起始位置为addr0+len0,row6码流数据的起始位置为addr1+len4+len5,分别从这两个地址读取相应的数据,进行并行解码,从而得到所需的两行数据,解码效率非常高。
或者待解码数据中可以包括上述各待解码数据段的基地址,例如基地址的信息位于待解码数据中数据特征标志位之前,可以根据基地址找到目标数据所在的原始数据块对应的待解码数据段,称为目标待解码数据段。进而仅对目标待解码数据段解码,而无需解码其他部分,从而降低解码所需的资源开销,提高解码效率。
本公开上述数据解码方法中,根据待解码数据中各待解码数据段所对应的原始数据块的数据一致性特征,采用对应的解码方式对各待解码数据段进行解码,当原始数据块的数据一致程度较高,如原始数据块中的数据全部相同,或者全部为0时,可以通过较为简单的方式解码出对应的原始数据块,从而加快硬件设备的计算处理速度,提高解码效率。
参考图22所示的实施方式,提供了一种数据编码方法,包括以下步骤S2210至S2230:
步骤S2210,将待编码数据划分为多个数据块,每个数据块包括至少三个数据。
其中,对待编码数据的划分可以参考步骤S410,不同之处在于步骤S2210中需要保证每个数据块包括三个或三个以上数据,以便于对每个数据块分别计算残差。
在一种可选的实施方式中,可以将待编码数据划分为两个数据块。
在一种可选的实施方式中,可以将待编码数据均匀划分为多个数据块,使各数据块具有相同数量的数据。
步骤S2220,在每个数据块中,计算第一个数据的残差,并分别计算除第一个数据外的 每个数据与第一个数据之间的残差。
计算残差的方式可以参考上述计算方式①,从第二个数据开始,分别以每个数据与第一个数据作差,得到对应的残差。
对于数据块中的第一个数据,在计算残差时,可以采用上述计算方式③或④,包括:计算第一个数据与前一数据块中最后一个数据之间的残差;或者计算第一个数据与预设基准数据之间的残差。
在一种可选的实施方式中,预设基准数据可以是待编码数据的数值范围的中值。
在一种可选的实施方式中,待编码数据可以是多组待编码数据中的一组,每组待编码数据均被划分为多个数据块。基于此,在计算残差时,可以以每M组待编码数据为一个残差计算数据组,对残差计算数据组的每个数据块中的每个数据计算残差;M为大于或等于2的正整数。例如,对于一个残差计算数据组,采用统一的预设基准数据,该残差计算数据组中每个数据块的第一个数据与该预设基准数据做差,得到每个数据块的第一个数据的残差,然后再通过上述计算方式①计算其他数据的残差。
进一步的,在对残差计算数据组的每个数据块中的每个数据计算残差时,还可以采用图11所示的方式,具体为:
在残差计算数据组的第一数据块中,计算第一个数据与预设基准数据之间的残差,并计算其他数据与该第一个数据之间的残差;即d1=p1-p0,d2=p2-p1,d3=p3-p1,d4=p4-p1;
在残差计算数据组除第一数据块以外的其他每个数据块中,计算第一个数据与前一数据块中最后一个数据之间的残差,并分别计算除该第一个数据外的每个数据与该第一个数据之间的残差;即d5=p5-p4,d6=p6-p5,d7=p7-p5,d8=p8-p5等等。
步骤S2230,对残差进行编码。
根据残差的不同情况,可以采用不同的编码方式。在一种可选的实施方式中,可以根据每个数据块中的残差的数据一致性特征,分别通过对应的编码方式对每个数据块中的残差进行编码。
在一种可选的实施方式中,当数据块中的残差完全相同时,将残差特征标志位设为第三预设数值;根据第三预设数值和数据块中任一残差的编码,对数据块进行编码。
在一种可选的实施方式中,对数据块进行编码时,还可以设置数值长度标志位,根据数值长度标志位记录上述任一残差的编码所需的码流位长。
在一种可选的实施方式中,当数据块中的残差不完全相同时,将残差特征标志位设为第四预设数值;根据第四预设数值和数据块中每个残差的编码,对数据块进行编码。
在一种可选的实施方式中,对数据块进行编码时,还可以设置数值长度标志位,根据数值长度标志位记录最大的残差的编码所需的码流位长。
参考图23所示的实施方式,提供了一种数据解码方法,为图22所示的数据编码方法所对应的解码方法,包括以下步骤S2310至S2340:
步骤S2310,对待解码数据中每个待解码数据段中的数据进行解码,得到每个待解码数据段的残差;其中,待解码数据包括多个待解码数据段,每个待解码数据段对应于由至少三个原始数据所形成的一个原始数据块。
在一种可选的实施方式中,待解码数据包括两个待解码数据段。
在一种可选的实施方式中,各原始数据块具有相同数量的数据。
在一种可选的实施方式中,可以通过待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各待解码数据段,得到残差。
在一种可选的实施方式中,可以从待解码数据的起始位置依次读取第三预设数量的数值,得到每个待解码数据段的残差特征标志位的数值;分别对每个残差特征标志位的数值进行解析,确定每个待解码数据段的残差解码方式。
在一种可选的实施方式中,当残差特征标志位的数值为第三预设数值时,解码对应的待解码数据段,得到一个残差,确定待解码数据段的残差均等于一个残差。
在一种可选的实施方式中,当残差特征标志位的数值为第四预设数值时,解码对应的待解码数据段,得到待解码数据段的每个残差。
在一种可选的实施方式中,还可以根据待解码数据段中数值长度标志位的数值确定待解码数据段中的残差编码位长;根据残差编码位长从待解码数据段中读取残差编码并进行解码。
步骤S2320,根据每个待解码数据段的第一个残差,确定每个待解码数据段对应的原始数据块中的第一个数据。
在一种可选的实施方式中,可以将每个待解码数据段中第一个残差与前一待解码数据段所对应原始数据块中的最后一个数据求和,得到每个待解码数据段对应的原始数据块中的第一个数据;或者将每个待解码数据段中第一个残差与预设基准数据求和,得到每个待解码数据段对应的原始数据块中的第一个数据。
在一种可选的实施方式中,预设基准数据可以是原始数据的数值范围的中值。
步骤S2330,将每个待解码数据段中除第一个残差外的每个残差,分别与待解码数据段对应的原始数据块中的第一个数据求和,得到每个待解码数据段对应的原始数据块。
从每个待解码数据段的第二残差开始,将每个残差均与待解码数据段的第一个数据求和,即执行残差的逆运算,得到每个残差对应的数据,进而得到每个待解码数据段对应的原始数据块。
在一种可选的实施方式中,待解码数据可以是多组待解码数据中的一组,每组待解码数据均包括多个待解码数据段。基于此,在确定每个待解码数据段对应的原始数据块时,可以以每M组待解码数据为一个残差解码数据组,对残差解码数据组中的残差进行计算,得到残差解码数据组中每个待解码数据段对应的原始数据块;M为大于或等于2的正整数。
步骤S2340,合并各原始数据块,得到待解码数据对应的原始数据。
例如可以按照原始数据的尺寸对各原始数据块进行排列,得到待解码数据对应的完整 的原始数据,从而完成数据解码流程。
本公开示例性实施方式还提供一种数据处理方法,应用于如图24所示的数据处理系统。该数据处理系统包括:依次连接的配置器2410、存储器2420和处理器2430。该配置器2410可以设置于DMA模块中;该存储器2420可以是片外存储器,如DDR等;该处理器2430可以是CNN计算核,包括片上存储器,如SRAM等。
该数据处理方法的流程可以参考图25所示,包括以下步骤S2510至S2540:
步骤S2510,通过配置器执行本公开示例性实施方式中任一种数据编码方法(如图4或图22所示的方法),对预设的待编码数据进行编码,生成码流数据;
步骤S2520,将所生成的码流数据写入存储器,以降低对存储器的写带宽;
步骤S2530,通过配置器读取存储器内的至少部分码流数据,并对所读取的码流数据进行解码,以降低对存储器的读带宽;
步骤S2540,通过处理器运行解码所得到的数据。
其中,预设的待编码数据为处理器和配置器之间需要读写的数据,例如可以是CNN中的特征图像数据。
在一种可选的实施方式中,配置器2410可以包括编码器2411,使配置器2410具体通过编码器2411编码待编码数据。
在一种可选的实施方式中,配置器2410还可以包括解码器2412,使配置器2410具体通过解码器2412解码所读取的码流数据。
在一种可选的实施方式中,处理器2430还可以包括SRAM 2431,其作为片上存储器,使得处理器2430具体通过SRAM 2431与配置器2410进行数据读写。
由于本示例性实施方式的数据编码方法可以降低码流数据的开销,配置器2410将码流数据写入存储器2420时,可以占用更少的写带宽;配置器2410从存储器2420读取码流数据时,可以占用更少的读带宽。
本公开示例性实施方式还提供一种编码器,该编码器可以参考图24中的编码器2411所示,通过执行本公开示例性实施方式中任一种数据编码方法(如图4或图22所示的方法),对待编码数据进行编码。
图26示出编码器的一种示例性架构。待编码数据进入编码器后,首先由数据划分模块将待编码数据划分为多个数据块;然后由数据扫描模块扫描数据一致性特征,若满足条件(如全部为0,或者全部相同)则直接进入编码方式选择模块,确定采用数据一致性的编码方式(如游程编码);若数据一致性特征不满足条件,则由残差计算模块进行残差运算;再由残差扫描模块(可以和数据扫描模块为同一模块)扫描残差一致性特征;再由编码方式选择模块根据残差一致性特征确定对应的编码方式;最后由数据编码模块执行相应的编码方式,得到对应的码流数据。需要说明的是,本实施方式仅为示例性说明,不应当看作是对本公开的限定。
本公开示例性实施方式还提供一种解码器,该解码器可以参考图24中的解码器2412所示,通过执行本公开示例性实施方式中任一种数据编码方法(如图17或图23所示的方法),对待解码数据进行解码。
图27示出解码器的一种示例性架构。待解码数据进入解码器后,首先由编码方式解析模块解析各待解码数据段所对应的原始数据块采用了哪种编码方式;然后由解码方式选择模块确定对应的解码方式;再由数据解码模块执行相应的解码方式,包括数据一致性解码(如游程解码)、残差解码等;如果采用残差解码,还需要由残差计算模块进行残差逆运算;最终得到待解码数据对应的原始数据。需要说明的是,本实施方式仅为示例性说明,不应当看作是对本公开的限定。
本公开示例性实施方式还提供一种数据处理系统。可以参考上述图24所示,该数据处理系统可以包括:依次连接的配置器2410、存储器2420和处理器2430。其中:
配置器2410,用于执行本公开示例性实施方式中任一种数据编码方法(如图4或图22所示的方法),对预设的待编码数据进行编码,生成码流数据,并将所生成的码流数据写入存储器2420,以降低对存储器2420的写带宽;
配置器2410,还用于读取存储器2420内的至少部分码流数据,对所读取的码流数据进行解码,使处理器2430运行解码得到的数据,以降低对存储器2420的读带宽。
配置器2410在对码流数据进行解码时,可以采用与编码对应的解码方法,例如图17或图23所示的方法等。
本公开示例性实施方式还提供一种可移动平台。参考图28所示,该可移动平台可以包括:
机体2810;
动力系统2820,设于机体2810,动力系统2820用于为可移动平台提供动力;
数据处理系统2830,其结构可以参考图24。
示例性的,上述数据处理系统2830可以应用于动力系统、作业系统等等可移动平台的功能系统中。
本示例性实施方式提供的数据处理系统在运行CNN进行数据处理时,能够降低所需的带宽与计算资源,且实现对CNN的特征图像数据进行无损的编码与解码,保证不会引入额外的误差且不需要重新训练网络。因而,能够满足在硬件性能不高的情况下运行CNN。
本示例性实施方式提供的数据处理系统在使用神经网络进行数据处理时,能够实现对神经网络的参数进行无损的编码与解码,保证参数不会引入额外的误差且不需要重新训练神经网络,并且降低系统带宽开销。能够满足使用条件较低的硬件资源实现神经网络的运行。
本公开示例性实施方式还提供一种计算机可读介质,其上存储有计算机程序,计算机程序被处理器执行时实现本公开示例性实施方式中任一种数据编码方法、数据解码方法或数据处理方法,例如可以执行图4、图17、图22或图23中的方法步骤等。该计算机可读介质 可以是上述实施方式中描述的可移动平台中所包含的;也可以是单独存在,而未装配入该可移动平台中。
需要说明的是,本公开所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本公开实施方式的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、终端装置、或者网络设备等)执行根据本公开示例性实施例的方法。
此外,上述附图仅是根据本公开示例性实施例的方法所包括的处理的示意性说明,而不是限制目的。易于理解,上述附图所示的处理并不表明或限制这些处理的时间顺序。另外,也易于理解,这些处理可以是例如在多个模块中同步或异步执行的。
应当注意,尽管在上文详细描述中提及了用于动作执行的设备的若干模块或者单元,但是这种划分并非强制性的。实际上,根据本公开的示例性实施例,上文描述的两个或更多模块或者单元的特征和功能可以在一个模块或者单元中具体化。反之,上文描述的一个模块或者单元的特征和功能可以进一步划分为由多个模块或者单元来具体化。
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其他实施例。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由权利要求指出。
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限定。

Claims (73)

  1. 一种数据编码方法,其特征在于,包括:
    将待编码数据划分为多个数据块,每个所述数据块包括至少两个数据;
    根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码。
  2. 根据权利要求1所述的方法,其特征在于,所述根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码,包括:
    当所述数据块中的数据全部为0时,通过第一编码方式对所述数据块进行编码;
    当所述数据块中的数据不全为0时,通过第二编码方式对所述数据块进行编码。
  3. 根据权利要求2所述的方法,其特征在于,所述根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码,还包括:
    根据数据特征标志位对所述数据块进行编码,其中,所述数据特征标志位用于表征所述数据块中的数据是否全部为0。
  4. 根据权利要求3所述的方法,其特征在于,所述通过第一编码方式对所述数据块进行编码,包括:
    将所述数据特征标志位设为第一预设数值,并根据所述第一预设数值对所述数据块进行编码。
  5. 根据权利要求3所述的方法,其特征在于,所述通过第二编码方式对所述数据块进行编码,包括:
    将所述数据特征标志位设为第二预设数值;
    计算所述数据块中每个数据的残差;
    根据所述第二预设数值和所述数据块中的残差,对所述数据块进行编码。
  6. 根据权利要求5所述的方法,其特征在于,所述计算所述数据块中每个数据的残差,包括:
    计算所述数据块中所述每个数据与所述数据块中第一个数据之间的残差;或者
    计算所述数据块中所述每个数据与其前一数据之间的残差。
  7. 根据权利要求6所述的方法,其特征在于,所述第一个数据的残差,通过以下方式计算:
    计算所述第一个数据与前一数据块中最后一个数据之间的残差;或者
    计算所述第一个数据与预设基准数据之间的残差。
  8. 根据权利要求7所述的方法,其特征在于,所述预设基准数据为所述待编码数据的数值范围的中值。
  9. 根据权利要求5所述的方法,其特征在于,所述待编码数据为多组待编码数据中的一组;
    所述计算所述数据块中每个数据的残差,包括:
    以每M组所述待编码数据为一个残差计算数据组,对所述残差计算数据组的每个所述数据块中的每个数据计算残差;M为大于或等于2的正整数。
  10. 根据权利要求5所述的方法,其特征在于,所述根据所述第二预设数值和所述数据块中的残差,对所述数据块进行编码,包括:
    当所述数据块中的残差完全相同时,将残差特征标志位设为第三预设数值;
    根据所述第二预设数值、所述第三预设数值和所述数据块中任一所述残差的编码,对所述数据块进行编码。
  11. 根据权利要求10所述的方法,其特征在于,所述根据所述第二预设数值和所述数据块中的残差,对所述数据块进行编码,还包括:
    设置数值长度标志位,根据所述数值长度标志位记录任一所述残差的编码所需的码流位长。
  12. 根据权利要求5所述的方法,其特征在于,所述根据所述第二预设数值和所述数据块中的残差,对所述数据块进行编码,包括:
    当所述数据块中的残差不完全相同时,将残差特征标志位设为第四预设数值;
    根据所述第二预设数值、所述第四预设数值和所述数据块中每个所述残差的编码,对所述数据块进行编码。
  13. 根据权利要求12所述的方法,其特征在于,所述根据所述第二预设数值和所述数据块中的残差,对所述数据块进行编码,还包括:
    设置数值长度标志位,根据所述数值长度标志位记录最大的所述残差的编码所需的码流位长。
  14. 根据权利要求1所述的方法,其特征在于,所述根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码,包括:
    当所述数据块中的数据完全相同时,将数据特征标志位设为第五预设数值;
    根据所述第五预设数值和所述数据块中任一所述数据的编码,对所述数据块进行编码。
  15. 根据权利要求14所述的方法,其特征在于,所述对所述数据块进行编码,还包括:
    设置数值长度标志位,根据所述数值长度标志位记录任一所述数据的编码所需的码流位长。
  16. 根据权利要求14所述的方法,其特征在于,所述根据每个所述数据块中的数据一致性特征,分别通过对应的编码方式对每个所述数据块进行编码,还包括:
    当所述数据块中的数据不完全相同时,将所述数据特征标志位设为第六预设数值;
    计算所述数据块中每个数据的残差;
    根据所述第六预设数值和所述数据块中的残差,对所述数据块进行编码。
  17. 根据权利要求3至16中任一项所述的方法,其特征在于,在所述待编码数据的码流结构中,将各所述数据块的数据特征标志位连续设置于所述待编码数据的码流结构的前端。
  18. 根据权利要求17所述的方法,其特征在于,如果至少一个所述数据块的码流结构中包括残差特征标志位,则在所述待编码数据的码流结构中,将各所述残差特征标志位连续设置于所述数据特征标志位之后。
  19. 根据权利要求1所述的方法,其特征在于,所述待编码数据通过以下方式获取:
    将待编码图像划分为N*1的子图像,将每个所述子图像中的数据分别作为一个所述待编码数据;N为大于或等于4的正整数。
  20. 根据权利要求19所述的方法,其特征在于,在将所述待编码图像划分为N*1的子图像时,如果所述待编码图像的宽度不满足为N的整数倍,则对所述待编码图像进行数据填充,使填充后的所述待编码图像的宽度满足为N的整数倍。
  21. 根据权利要求20所述的方法,其特征在于,所述对所述待编码图像进行数据填充,包括:
    在所述待编码图像的右侧增加新的数据列,在所述新的数据列中填充其左侧相邻的数据。
  22. 根据权利要求19所述的方法,其特征在于,在对所述待编码数据进行编码时,所述方法还包括:
    设置尺寸标志位,根据所述尺寸标志位记录所述待编码数据的原始尺寸。
  23. 根据权利要求19所述的方法,其特征在于,所述待编码图像为卷积神经网络中的特征图像。
  24. 根据权利要求1至23中任一项所述的方法,其特征在于,所述将待编码数据划分为多个数据块,包括:
    将所述待编码数据划分为两个数据块。
  25. 根据权利要求1至23中任一项所述的方法,其特征在于,所述将待编码数据划分为多个数据块,包括:
    将所述待编码数据均匀划分为多个数据块,使各所述数据块具有相同数量的数据。
  26. 一种数据编码方法,其特征在于,包括:
    将待编码数据划分为多个数据块,每个所述数据块包括至少三个数据;
    在每个所述数据块中,计算第一个数据的残差,并分别计算除所述第一个数据外的每个数据与所述第一个数据之间的残差;
    对所述残差进行编码。
  27. 根据权利要求26所述的方法,其特征在于,所述计算第一个数据的残差,包括:
    计算所述第一个数据与前一数据块中最后一个数据之间的残差;或者
    计算所述第一个数据与预设基准数据之间的残差。
  28. 根据权利要求27所述的方法,其特征在于,所述预设基准数据为所述待编码数据的数值范围的中值。
  29. 根据权利要求27所述的方法,其特征在于,所述待编码数据为多组待编码数据中的一组,每组所述待编码数据均被划分为多个所述数据块;
    在计算所述残差时,以每M组所述待编码数据为一个残差计算数据组,对所述残差计算数据组的每个所述数据块中的每个数据计算残差;M为大于或等于2的正整数。
  30. 根据权利要求29所述的方法,其特征在于,所述对所述残差计算数据组的每个所述数据块中的每个数据计算残差,包括:
    在所述残差计算数据组的第一数据块中,计算第一个数据与所述预设基准数据之间的残差,并计算其他数据与该第一个数据之间的残差;
    在所述残差计算数据组除所述第一数据块以外的其他每个数据块中,计算第一个数据与前一数据块中最后一个数据之间的残差,并分别计算除该第一个数据外的每个数据与该第一个数据之间的残差。
  31. 根据权利要求26所述的方法,其特征在于,所述对所述残差进行编码,包括:
    根据每个所述数据块中的残差的数据一致性特征,分别通过对应的编码方式对每个所述数据块中的残差进行编码。
  32. 根据权利要求31所述的方法,其特征在于,所述根据每个所述数据块中的残差的数据一致性特征,分别通过对应的编码方式对每个所述数据块中的残差进行编码,包括:
    当所述数据块中的残差完全相同时,将残差特征标志位设为第三预设数值;
    根据所述第三预设数值和所述数据块中任一所述残差的编码,对所述数据块进行编码。
  33. 根据权利要求32所述的方法,其特征在于,所述对所述数据块进行编码,还包括:
    设置数值长度标志位,根据所述数值长度标志位记录任一所述残差的编码所需的码流位长。
  34. 根据权利要求31所述的方法,其特征在于,所述根据每个所述数据块中的残差的数据一致性特征,分别通过对应的编码方式对每个所述数据块中的残差进行编码,包括:
    当所述数据块中的残差不完全相同时,将残差特征标志位设为第四预设数值;
    根据所述第四预设数值和所述数据块中每个所述残差的编码,对所述数据块进行编码。
  35. 根据权利要求34所述的方法,其特征在于,所述对所述数据块进行编码,还包括:
    设置数值长度标志位,根据所述数值长度标志位记录最大的所述残差的编码所需的码流位长。
  36. 根据权利要求26至35中任一项所述的方法,其特征在于,所述将待编码数据划分为多个数据块,包括:
    将所述待编码数据划分为两个数据块。
  37. 根据权利要求26至35中任一项所述的方法,其特征在于,所述将待编码数据划分为多个数据块,包括:
    将所述待编码数据均匀划分为多个数据块,使各所述数据块具有相同数量的数据。
  38. 一种数据解码方法,其特征在于,包括:
    对待解码数据进行解析,确定所述待解码数据中各待解码数据段所对应的原始数据块的数据一致性特征;其中,所述待解码数据包括多个所述待解码数据段,每个所述待解码数据段对应于由至少两个原始数据所形成的一个原始数据块;
    根据每个所述原始数据块的数据一致性特征,分别通过对应的解码方式对每个所述待解码数据段进行解码,得到每个所述原始数据块;
    合并各所述原始数据块,得到所述待解码数据对应的全部原始数据。
  39. 根据权利要求38所述的方法,其特征在于,所述对待解码数据进行解析,确定所述待解码数据中各待解码数据段所对应的原始数据块的数据一致性特征,包括:
    通过所述待解码数据中数据特征标志位的数值,确定各所述待解码数据段所对应的原始数据块的数据一致性特征。
  40. 根据权利要求39所述的方法,其特征在于,所述通过所述待解码数据中数据特征标志位的数值,确定各所述待解码数据段所对应的原始数据块的数据一致性特征,包括:
    从所述待解码数据的起始位置依次读取第一预设数量的数值,得到每个所述待解码数据段的数据特征标志位的数值;
    分别对每个所述数据特征标志位的数值进行解析,确定每个所述待解码数据段所对应的原始数据块的数据一致性特征。
  41. 根据权利要求40所述的方法,其特征在于,所述分别对每个所述数据特征标志位的数值进行解析,确定每个所述待解码数据段所对应的原始数据块的数据一致性特征,包括:
    当所述数据特征标志位的数值为第一预设数值时,确定对应的所述待解码数据段为第一类待解码数据段,其对应的原始数据块中的数据均为0。
  42. 根据权利要求40所述的方法,其特征在于,所述分别对每个所述数据特征标志位的数值进行解析,确定每个所述待解码数据段所对应的原始数据块的数据一致 性特征,包括:
    当所述数据特征标志位的数值为第二预设数值时,确定对应的所述待解码数据段为第二类待解码数据段,其对应的原始数据块中的数据不全为0。
  43. 根据权利要求42所述的方法,其特征在于,所述根据每个所述原始数据块的数据一致性特征,分别通过对应的解码方式对每个所述待解码数据段进行解码,得到每个所述原始数据块,包括:
    解码所述第二类待解码数据段,得到残差;
    对所述残差进行残差的逆运算,得到所述第二类待解码数据段对应的原始数据块。
  44. 根据权利要求43所述的方法,其特征在于,所述解码所述第二类待解码数据段,得到残差,包括:
    通过所述待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各所述第二类待解码数据段,得到残差。
  45. 根据权利要求44所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各所述第二类待解码数据段,得到残差,包括:
    从所述数据特征标志位之后,依次读取第二预设数量的数值,得到每个所述第二类待解码数据段的残差特征标志位的数值;
    分别对每个所述残差特征标志位的数值进行解析,确定每个所述第二类待解码数据段对应的残差解码方式。
  46. 根据权利要求45所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各所述第二类待解码数据段,得到残差,还包括:
    当所述残差特征标志位的数值为第三预设数值时,解码对应的第二类待解码数据段,得到一个残差,并确定该第二类待解码数据段的残差均等于所述一个残差。
  47. 根据权利要求45所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各所述第二类待解码数据段,得到残差,还包括:
    当所述残差特征标志位的数值为第四预设数值时,解码对应的第二类待解码数据段,得到该第二类待解码数据段的每个残差。
  48. 根据权利要求46或47所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,采用对应的残差解码方式分别解码各所述第二类待解码数据段,得到残差,还包括:
    根据所述第二类待解码数据段中数值长度标志位的数值确定所述第二类待解码数据段中的残差编码位长;
    根据所述残差编码位长从所述第二类待解码数据段中读取残差编码并进行解码。
  49. 根据权利要求43所述的方法,其特征在于,所述对所述残差进行残差的逆运算,包括:
    将所述第二类待解码数据段中第一个残差与前一待解码数据段所对应原始数据块中的最后一个数据求和,得到所述第二类待解码数据段对应的原始数据块中的第一个数据;或者
    将所述第二类待解码数据段中第一个残差与预设基准数据求和,得到所述第二类待解码数据段对应的原始数据块中的第一个数据。
  50. 根据权利要求49所述的方法,其特征在于,所述预设基准数据为所述原始数据的数值范围的中值。
  51. 根据权利要求43所述的方法,其特征在于,所述对所述残差进行残差的逆运算,包括:
    将所述第二类待解码数据段中除第一个残差外的每个残差,逐个进行残差的逆运算,得到所述第二类待解码数据段对应的原始数据块;或者
    将所述第二类待解码数据段中除第一个残差外的每个残差,分别与所述第二类待解码数据段对应的原始数据块中的第一个数据求和,得到所述第二类待解码数据段对应的原始数据块。
  52. 根据权利要求43所述的方法,其特征在于,所述待解码数据为多组待解码数据中的一组,每组所述待解码数据均包括多个待解码数据段;
    所述对所述残差进行残差的逆运算,得到所述第二类待解码数据段对应的所述数据块,包括:
    以每M组所述待解码数据为一个残差解码数据组,对所述残差解码数据组中的残差进行残差的逆运算,得到所述残差解码数据组中每个所述第二类待解码数据段对应的所述数据块;M为大于或等于2的正整数。
  53. 根据权利要求38所述的方法,其特征在于,所述待解码数据为多组待解码数据中的一组,每组所述待解码数据对应的原始数据为原始图像中的一个子图像;
    所述合并各所述原始数据块,得到所述待解码数据对应的原始数据,包括:
    合并每组所述待解码数据对应的原始数据中的各所述原始数据块,得到每组所述待解码数据对应的所述子图像;
    按照所述原始图像的尺寸排列各所述子图像,得到所述原始图像。
  54. 根据权利要求53所述的方法,其特征在于,所述原始图像的尺寸,通过以下方式确定:
    根据所述待解码数据中尺寸标志位的数值确定所述原始图像的尺寸。
  55. 根据权利要求38至54中任一项所述的方法,其特征在于,所述待解码数据包括两个所述待解码数据段。
  56. 根据权利要求38至54中任一项所述的方法,其特征在于,各所述原始数据块具有相同数量的数据。
  57. 一种数据解码方法,其特征在于,包括:
    对待解码数据中每个待解码数据段中的数据进行解码,得到每个所述待解码数据段的残差;其中,所述待解码数据包括多个所述待解码数据段,每个所述待解码数据段对应于由至少三个原始数据所形成的一个原始数据块;
    根据每个所述待解码数据段的第一个残差,确定每个所述待解码数据段对应的原始数据块中的第一个数据;
    将每个所述待解码数据段中除第一个残差外的每个残差,分别与所述待解码数据段对应的原始数据块中的第一个数据求和,得到每个所述待解码数据段对应的原始数据块;
    合并各所述原始数据块,得到所述待解码数据对应的原始数据。
  58. 根据权利要求57所述的方法,其特征在于,所述根据每个所述待解码数据段的第一个残差,确定每个所述待解码数据段对应的原始数据块中的第一个数据,包括:
    将每个所述待解码数据段中第一个残差与前一待解码数据段所对应原始数据块中的最后一个数据求和,得到每个所述待解码数据段对应的原始数据块中的第一个数据;或者
    将每个所述待解码数据段中第一个残差与预设基准数据求和,得到每个所述待解码数据段对应的原始数据块中的第一个数据。
  59. 根据权利要求58所述的方法,其特征在于,所述预设基准数据为所述原始数据的数值范围的中值。
  60. 根据权利要求57所述的方法,其特征在于,所述对待解码数据中每个待解码数据段中的数据进行解码,得到每个所述待解码数据段中的残差,包括:
    通过所述待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各所述待解码数据段,得到残差。
  61. 根据权利要求60所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各所述待解码数据段,得到残差,包括:
    从所述待解码数据的起始位置依次读取第三预设数量的数值,得到每个所述待解码数据段的残差特征标志位的数值;
    分别对每个所述残差特征标志位的数值进行解析,确定每个所述待解码数据段的残差解码方式。
  62. 根据权利要求61所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各所述待解码数据段,得到 残差,还包括:
    当所述残差特征标志位的数值为第三预设数值时,解码对应的待解码数据段,得到一个残差,确定所述待解码数据段的残差均等于所述一个残差。
  63. 根据权利要求61所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各所述待解码数据段,得到残差,还包括:
    当所述残差特征标志位的数值为第四预设数值时,解码对应的待解码数据段,得到所述待解码数据段的每个残差。
  64. 根据权利要求62或63所述的方法,其特征在于,所述通过所述待解码数据中残差特征标志位的数值,分别采用对应的残差解码方式解码各所述待解码数据段,得到残差,还包括:
    根据所述待解码数据段中数值长度标志位的数值确定所述待解码数据段中的残差编码位长;
    根据所述残差编码位长从所述待解码数据段中读取残差编码并进行解码。
  65. 根据权利要求57所述的方法,其特征在于,所述待解码数据为多组待解码数据中的一组,每组所述待解码数据均包括多个待解码数据段;
    在确定每个所述待解码数据段对应的原始数据块时,以每M组所述待解码数据为一个残差解码数据组,对所述残差解码数据组中的残差进行计算,得到所述残差解码数据组中每个所述待解码数据段对应的原始数据块;M为大于或等于2的正整数。
  66. 根据权利要求57至65中任一项所述的方法,其特征在于,所述待解码数据包括两个所述待解码数据段。
  67. 根据权利要求57至65中任一项所述的方法,其特征在于,各原始数据块具有相同数量的数据。
  68. 一种数据处理方法,其特征在于,应用于依次连接的配置器、存储器和处理器,所述方法包括:
    通过所述配置器执行权利要求1至37中任一项所述的数据编码方法,对预设的待编码数据进行编码,生成码流数据;
    将所生成的码流数据写入所述存储器;
    通过所述配置器读取所述存储器内的至少部分码流数据,并对所读取的码流数据进行解码,以降低对所述存储器的读带宽;
    通过所述处理器运行解码所得到的数据。
  69. 一种编码器,其特征在于,所述编码器通过执行权利要求1至37中任一项所述的数据编码方法,对待编码数据进行编码。
  70. 一种解码器,其特征在于,所述解码器通过执行权利要求38至67中任一项所述的数据解码方法,对待解码数据进行解码。
  71. 一种数据处理系统,其特征在于,包括:依次连接的配置器、存储器和处理器;
    所述配置器用于执行权利要求1至37中任一项所述的数据编码方法,对预设的待编码数据进行编码,生成码流数据,并将所生成的码流数据写入所述存储器,以降低对所述存储器的写带宽;
    所述配置器还用于读取所述存储器内的至少部分码流数据,对所读取的码流数据进行解码,使所述处理器运行解码所得到的数据,以降低对所述存储器的读带宽。
  72. 一种可移动平台,其特征在于,包括:
    机体;
    动力系统,设于所述机体,所述动力系统用于为所述可移动平台提供动力;以及,
    如权利要求71所述的数据处理系统。
  73. 一种计算机可读介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至68中任一项所述的方法。
PCT/CN2020/099495 2020-05-27 2020-06-30 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质 WO2021237870A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
PCT/CN2020/092627 WO2021237513A1 (zh) 2020-05-27 2020-05-27 数据压缩存储的系统、方法、处理器及计算机存储介质
CNPCT/CN2020/092627 2020-05-27
CNPCT/CN2020/092640 2020-05-27
PCT/CN2020/092640 WO2021237518A1 (zh) 2020-05-27 2020-05-27 数据存储的方法、装置、处理器及计算机存储介质

Publications (1)

Publication Number Publication Date
WO2021237870A1 true WO2021237870A1 (zh) 2021-12-02

Family

ID=78745361

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/099495 WO2021237870A1 (zh) 2020-05-27 2020-06-30 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质

Country Status (1)

Country Link
WO (1) WO2021237870A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101516007A (zh) * 2008-02-22 2009-08-26 奇景光电股份有限公司 单一位平面的压缩系统
CN102542969A (zh) * 2010-11-16 2012-07-04 三星电子株式会社 图像数据压缩和解压方法及使用所述方法的显示驱动装置
CN103179389A (zh) * 2011-12-21 2013-06-26 索尼公司 图像处理设备和图像处理方法
CN103368582A (zh) * 2012-04-11 2013-10-23 联咏科技股份有限公司 数据编码及译码方法与装置
CN103974268A (zh) * 2013-01-29 2014-08-06 上海携昌电子科技有限公司 精细粒度可调的低延时传感器网络数据传输方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101516007A (zh) * 2008-02-22 2009-08-26 奇景光电股份有限公司 单一位平面的压缩系统
CN102542969A (zh) * 2010-11-16 2012-07-04 三星电子株式会社 图像数据压缩和解压方法及使用所述方法的显示驱动装置
CN103179389A (zh) * 2011-12-21 2013-06-26 索尼公司 图像处理设备和图像处理方法
CN103368582A (zh) * 2012-04-11 2013-10-23 联咏科技股份有限公司 数据编码及译码方法与装置
CN103974268A (zh) * 2013-01-29 2014-08-06 上海携昌电子科技有限公司 精细粒度可调的低延时传感器网络数据传输方法

Similar Documents

Publication Publication Date Title
CN109087258B (zh) 一种基于深度学习的图像去雨方法及装置
US10430975B2 (en) Advanced k-D tree encoding for point clouds by most significant axis selection
CN107105266A (zh) 一种png图像的解码方法、装置及系统
WO2019216376A1 (ja) 演算処理装置
CN109451317A (zh) 一种基于fpga的图像压缩系统及方法
CN110113615A (zh) 图像编码方法、解码方法、装置、计算设备及存储介质
WO2023197507A1 (zh) 视频数据处理方法、系统、装置及计算机可读存储介质
JPWO2007102518A1 (ja) 算術符号化装置、算術符号化方法、算術符号化プログラム及びプログラムを格納したコンピュータで読み取り可能な記録媒体
WO2021237870A1 (zh) 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质
WO2022073160A1 (zh) 编码方法、解码方法、编码器、解码器以及存储介质
WO2023172703A1 (en) Geometry point cloud coding
WO2022000324A1 (zh) 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质
JP2022508245A (ja) 文脈的区分化および処理のためのブロックベースのピクチャ融合
US6538583B1 (en) Method and apparatus for context modeling
WO2023272432A1 (zh) 图像处理方法和图像处理装置
CN103891272B (zh) 用于视频分析和编码的多个流处理
WO2023028177A1 (en) Attribute coding in geometry point cloud coding
WO2023278829A1 (en) Attribute coding in geometry point cloud coding
US11019366B2 (en) Image compression and decompression using triangulation
US20120263224A1 (en) Encoding digital assets as an image
US11412260B2 (en) Geometric transforms for image compression
CN113902097A (zh) 针对稀疏化cnn神经网络模型的游程编码加速器及方法
WO2021120067A1 (zh) 数据编码方法、数据解码方法、数据处理方法、编码器、解码器、系统、可移动平台与计算机可读介质
CN113222831B (zh) 一种图像条带噪声去除的特征记忆遗忘单元、网络及系统
WO2024074122A1 (en) Method, apparatus, and medium for point cloud coding

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: 20937384

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: 20937384

Country of ref document: EP

Kind code of ref document: A1