Back to section lessons
Free overview · medium · Lesson 3 of 5

Integer multiplication

Add two products and see how much room the sum needs.

A linear layer multiplies inputs by weights and sums the products. When both inputs and weights are represented by integer codes, part of this work can use integer arithmetic. The running sum needs more headroom.

A small example

Even modest codes can produce a large sum. Two products of 10 × 10 add up to 200. Signed int8 tops out at 127. The intermediate sum already needs a wider type, even though every input value fits comfortably in int8.

Read the result in its original units

Suppose input code 10 represents 1.0 and weight code 10 represents 0.5. What product would you expect in the original units? It is 0.5. Multiplying the two integer codes gives 100. To interpret that result, multiply it by both grid steps, 0.1 and 0.05. With two identical terms as in the example above, the integer sum of 200 corresponds to 1.0.

See it happen

An integer calculation, step by step

Use the exact numbers from the lesson. Scales return the integer sum to the original units.

  1. Integer values
  2. Accumulate
  3. Restore scale
  4. Add bias

Stored integer values

[1, −2, 3] × [2, 3, −1]

Input scale 0.1; weight scale 0.2. Values are widened to int32 before multiplication.

1/4: Integer values

A numerical illustration. Training and model generation run in the local project.

Done reading?

Mark the lesson as read to move your track progress forward.

Now build your own version

Build an integer layer calculation and verify each numerical step.

What practice includes and how much it costs

MCP includes the full lesson and a local project with starter files. Work through the task with your agent, ask for a hint and run the checks on your computer.

$134 $67.00 for one year −50%

One payment, no auto-renewal · Terms

Buy for $67.00