Neural network decoding method, device and medium
By decoding and reconstructing the grammatical elements and weight coefficients of the neural network model, it solves the problem of compression and decompression of the neural network model on resource-constrained devices and improves the performance of computer vision and speech recognition applications.
Patent Information
- Application Number
- CN202080035810.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-10-27
- Filing Date
- 2020-11-12
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-11-12
AI Technical Summary
Existing technologies are difficult to effectively compress and decompress neural network models, resulting in processing power and memory limitations on resource-constrained devices (such as mobile devices or smart cameras), affecting the performance of applications such as computer vision and speech recognition.
A method and device are provided to achieve efficient compression and decompression of neural network models by receiving and processing bit streams, decoding syntax elements in neural network models, reconstructing weight coefficients, and optimizing storage and computing resources through partitioning and scanning order.
Improves the storage and computing efficiency of neural network models on resource-constrained devices, reduces memory and processing requirements, and enhances the performance of applications such as computer vision and speech recognition.
Smart Images

Figure CN113853613B_ABST
Abstract
Description
[0001] Incorporation by Reference
[0002] This application claims priority to U.S. Patent Application No. 17 / 081,642, filed on October 27, 2020, for "Method and Apparatus for Neural Network Model Compression / Decompression," which claims priority to U.S. Provisional Patent Application No. 62 / 939,057, filed on November 22, 2019, for "Quantization for Neural Network Model Compression," U.S. Provisional Patent Application No. 62 / 939,054, filed on November 22, 2019, for "Adaptive Partitioning for Neural Network Model Compression," and U.S. Provisional Patent Application No. 62 / 958,697, filed on January 8, 2020, for "High-Level Syntax for Neural Network Model Compression." The entire contents of the prior applications are incorporated herein by reference. Technical Field
[0003] This disclosure describes embodiments related to neural network model compression / decompression. Background Art
[0004] The background description provided herein is intended to present the background of the present application as a whole. The extent to which the work of the presently named inventors described in the background section and various aspects of this specification is performed does not indicate that it is prior art at the time of filing this application, and it is never explicitly or implicitly admitted that it is prior art for this application.
[0005] Various applications in the fields of computer vision, image recognition, and speech recognition rely on neural networks to achieve performance improvements. Neural networks are based on a set of connected nodes (also called neurons) that loosely model multiple neurons in a biological brain. Neurons can be organized into multiple layers. Neurons in one layer are connected to multiple neurons in the previous and next layers. The connection between two neurons, like a synapse in a biological brain, can transmit a signal from one neuron to another. The neuron that receives the signal then processes the signal and can send signals to multiple other connected neurons. In some examples, to find the output of a neuron, the input to the neuron is weighted using the weights of the connections from the input to the neuron, and the weighted inputs are summed to generate a weighted sum. A bias can be added to the weighted sum. In addition, the weighted sum produces an output through an activation function. Summary of the invention
[0006] Various aspects of the present disclosure provide methods and apparatus for neural network model compression / decompression. In some examples, the apparatus for neural network model decompression includes a receiving circuit and a processing circuit. The processing circuit decodes at least one syntax element corresponding to a neural network representation from a bitstream, wherein the at least one syntax element is applied to multiple blocks of the neural network. Then, based on the syntax element, the processing circuit reconstructs weight coefficients of the multiple blocks from the bitstream.
[0007] In some examples, the processing circuit decodes an index from the neural network representation NNR header, wherein the index indicates the size of the coding tree unit CTU. Then, based on the CTU size indicated by the index, the processing circuit divides the weight tensor into multiple CTUs and reconstructs the weight coefficients of the multiple CTUs from the bitstream.
[0008] In some embodiments, the processing circuit decodes a flag from the neural network representation NNR header, wherein the flag indicates whether to change the CTU size based on the kernel size. Then, when the flag indicates that the coding tree unit CTU size can be changed based on the kernel size, the processing circuit updates the CTU size based on the kernel size, divides the weight tensor into multiple CTUs according to the updated CTU size; and reconstructs the weight coefficients of the multiple CTUs from the bitstream.
[0009] In some examples, the processing circuit decodes one or more partition flags from a bitstream, wherein the one or more partition flags indicate a plurality of partitions in a CTU, and then divides the CTU into a plurality of CUs based on the one or more partition flags.
[0010] In some embodiments, the processing circuit determines the bit depth of the quantization weight coefficients in the layer based at least on the syntax element. Then, based on the bit depth, the processing circuit allocates storage space for the quantization weight coefficients; and, using the allocated storage space, decodes the quantization weight coefficients in the layer from the bitstream. In some examples, the processing circuit decodes the global bit depth from the neural network representation NNR header, and decodes the difference between the bit depth and the global bit depth from the layer header of the layer. Then, the processing circuit determines the bit depth of the quantization weight coefficients in the layer based on the global bit depth and the combination of the difference between the bit depth and the global bit depth.
[0011] In some examples, the processing circuit decodes a flag from a layer header, wherein the flag indicates a scanning order of a plurality of blocks in a layer, and decodes a plurality of blocks from the bitstream according to the scanning order.
[0012] In one example, the processing circuit decodes at least one of multiple dimensions in the layer, a shape of the layer, a scanning order of multiple coding units in the layer, a saturation maximum value in the layer, and a quantization step size in the layer from the layer header.
[0013] In some embodiments, when the layer comprises a biasing sublayer and another sublayer, the biasing sublayer of the layer is decoded from the bitstream before decoding the another sublayer of the layer.
[0014] In some examples, the processing circuit decodes a parameter from a header portion in the bitstream, the parameter indicating a total size of the header portion; and, based on the parameter, accesses a portion of the bitstream following the header portion.
[0015] Various aspects of the present disclosure also provide a non-volatile computer-readable medium, wherein the non-volatile computer-readable medium stores instructions, which, when executed by a computer for neural network model decompression, enable the computer to execute the above-mentioned neural network model decompression method. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Other features, properties and various advantages of the disclosed subject matter will become further apparent from the following detailed description and accompanying drawings, in which:
[0017] Figure 1 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0018] Figure 2 An example for performing weight tensor quantization is shown.
[0019] Figure 3 An example of clipping and mapping coefficients to an 8-bit representation according to some embodiments of the present disclosure is shown.
[0020] Figure 4 An example of decoding the absolute value of a quantized weight coefficient according to some embodiments of the present disclosure is shown.
[0021] Figure 5A-5B An example of a syntax table in some embodiments according to the present disclosure is shown.
[0022] Figure 6 A schematic diagram illustrating a routine in the matrix multiplication library is shown.
[0023] Figure 7 A schematic diagram illustrating tensor partitioning according to some embodiments of the present disclosure is shown.
[0024] Figures 8A-8C Syntax examples according to some embodiments of the present disclosure are shown.
[0025] Figures 9A-9B Examples of partitioning and scanning order according to some embodiments of the present disclosure are shown.
[0026] Fig. 10A and Fig. 10B An example syntax table for partitioning according to some embodiments of the present disclosure is shown.
[0027] Fig.11 An example syntax table according to an embodiment of the present disclosure is shown.
[0028] Fig.12 Another example syntax table according to an embodiment of the present disclosure is shown.
[0029] Fig.13 An example syntax according to an embodiment of the present disclosure is shown.
[0030] Fig.14 A flowchart outlining an example of a process according to some embodiments of the present disclosure is shown.
[0031] Fig.15 is a schematic diagram of a computer system according to an embodiment. DETAILED DESCRIPTION
[0032] Various aspects of the present disclosure provide various techniques for neural network model compression / decompression. These techniques include quantization techniques, partitioning techniques, and syntax elements in neural network model compression / decompression.
[0033] Artificial neural networks are applicable to a wide range of tasks in multimedia analysis and processing, media encoding and decoding, data analysis, and many other fields. The success of using artificial neural networks is based on the feasibility of processing much larger and more complex neural networks (deep neural networks, (DNN)) than in the past, and the availability of large-scale training data sets. Therefore, a trained neural network can contain a large number of parameters and weights, resulting in a considerable size (e.g., hundreds of MB). Many applications require the deployment of a specific trained network instance, which may be deployed to a large number of devices, which may have limitations in terms of processing power and memory (e.g., mobile devices or smart cameras) and in terms of communication bandwidth.
[0034] Figure 1 A block diagram of an electronic device 130 according to an embodiment of the present disclosure is shown. The electronic device 130 is configured to execute an application based on a neural network. In some embodiments, the electronic device 130 stores a compressed neural network model, which is also referred to as a representation of a neural network. The electronic device 130 can decompress the compressed neural network model to restore the neural network model, and can execute an application based on the neural network model.
[0035] In some embodiments, the compressed neural network model is provided from a server, such as application server 110. Electronic device 130 may decompress the compressed neural network model to restore the neural network model, and may execute an application based on the neural network model.
[0036] exist Figure 1 In an example, the application server 110 includes a processing circuit 120, a memory 115, and an interface circuit 111 coupled together. In some examples, a neural network is appropriately generated, trained, or updated. The neural network can be stored in the memory 115 as a source neural network model. The processing circuit 120 includes a neural network model codec 121. The neural network model codec 121 includes an encoder that can compress the source neural network model and generate a compressed neural network model as a neural network representation. In some examples, the compressed neural network model is in the form of a bit stream. The compressed neural network model can be stored in the memory 115. The application server 110 can provide the compressed neural network model to other devices, such as the electronic device 130, through the interface circuit 111 in the form of a bit stream.
[0037] It should be noted that the electronic device 130 may be any suitable device, such as a smart phone, a camera, a tablet computer, a laptop computer, a desktop computer, a gaming headset, etc.
[0038] exist Figure 1 In some examples, the electronic device 130 includes a processing circuit 140, a cache memory 150, a main memory 160, and an interface circuit 131 coupled together. In some examples, the electronic device 130 receives the compressed neural network model via the interface circuit 131, for example, in the form of a bit stream. The compressed neural network model is stored in the main memory 160.
[0039] The processing circuit 140 includes any suitable processing hardware, such as central processing units (CPUs), graphics processing units (GPUs), etc. The processing circuit 140 includes appropriate components for executing neural network-based applications, and includes appropriate components configured as a neural network model codec 141. The neural network model codec 141 includes a decoder capable of decoding the compressed neural network model. In one example, the processing circuit 140 includes a single chip on which one or more processors are arranged. In another example, the processing circuit 140 includes multiple chips, and each chip may include one or more processors.
[0040] In some embodiments, the main memory 160 has a large storage space and can store various information, such as software code, media data (e.g., video, audio, image, etc.), compressed neural network models, etc. The cache memory 150 has a smaller storage space, but the access speed is much faster than the main memory 160. In some examples, the main memory 160 may include a hard disk drive, a solid-state drive, etc., and the cache memory 150 may include a static random access memory (Static Random Access Memory, SRAM), etc. In one example, the cache memory 150 may be an on-chip memory arranged on, for example, a processor chip. In another example, the cache memory 150 may be an off-chip memory arranged on one or more memory chips separated from the processor chip. Generally, on-chip memory has a faster access speed than off-chip memory.
[0041] In some embodiments, when the processing circuit 140 executes an application using a neural network model, the neural network model codec 141 can decompress the compressed neural network model to restore the neural network model. In some examples, the cache memory 150 is large enough so that the restored neural network model can be cached in the cache memory 150. The processing circuit 140 can then access the cache memory 150 to use the restored neural network model in the application. In another example, the cache memory 150 has limited storage space (e.g., on-chip memory), and the compressed neural network model can be decompressed layer by layer, or can also be decompressed block by block, and the cache memory 150 can cache the restored neural network model layer by layer or block by block.
[0042] It should be noted that the neural network model codec 121 and the neural network model codec 141 can be implemented by any suitable technology. In some embodiments, the encoder and / or decoder can be implemented by an integrated circuit. In some embodiments, the encoder and decoder can be implemented as one or more processors that execute a program stored in a non-volatile computer-readable medium. The neural network model codec 121 and the neural network model codec 141 can be implemented according to the encoding and decoding features described below.
[0043] Video codec techniques for visual analysis and understanding can be standardized. In one example, the Compact Descriptors for Visual Search (CDVS) standard can include techniques for extracting feature representations from still images for image similarity matching. In another example, the CDVS standard can include techniques for extracting global and local, hand-crafted, and DNN-based feature descriptors of video clips.
[0044] The present disclosure provides a technique for Neural Network Representation (NNR), which can be used to encode and decode neural network models (e.g., Deep Neural Network (DNN) models) to save storage and computation. Deep neural networks (DNNs) can be used in a wide range of video applications, such as semantic classification, object detection / recognition, object tracking, video quality enhancement, etc.
[0045] (Artificial) neural networks generally include multiple layers between the input layer and the output layer. In some examples, a layer in a neural network corresponds to a mathematical operation that transforms the input of the layer into the output of the layer. The mathematical operation can be a linear relationship or a nonlinear relationship. The neural network can move between layers to calculate the probability of each output. Each mathematical operation is considered as a layer, and complex DNNs can have many layers. In some examples, the mathematical operation of a layer can be represented by a weight tensor with weight coefficients and biases.
[0046] Various techniques can be used in the encoding / decoding of neural network models, such as scanning order technology, quantization technology, entropy encoding and decoding technology, etc.
[0047] In some examples of the scan order technique, the dimension of the weight tensor is greater than two (e.g., four in a convolutional layer), and the weight tensor can be reshaped into a two-dimensional tensor. In one example, if the dimension of the weight tensor is not greater than two (e.g., a fully connected layer or a bias layer), no reshaping is performed.
[0048] To encode the weight tensor, the weight coefficients in the weight tensor are scanned according to a specific order. In some examples, the weight coefficients in the weight tensor can be scanned from left to right for each row in a row-first manner, and from the top row to the bottom row for multiple rows.
[0049] Figure 2 An example of syntax for scanning weight coefficients and performing quantization of weight tensors is shown.
[0050] In some related examples, when the dimension of the weight tensor is greater than two, the weight tensor is reshaped into a two-dimensional weight tensor. The weight coefficients in the two-dimensional weight tensor can be scanned from left to right for each row in a row-first manner, and from the top row to the bottom row for multiple rows.
[0051] In order to quantize the weight coefficients, in some examples, fixed step quantization can be applied. In some examples, the distribution of weight coefficients in a layer of a neural network follows a Gaussian distribution, and the percentage of weight coefficients with larger values is very small, but the maximum value of the weight coefficient can be very large. In some embodiments, the encoder can determine the bit depth (expressed as bitdepth) of the quantized weight coefficients in the layer. The bit depth is the number of bits used to represent the absolute value of the quantized weight coefficient, for example, 7 bits. The encoder can then use an optimization algorithm based on, for example, the Kullback–Leibler divergence measure to determine the optimal saturated maximum value for the bit depth. When a weight coefficient is outside a range defined based on the saturated maximum value, the weight coefficient is clipped to the saturated maximum value. The weight coefficients of the layer can then be uniformly quantized to [-(2 bitdepth -1),2 bitdepth -1] range. For example, nearest neighbor (integer) quantization can be applied to each weight coefficient in a uniform manner. Specifically, the weight coefficient is quantized to the nearest integer in the range. The nearest integer (also referred to as quantized weight coefficient, quantized weight level, etc.) can be appropriately encoded.
[0052] Figure 3 An example of limiting and mapping coefficients to 7-bit absolute value representation according to some embodiments of the present disclosure is shown. In some examples, the encoder determines that a total of 8 bits are used to represent the quantized weight coefficient, so 7 bits can be used for the absolute value of the quantized weight coefficient, and the bit depth is 7. The encoder then determines the optimal saturation maximum value T (also expressed as layer_sat_maxw) based on the optimization algorithm. When the weight coefficient is outside the range of [-|T|,|T|], the weight coefficient is limited to -|T| or |T| depending on which is closer. For example, the two weight coefficients (301) and (302) are outside the range of [-|T|,|T|] and are closer to -|T|, so the two weight coefficients (301) and (302) are limited to -|T|. The weight coefficients are then uniformly quantized to integers in the range of [-127,127]. For example, the two weight coefficients (301) and (302) are quantized to -127.
[0053] In an embodiment, the saturation maximum value T may be represented by a 32-bit floating point number, and the encoder may include the saturation maximum value T in the bitstream, for example, in the layer header. In another embodiment, the saturation maximum value T may be converted to an integer while maintaining N decimal places of precision. For example, int_layer_sat_maxw=int(ceil(layer_sat_maxw×(2 N )))Calculate an integer (int_layer_sat_maxw) of the saturation maximum value T. In an example, the encoder includes int_layer_sat_maxw in the bitstream, such as in a layer header; and the decoder can use rec_layer_sat_maxw=(float)int_layer_sat_maxw / (2 N ), reconstruct the saturation maximum value (rec_layer_sat_maxw).
[0054] In another embodiment, the step size (denoted by stepsize) is appropriately determined and included in the bitstream, wherein the saturation maximum value is not included in the bitstream. For example, the step size is calculated as stepsize = layer_sat_maxw / (2 bitdepth -1). In the example, the step size is defined as a 32-bit floating point number, and the step size is encoded in the bitstream. Therefore, when the decoder decodes the step size and the integer corresponding to the weight coefficient from the bitstream, the decoder can reconstruct the weight coefficient as the product of the integer and the step size.
[0055] To encode the quantized weight coefficients, entropy coding techniques may be used. In some embodiments, the absolute values of the quantized weight coefficients are encoded in a sequence, which includes a unary sequence, which may be followed by a fixed length sequence.
[0056] In some examples, the distribution of weight coefficients in the layer generally follows a Gaussian distribution, and the percentage of weight coefficients with larger values is very small, but the maximum value of the weight coefficient can be very large. In some embodiments, very small values can be encoded using unary coding, and larger values can be encoded based on Golomb coding. For example, when Golomb coding is not used, an integer parameter called maxNumNoRem is used to represent the maximum number. When the quantized weight coefficient is not greater than (e.g., equal to or less than) maxNumNoRem, the quantized weight coefficient can be encoded by unary coding. When the quantized weight coefficient is greater than maxNumNoRem, a portion of the quantized weight coefficient equal to maxNumNoRem is encoded by unary coding, and the remainder of the quantized weight coefficient is encoded by Golomb coding. Therefore, the unary sequence includes a first part and a second part of bits of the unary coding, wherein the second part of bits is used to encode the exponential Golomb remainder bits.
[0057] In some embodiments, the quantized weight coefficients may be encoded through the following two steps.
[0058] In the first step, a binary syntax element sig_flag is encoded for the quantized weight coefficient. The binary syntax element sig_flag specifies whether the quantized weight coefficient is equal to zero. If sig_flag is equal to 1 (indicating that the quantized weight coefficient is not equal to zero), a binary syntax element sign_flag is further encoded. The binary syntax element sign_flag indicates whether the quantized weight coefficient is positive or negative.
[0059] In a second step, the absolute value of the quantized weight coefficient may be encoded into a sequence comprising a unary sequence, which may be followed by a fixed length sequence. When the absolute value of the quantized weight coefficient is equal to or less than maxNumNoRem, the sequence comprises a unary encoding of the absolute value of the quantized weight coefficient. When the absolute value of the quantized weight coefficient is greater than maxNumNoRem, the unary sequence may comprise a first portion encoding maxNumNoRem using a unary encoding, and a second portion encoding the exponential Golomb remainder bits, and the fixed length sequence is used to encode the fixed length remainder.
[0060] In some examples, unary coding is applied first. For example, a variable such as j is initialized to 0, and another variable X is set to j + 1. The syntax element abs_level_greater_X is encoded. In the example, when the absolute value of the quantized weight level is greater than the variable X, abs_level_greater_X is set to 1, and unary coding continues; otherwise, abs_level_greater_X is set to 0, and unary coding is completed. When abs_level_greater_X is equal to 1 and the variable j is less than maxNumNoRem, the variable j is incremented by 1, and the variable X is also incremented by 1. Then, another syntax element abs_level_greater_X is encoded. This process continues until abs_level_greater_X is equal to 0 or the variable j is equal to maxNumNoRem. When the variable j is equal to maxNumNoRem, the encoded bits are the first part of the unary sequence.
[0061] When abs_level_greater_X is equal to 1 and j is equal to maxNumNoRem, the encoding continues using Golomb coding. Specifically, the variable j is reset to 0, and X is set to 1 << j. The absolute value of the result of subtracting maxNumNoRem from the absolute value of the quantized weight coefficient can be used as the unary coding reminder. The syntax element abs_level_greater_than X is encoded. In the example, when the unary coding reminder is greater than the variable X, abs_level_greater_X is set to 1; otherwise, abs_level_greater_X is set to 0. If abs_level_greater_X is equal to 1, the variable j is incremented by 1, 1 << j is added to X, and another abs_level_greater_X is encoded. This process continues until abs_level_greater_X is equal to 0, thereby encoding the second part of the unary sequence. When abs_level_greater_X is equal to 0, the unary coding reminder can be one of the values (X, X - 1,... X – (1 << j)+1). A code of length j can be used to encode an index that points to one of the values in (X, X - 1,... X – (1 << j)+1), and this code can be referred to as a fixed-length reminder.
[0062] Figure 4 Examples for decoding the absolute value of a quantized weight coefficient according to some embodiments of the present disclosure are shown. In Figure 4In the example, QuantWeight[i] represents the quantized weight coefficient at the i-th position in the array; sig_flag indicates whether the quantized weight coefficient QuantWeight[i] is non-zero (for example, sig_flag is 0 to indicate that QuantWeight[i] is zero); sign_flag indicates whether the quantized weight coefficient QuantWeight[i] is positive or negative (for example, sign_flag is 1 to indicate that QuantWeight[i] is negative); abs_level_greater_x[j] indicates whether the absolute level of QuantWeight[i] is greater than j+1 (for example, the first part of the unary sequence); abs_level_greater_x2[j] includes the unary part of the exponential Golomb remainder (for example, the second part of the unary sequence); and abs_remainder indicates a fixed-length remainder.
[0063] According to one aspect of the present disclosure, a context modeling approach may be used in the encoding of the three flags sig_flag, sign_flag, and abs_level_greater_X. Thus, flags with similar statistical behaviors may be associated with the same context model, so that the probability estimator (inside the context model) may adapt to the underlying statistics.
[0064] In one example, the context modeling method uses three context models for sig_flag, depending on whether the weight coefficient of the neighboring quantization on the left is zero, less than zero, or greater than zero.
[0065] In another example, the context modeling method uses three other context models for sign_flag, depending on whether the left neighboring quantized weight coefficient is zero, less than zero, or greater than zero.
[0066] In another example, for each abs_level_greater_X flag in multiple abs_level_greater_X flags, the context modeling method uses one or two separate context models. In an example, when X<=maxNumNoRem, two context models are used according to sign_flag. When X>maxNumNoRem, in an example, only one context model is used.
[0067] Some aspects of the present disclosure provide further techniques for quantization. In some examples, the step size is defined as a 32-bit floating point number, and the decoder has no information about the maximum bit depth of the quantized weight coefficients in a layer before completing the decoding of the quantized weight coefficients of the layer. In some examples, the decoder may need to allocate memory for quantized weight coefficients with the maximum possible bit depth (such as 32 bits), which may waste memory usage and may reduce the speed of inference operations when the maximum bit depth of the layer is much less than 32 bits.
[0068] Aspects of the present disclosure provide techniques for providing bit depth information in a bitstream. Therefore, before the decoding of the quantized weight coefficients of the layer is completed, the decoder knows the bit depth information. The decoder can allocate storage space based on the bit depth information to store the quantized weight coefficients. Therefore, the storage space can be used more efficiently.
[0069] In one embodiment, the bit depth of the quantized weight coefficients is included in the layer header. The bit depth may be encoded using variable length coding, or fixed length coding.
[0070] Figure 5A An example of a syntax table (510) in a layer header according to an embodiment of the present disclosure is shown. The syntax table (510) includes a step size (layer_stepsize) and a bit depth (layer_bitdepth) in a layer, which are used to quantize and dequantize the weight coefficients in the layer. In some examples, based on the bit depth, the decoder can allocate storage space for storing decoded quantized weight coefficients. In addition, after decoding the quantized weight coefficients, the decoder can reconstruct the weight coefficients based on the step size and the quantized weight coefficients, such as the multiplication of the step size and the quantized weight coefficients.
[0071] In another embodiment, the bit depth and saturation maximum value of the quantized weight coefficients may be included in the layer header.
[0072] Figure 5B Another example of a syntax table (520) in a layer header according to an embodiment of the present disclosure is shown. The syntax table (520) includes a bit depth (layer_bitdepth) and a saturation maximum value (layer_sat_maxw) of a layer, which can be used for quantization and dequantization of weight coefficients in the layer. In some examples, based on the bit depth, the decoder can allocate storage space for storing decoded quantized weight coefficients. In addition, based on the bit depth and the saturation maximum value, the decoder can determine a step size. Then, after decoding the quantized weight coefficients, the decoder can reconstruct the weight coefficients based on the step size and the quantized weight coefficients, such as the multiplication of the step size and the quantized weight coefficients.
[0073] It should be noted that the saturation maximum value can be represented by a floating point number or an integer. If the saturation maximum value is represented as an integer, the saturation maximum value can be encoded using a variable length coding or a fixed length coding method.
[0074] According to some aspects of the present disclosure, on-chip memory can have a relatively high access speed compared to off-chip memory, and on-chip memory is more suitable for matrix multiplication. However, on-chip memory is relatively small. In some embodiments, block matrix multiplication can be used. The matrix can be divided into blocks for block-based multiplication. In some examples, for the multiplication of two blocks, when the on-chip memory allocates enough space for caching two blocks and the results, the multiplication of the two blocks can be performed based on access to the on-chip memory. Various aspects of the present disclosure provide a technique for partitioning a weight tensor into blocks and providing partition information in a bitstream. Therefore, the decoder can determine the partition information from the bitstream and decode the weight coefficients block by block.
[0075] For example, the reasoning operation of the deep learning system widely uses matrix multiplication. In some embodiments, the general matrix multiplication (GEMM) library can be used to perform matrix multiplication. The GEMM library includes various routines for partitioning matrices and performing partitioned matrix multiplication. In some examples, two GEMM routines (GEPP / GEBP, GEPM / GEBP) can be used depending on the size of the left-hand-side (lhs) matrix and the right-hand-side (rhs) matrix in the matrix multiplication.
[0076] Figure 6 Schematics illustrating the GEPP / GEBP routine and the GEPM / GEBP routine are shown. The two GEMM routines recursively partition the lhs matrix and the rhs matrix to best utilize the different characteristics of off-chip memory (e.g., DDR) and on-chip memory (e.g., multi-level cache) in modern computing platforms. In some examples, the lhs matrix is preferably stored in column-major order to achieve optimal memory access patterns.
[0077] In some related examples, the matrix scanning order is defined as row-first, i.e., for a single row, scan from left to right, and for multiple rows, scan from top to bottom. This scanning order does not match the preferred memory access pattern required for the inference operation, so for the inference operation, the weight coefficients are over-buffered before the inference operation starts. For example, when performing an inference operation for a fully connected layer, assuming that the matrix size of the fully connected layer is 25088x4096, a buffer capable of storing Nx25088 weight coefficients must be reserved in order to execute the GEMM routine. If N=64 for a conventional GEMM operation, the buffer size will be 1.5MB, even though the coefficients are represented by 8-bit integers instead of 32-bit floating point numbers, which is too large, especially for mobile and edge devices.
[0078] According to some aspects of the present disclosure, an lhs tensor (e.g., a weight tensor) may be partitioned into multiple 3D coding tree units (CTU3Ds or CTUs for short). Each CTU3D may be partitioned into multiple 3D coding units (CU3Ds, or CUs for short). The scanning order of multiple CTU3Ds is referred to as the CTU3D scanning order, the scanning order of multiple CU3Ds in the CTU3D is referred to as the CU3D scanning order, and the scanning order of multiple weight coefficients in the CU3D is referred to as the scanning order within the CU3D. In some examples, information about partitions and scanning order may be included in headers at various levels, such as an NNR header, a layer header, and the like. It should also be noted that in some examples, information about partitions and scanning order may be predefined or inferred. It should be noted that the term "block" in the present disclosure may be interpreted as CTU3D or CU3D, and the like.
[0079] In some embodiments, the weight tensor may include more than two dimensions. For example, the lhs tensor includes weight coefficients, which may be stored in column-major order. In another example, the lhs tensor is stored in the form of rows as the main tensor, and the lhs tensor may be obtained by transposing the rows as the main tensor. In some examples, for convolutional layers (sublayers in some examples) with a layout of [R][S][C][K], the dimension of the weight tensor may be 4. For fully connected layers (sublayers in some examples) with a layout of [C][K], the dimension of the weight tensor may be 2. For bias layers (sublayers in some examples) and batch normalization layers (sublayers in some examples), the dimension of the weight tensor may be 1. R and S represent the convolution kernel size, C is the input feature size, and K is the output feature size.
[0080] In the example of a convolutional layer, the 2D kernel 2D[R][S] can be reshaped into a 1D kernel 1D[RS] (the size of the 1D is equal to R×S), so the 4D tensor 4D[R][S][C][K] can be reshaped into a 3D tensor 3D[RS][C][K]. A fully connected layer can be a special case of a 3D tensor with R=S=1.
[0081] In general, the kernel size RS is typically much smaller than the input feature size C and the output feature size K. According to one aspect of the present disclosure, the 3D tensor [RS][C][K] can be divided into non-overlapping smaller blocks along the [C][K] plane, which are referred to as 3D coding tree units (CTU3D). The shape of each CTU3D is [RS][ctu3d_height][ctu3d_width]. In some examples, max_ctu3d_height represents the conventional height of the CTU, and max_ctu3d_width represents the conventional width of the CTU3D. In an example, max_ctu3d_height / max_ctu3d_width can be encoded in the bitstream (e.g., NNR header). Therefore, for a conventional CTU3D [RS][ctu3d_height][ctu3d_width], ctu3d_height is equal to max_ctu3d_height, and ctu3d_width is equal to max_ctu3d_width. It should be noted that the size of the CTU3D located to the right and / or bottom of the tensor may be smaller. For example, the height ctu3d_height of the CTU3D located at the bottom of the tensor may be the remainder of C / max_ctu3d_height, and the width ctu3d_width of the CTU3D located at the right of the tensor may be the remainder of K / max_ctu3d_width.
[0082] Figure 7 A schematic diagram illustrating tensor partitioning according to some embodiments of the present disclosure is shown. Along the [C][K] plane, the tensor (700) is divided into multiple CTU3Ds. The shape of a conventional CTU3D is [RS][H][W], where H represents the height of the CTU3D (ctu3d_height), and W represents the width of the CTU3D (ctu3d_width).
[0083] In some embodiments, the 3D tensor [RS][C][K] may be divided into a plurality of CTU3Ds having a square shape in the [C][K] plane. In such embodiments, max_ctu3d_height is equal to max_ctu3d_width. In some examples, a variable max_ctu3d_size is used to represent max_ctu3d_height and max_ctu3d_width. In some examples, max_ctu3d_size is defined as 2**N (2 to the power of N, 2 N ), and N can be 8, 16, 32, 64, etc. In one example, the max_ctu3d_size information can be encoded in the bitstream (e.g., NNR header).
[0084] In some examples, to facilitate on-chip memory requirements in inference operations, a flag is used to indicate whether the CTU3D size of multiple layers needs to be constrained to different kernel sizes. For example, when the flag is equal to 0, ctu3d_height / ctu3d_width can remain unchanged regardless of the kernel size. In this case, the size of the CTU3D of the convolutional layer is RS (R×S) times the size of the CTU3D of the fully connected layer. In another example, when the flag is equal to 1, ctu3d_height / ctu3d_width can be scaled based on the kernel size. For example, the width and height product of the CTU3D is scaled down by R×S.
[0085] It should be noted that the multiple CTU3Ds in the tensor may be scanned by any suitable CTU3D scan order. In some examples, the multiple CTU3Ds in the tensor may be scanned in a raster scan order (SCAN_CK) in the horizontal direction. In some examples, the multiple CTU3Ds in the tensor may be scanned in a raster scan order (SCAN_KC) in the vertical direction. In some embodiments, the CTU3D scan order information may be included in a header (e.g., a layer header, etc.).
[0086] Figures 8A-8C A syntax example according to an embodiment of the present disclosure is shown. Fig. 8A An example of a syntax representation of NNR is shown. Figure 8B An example of the syntax of the NNR header is shown. Figure 8C An example of the syntax of the layer header is shown.
[0087] In the NNR header, enable_max_ctu3d_size is used to indicate whether to change the size of CTU3D according to the kernel size. In an example, when enable_max_ctu3d_size is 0, CTU3D size parameters such as ctu3d_height, ctu3d_width, etc. remain unchanged regardless of the kernel size. When enable_max_ctu3d_size is 1, CTU3D size parameters such as ctu3d_height, ctu3d_width, etc. are scaled according to the kernel size, such as Fig. 8A As shown in (801) and (802) in .
[0088] In the layer header, layer_scan_order is used to indicate the CTU 3D scan order. In one example, when layer_scan_order is equal to 0, a horizontal raster scan order may be used. When layer_scan_order is equal to 1, a vertical raster scan order may be used.
[0089] According to one aspect of the present disclosure, each CTU3D may be further divided, for example, along the [C][K] plane, to divide each CTU3D into multiple CU3Ds. In some embodiments, adaptive partitioning may be used to divide a CTU3D into multiple CU3Ds.
[0090] In some embodiments, quadtree partitioning can be used recursively. Each quadtree partitioning can divide a larger block into four smaller blocks of the same shape as the larger block. The larger block can be called a parent node in the partition tree structure, and the four smaller blocks can be called child nodes of the parent node. In some examples, CTU3D / CU3D can be recursively partitioned based on quadtree partitioning until the maximum recursive depth is reached. Starting from the CTU3D node, a depth-first quadtree scan order can be used to scan and process the quadtrees of multiple CU3Ds. Multiple child nodes under the same parent node are scanned and processed using a raster scan order in the horizontal or vertical direction.
[0091] In some embodiments, for a CU3D of a given quadtree depth, max_cu3d_height / max_cu3d_width of multiple CU3Ds can be calculated using (Equation 1) and (Equation 2), and the maximum recursion depth is reached when both max_cu3d_height and max_cu3d_width are less than or equal to a predefined threshold. This predefined threshold can be explicitly included in the bitstream or can be a predefined number (e.g., 8) that the decoder can implicitly infer.
[0092] max_cu3d_height = max_ctu3d_height >> depth (Equation 1)
[0093] max_cu3d_width=max_ctu3d_width>>depth (Equation 2)
[0094] In some examples, square partitioning is used so that max_ctu3d_height = max_ctu3d_width. For CU3Ds of a given quadtree depth, the max_cu3d_size of these CU3Ds is calculated using (Equation 3). The maximum recursion depth is reached when max_cu3d_size is less than or equal to a predefined threshold. The threshold can be explicitly included in the bitstream or can be a predefined number (e.g., 8) that is implicitly inferred by the decoder.
[0095] max_cu3d_size = max_ctu3d_size >> depth (Equation 3)
[0096] Fig.9A An example of CTU3D partitioning and CU3D scanning order according to some embodiments of the present disclosure is shown. Fig.9A In the example of , CTU3D (910) has a square shape in the [C] [K] plane, and CTU3D (910) is divided into 16 CU3Ds from the [C] [K] plane, as shown in block-1 to block-16. The quadtree depth of block-8 and block-9 is 1. The quadtree depth of block-1, block-6, block-7, block-10, block-11, and block-16 is 2. The quadtree depth of block-2 to block-5 and block-12 to block-15 is 3. When scanning a plurality of CU3Ds using a vertical raster scan, the scanning order of the plurality of CU3Ds is block-1, block-2, block-3, block-4, block-5, block-6, block-7, block-8, block-9, block-10, block-11, block-12, block-13, block-14, block-15, and block-16.
[0097] Fig. 9B An example of CTU3D partitioning and CU3D scanning order according to some embodiments of the present disclosure is shown. Fig. 9BIn the example, CTU3D(920) can be the edge CTU on the right side of the tensor. In some examples, as shown in the figure, CTU3D(920) is divided into 14 CU3Ds, block - 1 to block - 14. The quadtree depth of block - 8 and block - 9 is 1. The quadtree depth of block - 1, block - 6, block - 7, block - 10, block - 11, and block - 14 is 2. The quadtree depth of block - 2 to block - 5 and block - 12 to block - 13 is 3. When scanning multiple CU3Ds using raster scanning in the vertical direction, the scanning order of the multiple CU3Ds is block - 1, block - 2, block - 3, block - 4, block - 5, block - 6, block - 7, block - 8, block - 9, block - 10, block - 11, block - 12, block - 13, and block - 14.
[0098] As Fig. 9B shown, for CTU3Ds located on the right side and / or bottom of the tensor, the parent CU3D node at a given depth may not have all 4 child nodes. For CU3Ds located on the right side and / or bottom of the tensor, cu3d_height can be the remainder of max_ctu3d_height / max_cu3d_height, and cu3d_width can be the remainder of max_ctu3d_width / max_cu3d_width.
[0099] According to one aspect of the present disclosure, a rate - distortion (RD) - based coding algorithm can be used to determine whether a parent CU3D needs to be split into multiple smaller child CU3Ds. In one example, when the combined rate - distortion of the smaller multiple child CU3Ds is less than the rate - distortion of the parent CU3D, the parent CU3D is split into multiple smaller child CU3Ds; otherwise, the parent CU3D does not need to be split. In some embodiments, a split flag can be used to record the splitting decision at the encoder and can be included in the bitstream to notify the decoder of the splitting decision.
[0100] Fig. 10A And Fig. 10B shows an exemplary syntax table for splitting CTU3D into multiple CU3Ds according to some embodiments of the present disclosure. For a CU3D, the quadtree depth is compared with a threshold (ctu3d_depth), and when the quadtree depth meets the condition (e.g., depth < ctu3d_depth - 1), a flag (split_flag) is retrieved from the bitstream. This flag is used to indicate whether the CU3D is the parent CU3D that is split into 4 smaller child CU3Ds. For example, when split_flag is 1, the CU3D is split into four smaller CU3Ds.
[0101] Aspects of the present disclosure provide techniques for using syntax at various levels to ensure correct encoding and decoding of neural network models. In some examples, syntax elements that describe the structure of a bitstream or provide information applicable to multiple layers, multiple blocks (e.g., multiple coding units, multiple CTU3Ds, multiple CU3Ds, etc.) are referred to as high-level syntax.
[0102] According to one aspect of the present disclosure, an NNR header size parameter nnr_header_size may be defined and included in the NNR header. The nnr_header size may be used to ensure random access to one or more coding layers. Note that the nnr_header_size may be placed anywhere in the NNR header. In some examples, the nnr_header_size is the first syntax element in the NNR header.
[0103] In some embodiments, the NNR header may include global bit depth information, for example, using parameters max_ndim_bitdepth and max_1dim_bitdepth. The parameter max_ndim_bitdepth is defined as the maximum quantization bit depth between layers of non-one-dimensional (1D) arrays. The parameter max_1dim_bitdepth is defined as the maximum quantization bit depth of multiple one-dimensional array layers. The parameters max_ndim_bitdepth and max_1dim_bitdepth are used to guide the decoder to allocate appropriate memory for multiple decoded quantization layers.
[0104] Fig.11 An exemplary syntax table for an NNR header according to an embodiment of the present disclosure is shown. The NNR header includes syntax elements.
[0105] Specifically, in Fig.11In the example of , the syntax element nnr_header_size can be a parameter carrying information about the total number of bytes of nnr_header, including nnr_header_size itself. The syntax element total_layer can be a parameter carrying information about the total number of layers in NNR. The syntax element enable_zdep_reorder is a flag used to indicate whether the reordering algorithm (zdep reordering algorithm) is enabled. For example, when enable_zdep_reorder is equal to 0, the reordering algorithm is not allowed. When enable_zdep_reorder is equal to 1, the reordering algorithm is allowed. The syntax element enable_max_ctu3d_size is a flag used to indicate whether the size of CTU3D can be changed according to the kernel size. For example, when enable_max_ctu3d_size is equal to 0, the size parameters of CTU3D, such as ctu3d_height, ctu3d_width, etc., remain unchanged regardless of the kernel size. When enable_max_ctu3d_size is equal to 1, the size parameters of CTU3D, such as ctu3d_height, ctu3d_width, etc., can be scaled according to the kernel size. The syntax element max_ctu3d_idx may be a parameter carrying CTU3D size information. In one example, the size parameter max_ctu_3d_size of CTU3D may be determined based on (Equation 4).
[0106] max_ctu_3d_size=
[0107] (max_ctu3d_idx==0)?64:(max_ctu3d_idx==1)?32:(max_ctu3d_idx==2)?16:8 (Equation 4)
[0108] Therefore, when max_ctu3d_idx is equal to 0, max_ctu_3d_size may be set to 64. When max_ctu3d_idx is equal to 1, max_ctu_3d_size may be set to 32. When max_ctu3d_idx is equal to 2, max_ctu_3d_size may be set to 16. And, when max_ctu3d_idx is not any of 0, 1, 2, max_ctu_3d_size may be set to 8.
[0109] Further, the syntax element max_ndim_bitdepth may be a parameter (global parameter) that carries information about the maximum quantization bit depth between layers of non-one-dimensional (1D) arrays. The syntax element max_1dim_bitdepth may be a parameter (global parameter) that carries information about the maximum quantization bit depth of multiple layers of one-dimensional arrays.
[0110] According to an aspect of the present disclosure, the layer header may include information of the current layer and sublayers of the current layer.
[0111] Fig.12 An example syntax table of a layer header according to an embodiment of the present disclosure is shown. The layer header includes various syntax elements.
[0112] Specifically, the syntax element layer_size is a parameter used to carry information about the total number of bytes of the coded layer, including the layer_size itself. A layer size parameter layer_size may be defined and included in the layer header to ensure random access to one or more coded layers. The layer size parameter may be placed anywhere in the layer header (outside of the sublayer loop). In some examples, the layer size parameter layer_size is the first syntax element in the layer header.
[0113] In some embodiments, a layer may include multiple sublayers, for example, a bias sublayer, a batch normalization sublayer, etc. Information about multiple sublayers may be included in the layer header. The syntax element total_sublayer is a parameter that carries information about the number of sublayers. The syntax element sublayer_size is a parameter that carries information about the total number of bytes of the coding sublayer. In some examples, a sublayer size parameter sublayer_size may be defined and included in the layer header to ensure random access to the coding sublayer.
[0114] The syntax element sublayer_ndim is a parameter used to carry the dimension information of the current sublayer. The syntax element sublayer_shape[] is a parameter used to carry the shape information of the current sublayer. In one embodiment, the layer header includes multiple sublayer parameters, such as sublayer_ndim, sublayer_shape[ndim], etc. In another embodiment, for example, sublayer_ndim and sublayer_shape[ndim] are not included in the layer header. In this case, the decoder can rely on an external model structure to obtain multiple parameter values.
[0115] The syntax element sublayer_scan_order is a flag used to indicate the CTU3D / CU3D scan order. For example, when sublayer_scan_order is equal to 0, the horizontal raster scan order can be used for the CTU3D scan order and / or the CU3D scan order. When sublayer_scan_order is equal to 1, the vertical raster scan order can be used for the CTU3D scan order and / or the CU3D scan order.
[0116] The syntax element sublayer_sat_maxw is a parameter that carries the saturated maximum value of a multidimensional tensor in a layer. The saturated maximum value can be in integer or floating point format.
[0117] The syntax element sublayer_delta_bitdepth is used to carry the bit depth difference of the sublayer and the global bit depth (eg, max_ldim_bitdepth or max_ndim_bitdepth in the NNR header). In one example, the bit depth of the sublayer may be calculated using (Equation 5).
[0118] sublayer bitdepth=
[0119] ((ndim==1)?max_1dim_bitdepth:max_ndim_bitdepth)-sublayer_delta_bitdepth (Equation 5)
[0120] In one embodiment, all 1D sublayers may share the same bit depth (e.g., have the same max_1dim_bitdepth), and thus, sublayer_delta_bitdepth is not required in the layer header. In another embodiment, each 1D sublayer may have its own bit depth, and thus, sublayer_delta_bitdepth may be included in the layer header.
[0121] According to one aspect of the present disclosure, a layer may include multiple sublayers. In one example, a layer may include a convolutional sublayer and a bias sublayer. In another example, a layer may include a fully connected sublayer and a bias sublayer. In some embodiments, when a layer includes a bias sublayer and another sublayer, the bias sublayer is encoded (encoded / decoded) in the bitstream before encoding the other sublayers. For example, when a layer includes a convolutional sublayer and a bias sublayer, the bias sublayer is encoded and decoded before the convolutional sublayer. In another example, when a layer includes a fully connected sublayer and a bias sublayer, the bias sublayer is encoded (encoded and decoded) in the bitstream before the fully connected sublayer.
[0122] Fig.13 An example syntax according to an embodiment of the present disclosure is shown. As shown in (1310), when the layer includes a bias sublayer and another sublayer, before the other sublayer, for example, a convolutional sublayer (e.g., type is conv), a fully connected sublayer (e.g., type is fc), and a bias sublayer are encoded in the bitstream.
[0123] Fig.14 A flow chart of an overview process (1400) according to an embodiment of the present disclosure is shown. The process (1400) can be used in a device such as an electronic device (130) to decode (decompress) a bit stream corresponding to a neural network representation. The process starts at (S1401) and proceeds to (S1410).
[0124] At (S1410), a bitstream corresponding to the neural network representation is stored in a memory. For example, main memory 160 stores a compressed neural network model as a neural network representation. In some embodiments, the compressed neural network model is transmitted from application server 110 to electronic device 130. When electronic device 130 receives the compressed neural network model, electronic device 130 stores the compressed neural network model in main memory 160.
[0125] At (S1420), syntax elements of a plurality of blocks to be applied to a neural network are decoded from the bitstream.
[0126] At (S1430), weight coefficients of a plurality of blocks are decoded based on the syntax elements.
[0127] In some examples, the syntax element is included in the NNR header. In one example, from the NNR header, an index (e.g., max_ctu3d_idx) indicating a CTU size (e.g., CTU3D size) is decoded. The weight tensor can then be divided into multiple CTUs according to the CTU size indicated by the index. The weight coefficients of the multiple CTUs can then be reconstructed from the bitstream.
[0128] In one example, from the NNR header, a flag (e.g., enable_max_ctu3d_size) indicating whether to change the CTU size based on the kernel size is decoded. When the flag indicates that changing the CTU size based on the kernel size is enabled, the CTU size is updated according to the kernel size. In addition, the weight tensor can be divided into multiple CTUs according to the updated CTU size. Then, the weight coefficient of the CTU can be reconstructed from the bitstream.
[0129] In some embodiments, one or more partition flags indicating multiple partitions in a CTU may be decoded from the bitstream.Then, the CTU is divided into multiple CUs (eg, CU3D) according to the one or more partition flags.
[0130] In some embodiments, the bit depth of the quantization weight coefficients in the layer can be determined based on at least syntax elements (e.g., max_ndim_bitdepth, max_1dim_bitdepth, layer_bitdepth, etc.). Then, based on the bit depth, storage space for the quantization weight coefficients can be allocated. Then, the quantization weight coefficients in the layer can be decoded from the bitstream using the allocated storage space. In some examples, from the NNR header, the global bit depth (e.g., max_ndim_bitdepth, max_1dim_bitdepth, etc.) can be decoded. Then, from the layer header of the layer, the difference between the bit depth and the global bit depth (e.g., sublayer_delta_bitdepth) can be decoded. The bit depth of the quantization weight coefficients in the layer can be determined based on the global bit depth, and a combination of the difference between the bit depth and the global bit depth.
[0131] In some examples, from the layer header, a flag (e.g., sublayer_scan_order) indicating a scanning order of multiple blocks in the layer can be decoded. Then, based on the scanning order, multiple blocks can be decoded from the bitstream. In addition, in some examples, from the layer header, at least one of multiple dimensions in the layer (e.g., sublayer_ndim), the shape of the layer (e.g., sublayer_shape[]), the saturation maximum value in the layer (e.g., layer_sat_maxw), and the quantization step size in the layer (e.g., layer_stepsize) can be decoded from the layer header.
[0132] In some embodiments, when a layer includes a biasing sublayer and another sublayer, the biasing sublayer is encoded in the bitstream before the other sublayer.
[0133] In some embodiments, a parameter can be decoded from the header portion of the bitstream, wherein the parameter indicates the total size of the header portion in the bitstream. The parameter can be used to access (referred to as random access) the portion following the header in the bitstream based on the parameter.
[0134] The above techniques may be implemented as computer software via computer-readable instructions and physically stored in one or more computer-readable media. Fig.15 A computer system (1500) is shown that is suitable for implementing certain embodiments of the disclosed subject matter.
[0135] The computer software may be encoded in any suitable machine code or computer language, and may be assembled, compiled, linked, or the like to create a code comprising instructions, which may be directly executed by one or more computer central processing units (CPUs), graphics processing units (GPUs), etc., or executed by decoding, microcode, or the like.
[0136] The instructions may be executed on various types of computers or components thereof, including, for example, personal computers, tablets, servers, smartphones, gaming devices, IoT devices, etc.
[0137] Fig.15 The components shown for the computer system (1500) are exemplary in nature and are not intended to limit the scope of use or functionality of the computer software implementing the embodiments of the present application. The configuration of the components should not be interpreted as having any dependency or requirement on any component or combination of components shown in the exemplary embodiment of the computer system (1500).
[0138] The computer system (1500) may include certain human-computer interface input devices. Such human-computer interface input devices may respond to input from one or more human users through tactile input (e.g., keyboard input, sliding, data glove movement), audio input (e.g., sound, applause), visual input (e.g., gestures), and olfactory input (not shown). The human-computer interface devices may also be used to capture certain media that are not necessarily directly related to human conscious input, such as audio (e.g., speech, music, ambient sound), images (e.g., scanned images, photographic images obtained from a still image camera), and videos (e.g., two-dimensional video, three-dimensional video including stereoscopic video).
[0139] The human-computer interface input device may include one or more of the following (only one of which is drawn): keyboard (1501), mouse (1502), touchpad (1503), touch screen (1510), data gloves (not shown), joystick (1505), microphone (1506), scanner (1507), camera (1508).
[0140] The computer system (1500) may also include certain human-computer interface output devices. Such human-computer interface output devices may stimulate one or more human user senses through, for example, tactile output, sound, light, and smell / taste. Such human-computer interface output devices may include tactile output devices (e.g., tactile feedback through a touch screen (1510), a data glove (not shown), or a joystick (1505), but there may also be tactile feedback devices that are not used as input devices), audio output devices (e.g., speakers (1509), headphones (not shown)), visual output devices (e.g., screens (1510) including cathode ray tube screens, liquid crystal screens, plasma screens, organic light emitting diode screens, each of which has or does not have a touch screen input function, each of which has or does not have a tactile feedback function - some of which may output two-dimensional visual output or output of more than three dimensions through means such as stereoscopic picture output; virtual reality glasses (not shown), holographic displays, and smoke boxes (not shown)) and printers (not shown).
[0141] The computer system (1500) may also include human-accessible storage devices and their associated media, such as optical media including high-density read-only / rewritable optical disks (CD / DVD ROM / RW) (1520) with CD / DVD or similar media (1521), thumb drives (1522), removable hard disk drives or solid state drives (1523), traditional magnetic media such as tapes and floppy disks (not shown), special-purpose ROM / ASIC / PLD-based devices such as security software protectors (not shown), and the like.
[0142] Those skilled in the art should also understand that the term "computer-readable media" used in connection with the disclosed subject matter does not include transmission media, carrier waves, or other transient signals.
[0143] The computer system (1500) may also include an interface to one or more communication networks. For example, the network may be wireless, wired, or optical. The network may also be a local area network, a wide area network, a metropolitan area network, an in-vehicle network, an industrial network, a real-time network, a delay-tolerant network, and the like. The network also includes local area networks such as Ethernet, wireless local area networks, cellular networks (GSM, 3G, 4G, 5G, LTE, etc.), television wired or wireless wide area digital networks (including cable television, satellite television, and terrestrial broadcast television), in-vehicle and industrial networks (including CANBus), and the like. Some networks typically require an external network interface adapter for connecting to some universal data ports or peripheral buses (1549) (e.g., a USB port of the computer system (1500)); other systems are typically integrated into the core of the computer system (1500) by connecting to a system bus as described below (e.g., an Ethernet interface integrated into a PC computer system or a cellular network interface integrated into a smart phone computer system). By using any of these networks, the computer system (1500) can communicate with other entities. The communication can be one-way, for receiving only (e.g., wireless television), one-way for sending only (e.g., CAN bus to certain CAN bus devices), or two-way, such as to other computer systems via a local or wide area digital network. Each of the above networks and network interfaces can use certain protocols and protocol stacks.
[0144] The above-mentioned human-machine interface devices, human-accessible storage devices, and network interfaces may be connected to the core (1540) of the computer system (1500).
[0145] The core (1540) may include one or more central processing units (CPUs) (1541), graphics processing units (GPUs) (1542), dedicated programmable processing units in the form of field programmable gate arrays (FPGAs) (1543), hardware accelerators for specific tasks (1544), etc. These devices, as well as read-only memory (ROM) (1545), random access memory (1546), internal mass storage (e.g., internal non-user accessible hard disk drives, solid-state drives, etc.) (1547), etc., may be connected via a system bus (1548). In some computer systems, the system bus (1548) may be accessed in the form of one or more physical plugs so that it can be expanded by additional central processing units, graphics processing units, etc. Peripheral devices may be directly attached to the core's system bus (1548), or connected via a peripheral bus (1549). The architecture of the peripheral bus includes PCI, USB, etc.
[0146] The CPU (1541), GPU (1542), FPGA (1543) and accelerator (1544) can execute certain instructions, which can be combined to form the above-mentioned computer code. The computer code can be stored in ROM (1545) or RAM (1546). Transition data can also be stored in RAM (1546), while permanent data can be stored in, for example, internal mass storage (1547). Fast storage and retrieval of any memory device can be achieved by using a cache memory, which can be closely associated with one or more CPUs (1541), GPUs (1542), mass storage (1547), ROM (1545), RAM (1546), etc.
[0147] The computer readable medium may have computer code thereon for performing various computer-implemented operations. The medium and computer code may be specially designed and constructed for the purpose of this application, or may be medium and code well known and available to those skilled in the art of computer software.
[0148] As an example and not a limitation, a computer system having an architecture (1500), in particular a core (1540), can be provided as a processor (including a CPU, a GPU, an FPGA, an accelerator, etc.) to execute software contained in one or more tangible computer-readable media. Such a computer-readable medium can be a medium associated with the above-mentioned user-accessible mass storage, as well as a specific memory of the core (1540) having non-volatility, such as a core internal mass storage (1547) or a ROM (1545). Software implementing various embodiments of the present application can be stored in such a device and executed by the core (1540). Depending on specific needs, the computer-readable medium may include one or more storage devices or chips. The software can enable the core (1540), in particular the processor therein (including a CPU, a GPU, an FPGA, etc.) to perform a specific process or a specific part of a specific process described herein, including defining a data structure stored in the RAM (1546) and modifying such a data structure according to a software-defined process. Additionally or alternatively, the computer system may provide functionality hardwired in logic or otherwise contained in circuitry (e.g., accelerator (1544)) that may operate in place of or in conjunction with software to perform a particular process or a particular portion of a particular process described herein. Where appropriate, references to software may include logic and vice versa. Where appropriate, references to computer-readable media may include circuitry (e.g., an integrated circuit (IC)) storing the executing software, circuitry containing the executing logic, or both. The present application includes any suitable combination of hardware and software.
[0149] Appendix A: Overall Grammar Examples
[0150]
[0151]
[0152]
[0153]
[0154]
[0155]
[0156]
[0157]
[0158]
[0159]
[0160]
[0161]
[0162]
[0163]
[0164] Although the present application has described a number of exemplary embodiments, various changes, arrangements and various equivalent substitutions of the embodiments are within the scope of the present application. Therefore, it should be understood that those skilled in the art can design a variety of systems and methods, which, although not explicitly shown or described herein, embody the principles of the present application and are therefore within the spirit and scope of the present application.
Claims
1. A neural network decoding method, characterized in that: include: decoding at least one syntax element corresponding to a neural network representation from a bitstream, wherein the at least one syntax element applies to a plurality of blocks of the neural network; and, reconstructing weight coefficients of the plurality of blocks from the bitstream according to the syntax elements; Wherein, the method further comprises: decoding a flag from a layer header, wherein the flag indicates a scanning order of a plurality of blocks in the layer; and, The plurality of blocks are decoded from the bitstream according to the scanning order.
2. The method according to claim 1, characterized in that Further including: Decoding a flag from a neural network representation (NNR) header, the flag indicating whether to change a coding tree unit (CTU) size based on a kernel size; When the flag indicates to change the coding tree unit CTU size based on the kernel size, updating the coding tree unit CTU size based on the kernel size; Based on the updated coding tree unit (CTU) size, a weight tensor is divided into a plurality of coding tree units (CTUs); and weight coefficients of the plurality of coding tree units (CTUs) are reconstructed from the bitstream.
3. The method according to claim 1, characterized in that Further including: Decoding an index from a neural network representation (NNR) header of the bitstream, the index indicating a coding tree unit (CTU) size; Based on the size of the coding tree unit CTU indicated by the index, dividing the weight tensor into a plurality of coding tree units CTU; and Weight coefficients of the plurality of coding tree units (CTUs) are reconstructed from the bitstream.
4. The method according to claim 3, characterized in that Further including: Decoding one or more partition flags in the bitstream, wherein the one or more partition flags indicate a plurality of partitions in a coding tree unit (CTU); as well as, Based on the one or more partition flags, the coding tree unit CTU is divided into multiple coding units CU.
5. The method according to claim 1, characterized in that Further including: determining, based at least on the syntax element, a bit depth of quantization weight coefficients in a layer; Allocating storage space for the quantization weight coefficients based on the bit depth; as well as, The quantized weight coefficients in the layer are decoded from the bitstream using the allocated memory space.
6. The method according to claim 5, characterized in that Further including: Decode the global bit depth from the neural network representation NNR head; decoding, from a layer header of a layer, a difference between the bit depth and the global bit depth; as well as, The bit depth of quantization weight coefficients in the layer is determined based on the global bit depth and a combination of the bit depth and a difference between the global bit depth.
7. The method according to claim 1, characterized in that Further including: At least one of a plurality of dimensions in a layer, a shape of the layer, a scanning order of a plurality of coding units in the layer, a saturation maximum value in the layer, and a quantization step size in the layer is decoded from a layer header.
8. The method according to claim 1, characterized in that: Further including: When the layer includes a bias sublayer and another sublayer, the bias sublayer of the layer is decoded from the bitstream before the another sublayer of the layer is decoded.
9. The method according to any one of claims 1 to 8, characterized in that: Further including: decoding a parameter from a header portion in the bitstream, the parameter indicating a total size of the header portion; as well as, Based on the parameters, a portion of the bitstream following the header portion is accessed.
10. A neural network decoding device, characterized in that: The method comprises a processing circuit for executing the method according to any one of claims 1 to 9.
11. A neural network decoding device, characterized in that: include: a decoding module for decoding at least one syntax element corresponding to a neural network representation from a bitstream, wherein the at least one syntax element is to be applied to a plurality of blocks of the neural network; and A reconstruction module, configured to reconstruct weight coefficients of the plurality of blocks from the bitstream according to the syntax elements; Wherein, the decoding module is further used for: decoding a flag from a layer header, wherein the flag indicates a scanning order of a plurality of blocks in the layer; and, The plurality of blocks are decoded from the bitstream according to the scanning order.
12. The device according to claim 11, characterized in that The apparatus further comprises an updating module and a partitioning module, wherein the decoding module is further used to decode a flag from a neural network representation (NNR) header, the flag indicating whether to change a coding tree unit (CTU) size based on a kernel size; When the flag indicates that the coding tree unit CTU size can be changed based on the kernel size, the updating module is used to update the coding tree unit CTU size based on the kernel size; The partitioning module is used to partition the weight tensor into a plurality of coding tree units CTU based on the updated coding tree unit CTU size; and The reconstruction module is further configured to reconstruct weight coefficients of the plurality of coding tree units CTU from the bitstream.
13. The device according to claim 11, characterized in that The device also includes a partitioning module, wherein: The decoding module is further used to decode an index from a neural network representation (NNR) header of the bitstream, the index indicating a coding tree unit (CTU) size; The partitioning module is used to partition the weight tensor into a plurality of coding tree units CTU based on the coding tree unit CTU size indicated by the index; and The reconstruction module is further configured to reconstruct weight coefficients of the plurality of coding tree units CTU from the bitstream.
14. The device according to claim 13, characterized in that The decoding module is further configured to: decode one or more partition flags from the bitstream, wherein the one or more partition flags indicate a plurality of partitions in a coding tree unit CTU; and The partitioning module further partitions the coding tree unit CTU into a plurality of coding units CU based on the one or more partitioning flags.
15. The device according to claim 11, characterized in that The device also includes a determination module and an allocation module, wherein: The determining module is configured to determine a bit depth of a quantization weight coefficient in a layer based at least on the syntax element; The allocation module is configured to allocate storage space for the quantization weight coefficient based on the bit depth; and The decoding module is further configured to decode the quantization weight coefficients in the layer from the bitstream using the allocated storage space.
16. The device according to claim 15, characterized in that The decoding module is further used for: Decode the global bit depth from the neural network representation NNR head; decoding, from a layer header of a layer, a difference between the bit depth and the global bit depth; and, The determination module is further configured to determine the bit depth of the quantization weight coefficients in the layer based on the global bit depth and a combination of the bit depth and the global bit depth.
17. The device according to claim 11, characterized in that The decoding module is further used for: At least one of a plurality of dimensions in a layer, a shape of the layer, a scanning order of a plurality of coding units in the layer, a saturation maximum value in the layer, and a quantization step size in the layer is decoded from a layer header.
18. The device according to claim 11, characterized in that The decoding module is further used for: When the layer includes a bias sublayer and another sublayer, the bias sublayer of the layer is decoded from the bitstream before the another sublayer of the layer is decoded.
19. The device according to claim 11, characterized in that The apparatus further comprises an access module, wherein the decoding module is further configured to decode a parameter from a header portion in the bitstream, the parameter indicating a total size of the header portion; and The access module is used to access the portion after the header portion in the bit stream based on the parameter.
20. A non-volatile computer readable medium, characterized in that The non-transitory computer-readable medium stores a plurality of instructions, which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 9.
