dot4I8Packed
On this page

dot4I8Packed

Function

A packed dot product reads byte-sized lanes from two words and sums their pairwise products.

Compare examples

Compare the unpacked lanes with the sum of products. Each lane has its own signedness.

Example 1a = [-1,2,-3,4]; b = [4,-3,2,-1]
Result
(-1 × 4) + (2 × -3) + (-3 × 2) + (4 × -1) = -20
Example 2a = [0,0,0,0]; b = [1,1,1,1]
Result
(0 × 1) + (0 × 1) + (0 × 1) + (0 × 1) = 0
Example 3a = [-2,-2,-2,-2]; b = [-2,-2,-2,-2]
Result
(-2 × -2) + (-2 × -2) + (-2 × -2) + (-2 × -2) = 16

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

When to use it

Use it for compact integer-vector arithmetic, including quantized inference.

Inputs and limits

This example uses signed bytes. The compiler requires WebGPU and the packed integer dot-product language feature.

For shader input rules and precision, consult WGSL and GLSL ES 3.00.

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Reads both u32 arguments as four SIGNED bytes and sums the four products into an i32, wrapping at 32 bits.

Syntax

declare function dot4I8Packed(a0: u32, a1: u32): i32
declare function dot4I8Packed(a: u32, b: u32): i32

Parameters

Return value

i32

Description

Not supported yet on the WebGL2 tier, like dot4U8Packed.

Targets

WGSL
dot4I8Packed(a, b)
GLSL ES 3.00
dot4I8Packed is not supported yet on the WebGL2 tier

Examples

See also

Edit this page Report a problem