# US 12,010,310 B2 · Method and apparatus for quantization, adaptive block partitioning and codebook coding for neural network model compression

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,010,310 B2
- Document ID: US12010310B2
- Status: Granted
- Kind: B2
- Application number: 17/559,676
- Filed: 2021-12-22
- Published: 2022-04-14
- Granted: 2024-06-11
- Earliest claimed: 2019-11-22
- Assignees: Tencent America LLC
- Applicants: Tencent America LLC
- Inventors: Wei Wang; Wei Jiang; Shan Liu
- Web page: https://patentgrep.com/patent/US12010310B2

## CPC

- H04N 19/124: Quantisation
- G06N 3/045: Combinations of networks
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/0495: Quantised networks; Sparse networks; Compressed networks
- G06N 3/08: Learning methods
- G06N 3/082: modifying the architecture, e.g. adding, deleting or silencing nodes or connections
- H04N 19/119: Adaptive subdivision aspects, e.g. subdivision of a picture into rectangular or non-rectangular coding blocks
- H04N 19/13: Adaptive entropy coding, e.g. adaptive variable length coding [AVLC] or context adaptive binary arithmetic coding [CABAC]
- H04N 19/147: according to rate distortion criteria (rate-distortion as a criterion for motion estimation H04N19/567)
- H04N 19/176: the region being a block, e.g. a macroblock
- H04N 19/192: the adaptation method, adaptation tool or adaptation type being iterative or recursive
- H04N 19/30: using hierarchical techniques, e.g. scalability (H04N19/63 takes precedence)
- H04N 19/46: Embedding additional information in the video signal during the compression process (H04N19/517, H04N19/68, H04N19/70 take precedence)
- H04N 19/597: specially adapted for multi-view video sequence encoding
- H04N 19/96: Tree coding, e.g. quad-tree coding
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A method of quantization, adaptive block partitioning and codebook coding for neural network model compression, is performed by at least one processor and includes determining a saturated maximum value of a multi-dimensional tensor in a layer of a neural network, and a bit depth corresponding to the saturated maximum value, and clipping weight coefficients in the multi-dimensional tensor to be within a range of the saturated maximum value. The method further includes quantizing the clipped weight coefficients, based on the bit depth, and transmitting, to a decoder, a layer header including the bit depth.

## Claims

### Claim 1

A method of quantization, adaptive block partitioning and codebook coding for neural network model compression, the method being performed by at least one processor, and the method comprising:
determining a saturated maximum value of a multi-dimensional tensor in a layer of a neural network, and a bit depth corresponding to the saturated maximum value;
clipping weight coefficients in the multi-dimensional tensor to be within a range of the saturated maximum value;
quantizing the clipped weight coefficients, based on the bit depth;
transmitting, to a decoder, a layer header comprising the bit depth and a plurality of partitioning parameters that specify at least a height threshold and a width threshold;
reshaping a four-dimensional (4D) parameter tensor of a neural network, among the quantized weight coefficients, into a three-dimensional (3D) parameter tensor of the neural network, the 3D parameter tensor comprising a convolution kernal size, an input feature size and an output feature size; and
partitioning the 3D parameter tensor based on the height threshold and the width threshold.

### Claim 2 (depends on 1)

The method of claim 1, further comprising coding the bit depth, using a variable length coding or a fixed length coding,
wherein the layer header comprises the coded bit depth.

### Claim 3 (depends on 1)

The method of claim 1, wherein the layer header further comprises the saturated maximum value.

### Claim 4 (depends on 1)

The method of claim 1,
the height threshold is determined based on a right shift operation of a maximum height of a 3D coding tree unit (CTU3D) by the bit depth, and
the width threshold is determined based on a right shift operation of a maximum weight of the CTU3D by the bit depth.

### Claim 5 (depends on 1)

The method of claim 1, wherein the saturated maximum value is represented by a floating number,
wherein the method further comprises determining an integer representing the saturated maximum value, based on an equation:
int_layer_sat_maxw=int(ceil(layer_sat_maxw*(2**N))),
where int_layer_sat_maxw indicates the integer of the saturated maximum value, and layer_sat_maxw indicates the saturated maximum value.

### Claim 6 (depends on 5)

The method of claim 5, further comprising coding the integer of the saturated maximum value, using a variable length coding or a fixed length coding.

### Claim 7 (depends on 1)

The method of claim 1, wherein the layer header further comprises a step size of the quantizing the clipped weight coefficients.

### Claim 8 (depends on 1)

The method of claim 1,
wherein the partitioning the 3D parameter tensor is performed along a plane that is formed by the input feature size and the output feature size, into 3D coding tree units (CTU3Ds); and
the method further comprising encoding the CTU3Ds.

### Claim 9 (depends on 8)

The method of claim 8, wherein the CTU3Ds are non-overlapping square blocks.

