liveBook · Manning

Right-shift operation

As explained in Quantization and Fast Inference

A right shift moves an integer’s bits toward lower-order positions, approximately dividing by a power of two.

A right shift moves integer bits toward lower-order positions. In fixed-point multiplication, shifting the product right by the number of fractional bits restores the original scale; adding half a step first rounds to the nearest value instead of always truncating. section 2.1

Rescaling a Q3.4 product

The raw values 24 and 8 represent 1.5 and 0.5. Their product is 192; shifting right by four bits gives 12, the raw representation of 0.75. section 2.1

How Quantization and Fast Inference covers it

How deep it goes
Connects shifting by four bits to Q3.4 rescaling and explains adding half a step for rounding.
Examples
Works through multiplying raw values 24 and 8, then shifting the product to obtain raw value 12.
What it assumes
Defines raw-integer arithmetic and fixed-point scaling before using shifts.
What you can do after
Apply right shifts to rescale fixed-point multiplication results by the number of fractional bits.
How it connects
Ties right shifts to fixed-point arithmetic, integer multiplication, and rounding.

Also explained in

Compare how 2 books explain right-shift operation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantization and Fast Inference. The section links point to the parts of the book it draws on.