Method and apparatus for neural network model compression/decompression
Aspects of the disclosure provide methods and apparatuses for neural network model compression/decompression. In some examples, an apparatus for neural network model decompression includes receiving circuitry and processing circuitry. The processing circuitry decodes, from a bitstream corresponding to a representation of a neural network, at least a syntax element to be applied to multiple blocks in the neural network. Then, the processing circuitry reconstructs, from the bitstream, weight coefficients in the blocks based on the syntax element.
1. A method by a decoder for neural network decoding, comprising:
decoding, from a neural network representation (NNR) header of a bitstream, a global bit depth for quantized weight coefficients of a neural network encoded in the bitstream;
allocating a memory space for the quantized weight coefficients of a layer of the neural network based on a layer bit depth for the quantized weight coefficients of the layer, the layer bit depth being no greater than the global bit depth; and
decoding, from the bitstream, the quantized weight coefficients in the layer of the neural network using the allocated memory space.
2. The method of claim 1 , further comprising:
decoding, from a layer header for the layer of the neural network in the bitstream, a delta bit depth for quantized weight coefficients; and
deriving the layer bit depth from a combination of the global bit depth and the delta bit depth.
3. The method of claim 2 , wherein deriving the layer bit depth comprises obtaining the layer bit depth by reducing the global bit depth by the delta bit depth.
4. The method of claim 1 , further comprising:
decoding, from a layer header for the layer of the neural network in the bitstream, a flag indicative of a scan order of multiple blocks in the layer of the neural network; and
decoding the quantized weight coefficients in the layer of the neural network by decoding the multiple blocks from the bitstream according to the scan order.
5. The method of claim 1 , further comprising decoding, from a layer header for the layer of the neural network in the bitstream, at least one of a number of dimensions in the layer, a shape of the layer, a scan order of coding units in the layer, or a saturated maximum value in the layer, or a quantization step size in the layer.
6. The method of claim 1 , further comprising decoding, from the NNR header of the bitstream, a header size parameter indicative of a total number of bytes of the NNR header.
7. The method of claim 6 , further comprising using the header size parameter for random access following the NNR within the bitstream.
8. The method of claim 1 , further comprising decoding, from the NNR header of the bitstream, an index indicative of a maximum coding tree unit (CTU) size for partitioning the neural network, wherein decoding the layer of the neural network comprises reconstructing weight coefficients of CTUs partitioned from a weight tensor associated with the layer of the neural network based on a CTU size, the CTU size being no greater than the maximum CTU size.
9. The method of claim 8 , further comprising
decoding, from the NNR header, a flag that indicates whether the CTU size associated with partitioning the weight tensor of the layer of the neural network depends on a convolution kernel size associated with the layer; and
determining the CTU size based on the maximum CTU size and the convolutional kernel size associated with the layer.
10. The method of claim 9 , further comprising decoding, from the bitstream, one or more split flags indicative of further partitioning within a CTU of the CTUs, wherein reconstructing the weight coefficients of the CTUs of the layer comprises determining one or more coding units (CUs) within each of the CTUs and decoding the one or more CUs.
11. The method of claim 10 , wherein decoding a CU of the one or more CUs comprises recursively decoding subpartitions of the CU according to a partitioning depth extracted from the bitstream.
12. The method of claim 1 , further comprising:
decoding, from the bitstream, a bias sublayer of the layer before decoding another sublayer of the layer in response to the layer including the bias sublayer and the another sublayer.
13. A device for neural network decoding, comprising a processing circuitry configured to:
decode, from a neural network representation (NNR) header of a bitstream, a global bit depth for quantized weight coefficients of a neural network encoded in the bitstream;
allocate a memory space for the quantized weight coefficients of a layer of the neural network based on a layer bit depth for quantized weight coefficients of the layer, the layer bit depth being no greater than the global bit depth; and
decode, from the bitstream, the quantized weight coefficients in the layer of the neural network using the allocated memory space.
14. The device of claim 13 , wherein the processing circuitry is further configured to:
decode, from a layer header for the layer of the neural network in the bitstream, a delta bit depth for quantized weight coefficients; and
derive the layer bit depth as the global bit depth reduced by the delta bit depth.
15. The device of claim 13 , where the processing circuitry is further configured to:
decode, from a layer header for the layer of the neural network in the bitstream, a flag indicative of a scan order of multiple blocks in the layer of the neural network; and
decode the quantized weight coefficients in the layer of the neural network by decoding the multiple blocks from the bitstream according to the scan order.
16. The device of claim 13 , where the processing circuitry is further configured to decode, from a layer header for the layer of the neural network in the bitstream, at least one of a number of dimensions in the layer, a shape of the layer, a scan order of coding units in the layer, or a saturated maximum value in the layer, or a quantization step size in the layer.
17. The device of claim 13 , where the processing circuitry is further configured to:
decode, from the NNR header of the bitstream, a header size parameter indicative of a total number of bytes of the NNR header; and
using the header size parameter for random access following the NNR within the bitstream.
18. The device of claim 13 , where the processing circuitry is further configured to decode, from the NNR header of the bitstream, an index indicative of a maximum coding tree unit (CTU) size for partitioning the neural network, wherein decoding the layer of the neural network comprises reconstructing weight coefficients of CTUs partitioned from a weight tensor associated with the layer of the neural network based on a CTU size, the CTU size being no greater than the maximum CTU size.
19. The device of claim 18 , where the processing circuitry is further configured to:
decode, from the NNR header, a flag that indicates whether the CTU size associated with partitioning the weight tensor of the layer of the neural network depends on a convolution kernel size associated with the layer; and
determine the CTU size based on the maximum CTU size and the convolutional kernel size associated with the layer.
20. The device of claim 19 , where the processing circuitry is further configured to decode, from the bitstream, one or more split flags indicative of further partitioning within a CTU of the CTUs, wherein reconstructing the weight coefficients of CTUs of the layer comprises determining one or more coding units (CUs) within each of the CTUs and decoding the one or more CUs.