### Claim 10 (depends on 8)

The method of claim 8, further comprising setting a flag to indicate that each of the CTU3Ds has a constant size,
wherein the partitioning the 3D parameter tensor comprises, based on the flag being set to indicate that each of the CTU3Ds has the constant size, partitioning the 3D parameter tensor along the plane, into the CTU3Ds having the constant size.

### Claim 11 (depends on 8)

The method of claim 8, further comprising setting a flag to indicate that each of the CTU3Ds has a size that is scaled based on the convolution kernel size,
wherein the partitioning the 3D parameter tensor comprises, based on the flag being set to indicate that each of the CTU3Ds has the size scaled based on the convolution kernel size, partitioning the 3D parameter tensor along the plane, into the CTU3Ds having the size scaled based on the convolution kernel size.

### Claim 12 (depends on 8)

The method of claim 8, wherein the entropy encoding the CTU3Ds comprises entropy encoding the CTU3Ds in a raster scan order at either a horizontal direction or a vertical direction.

### Claim 13 (depends on 8)

The method of claim 8, further comprising partitioning each of the CTU3Ds into a plurality of 3D coding units (CU3Ds) recursively until a maximum depth, using a quad-tree.

### Claim 14 (depends on 13)

The method of claim 13, wherein the entropy encoding the CTU3Ds comprises:
scanning a first depth of the quad-tree; and
entropy encoding one or more of the plurality of CU3Ds included in the scanned first depth of the quad-tree, in a raster scan order at either a horizontal direction or a vertical direction.

### Claim 15 (depends on 13)

The method of claim 13, wherein the plurality of CU3Ds are non-overlapping square blocks.

### Claim 16 (depends on 13)

The method of claim 13, wherein the partitioning each of the CTU3Ds into the plurality of CU3Ds comprises:
determining whether a combined rate distortion of child CU3Ds is less than a rate distortion of a parent CU3D among the plurality of CU3Ds; and
based on the combined rate distortion of the child CU3Ds being determined to be less than the rate distortion of the parent CU3D, partitioning the parent CU3D into the child CU3Ds.

### Claim 17 (depends on 1)

The method of claim 1, further comprising:
generating a histogram of the quantized weight coefficients;
comparing a rate distortion of each of bins of the generated histogram with a rate distortion of each of entries in a codebook predictor for the quantized weight coefficients; and
based on the rate distortion of one of the bins of the histogram being compared to be less than the rate distortion of one of the entries in the codebook predictor, replacing the one of the bins with the one of the entries, to generate a codebook for re-indexing the quantized weight coefficients.

### Claim 18 (depends on 17)

The method of claim 17, further comprising a predicted bitmap indicating whether each of the entries of the codebook predictor is in the generated codebook.

### Claim 19

An apparatus for quantization, adaptive block partitioning and codebook coding for neural network model compression, the apparatus comprising:
at least one memory configured to store program code; and
at least one processor configured to read the program code and operate as instructed by the program code, the program code comprising:
first determining code configured to cause the at least one processor to determine a saturated maximum value of a multi-dimensional tensor in a layer of a neural network, and a bit depth corresponding to the saturated maximum value;
clipping code configured to cause the at least one processor to clip weight coefficients in the multi-dimensional tensor to be within a range of the saturated maximum value;
quantizing code configured to cause the at least one processor to quantize the clipped weight coefficients, based on the bit depth;
transmitting code configured to cause the at least one processor to transmit, to a decoder, a layer header comprising the bit depth and a plurality of partitioning parameters that specify at least a height threshold and a width threshold;
reshaping code configured to cause the at least one processor to reshape a four-dimensional (4D) parameter tensor of a neural network, among the quantized weight coefficients, into a three-dimensional (3D) parameter tensor of the neural network, the 3D parameter tensor comprising a convolution kernel size, an input feature size and an output feature size; and
partitioning the 3D parameter tensor based on the height threshold and the width threshold.

### Claim 20

A non-transitory computer-readable medium storing instructions that, when executed by at least one processor for quantization, adaptive block partitioning and codebook coding for neural network model compression, cause the at least one processor to:
determine a saturated maximum value of a multi-dimensional tensor in a layer of a neural network, and a bit depth corresponding to the saturated maximum value;
clip weight coefficients in the multi-dimensional tensor to be within a range of the saturated maximum value;
quantize the clipped weight coefficients, based on the bit depth;
transmit, to a decoder, a layer header comprising the bit depth and a plurality of partitioning parameters that specify at least a height threshold and a width threshold;
reshape a four-dimensional (4D) parameter tensor of a neural network, among the quantized weight coefficients, into a three-dimensional (3D) parameter tensor of the neural network, the 3D parameter tensor comprising a convolution kernel size, an input feature size and an output feature size; and
partitioning the 3D parameter tensor based on the height threshold and the width threshold.
