mtl5.mixed.dot#
- mtl5.mixed.dot(...)#
Overloaded function.
dot(a: mtl5._core.DenseVector_f32, b: mtl5._core.DenseVector_f32, accumulator: str | None = None, result: str | None = None) -> floatdot(a: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_f64, b: mtl5._core.DenseVector_f64, accumulator: str | None = None, result: str | None = None) -> floatdot(a: ndarray[dtype=float64, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=float64, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_i8, b: mtl5._core.DenseVector_i8, accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: ndarray[dtype=int8, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=int8, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: mtl5._core.DenseVector_i16, b: mtl5._core.DenseVector_i16, accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: ndarray[dtype=int16, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=int16, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: mtl5._core.DenseVector_u8, b: mtl5._core.DenseVector_u8, accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: ndarray[dtype=uint8, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=uint8, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> float
Dot product accumulated in a precision wider than the element.
accumulator=’i32’ is required. On 8-bit operands this is the quad multiply-accumulate (vpdpbusd / SDOT); on 16-bit it is the widening multiply-accumulate (vpmaddwd / SMLAL).
OVERFLOW IS THE CONTRACT, not an error case. Products are always exact – two int16 cannot overflow an int32 product – but the SUM wraps, and how soon depends on the operand magnitude rather than the vector length: at b bits of magnitude the headroom is about 2^(31-2b) terms. Measured at full range: one i16 x i16 product uses 2^30 of the int32 range, so TWO of them already overflow it, while i8 x i8 holds 131071 terms. That five order of magnitude gap is why the quantized-inference instructions are 8-bit. Wrapping is two’s complement and therefore bit-identical across lane counts, backends and thread partitions – reproducible, but still wrapping.
Every signedness pairing is accepted. The hardware implements only some of them (x86 does unsigned x signed first, ARM the symmetric ones), and a dot product is symmetric, so MTL5 swaps the operands onto whichever the machine has rather than refusing or falling back to the generic loop.
dot(a: mtl5._core.DenseVector_u8, b: mtl5._core.DenseVector_i8, accumulator: str | None = None, result: str | None = None) -> float
Dot product over mixed-signedness 8-bit operands, accumulated in int32.
accumulator=’i32’ is required. u8 x i8 is VNNI’s native pairing on x86 (unsigned activations against signed weights); ARM implements the symmetric pairings first instead. Either order is accepted here – a dot product is symmetric, so MTL5 swaps the operands onto whichever form the machine has rather than dropping to the generic loop.
The overflow contract is the same as the same-type form: products are exact, the sum wraps, and 8-bit operands give roughly 131000 terms of headroom in an int32.
dot(a: ndarray[dtype=uint8, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=int8, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> float
Dot product over mixed-signedness 8-bit operands, accumulated in int32.
accumulator=’i32’ is required. u8 x i8 is VNNI’s native pairing on x86 (unsigned activations against signed weights); ARM implements the symmetric pairings first instead. Either order is accepted here – a dot product is symmetric, so MTL5 swaps the operands onto whichever form the machine has rather than dropping to the generic loop.
The overflow contract is the same as the same-type form: products are exact, the sum wraps, and 8-bit operands give roughly 131000 terms of headroom in an int32.
dot(a: mtl5._core.DenseVector_i8, b: mtl5._core.DenseVector_u8, accumulator: str | None = None, result: str | None = None) -> float
Dot product over mixed-signedness 8-bit operands, accumulated in int32.
accumulator=’i32’ is required. u8 x i8 is VNNI’s native pairing on x86 (unsigned activations against signed weights); ARM implements the symmetric pairings first instead. Either order is accepted here – a dot product is symmetric, so MTL5 swaps the operands onto whichever form the machine has rather than dropping to the generic loop.
The overflow contract is the same as the same-type form: products are exact, the sum wraps, and 8-bit operands give roughly 131000 terms of headroom in an int32.
dot(a: ndarray[dtype=int8, shape=(*), order='C', device='cpu', writable=False], b: ndarray[dtype=uint8, shape=(*), order='C', device='cpu', writable=False], accumulator: str | None = None, result: str | None = None) -> float
Dot product over mixed-signedness 8-bit operands, accumulated in int32.
accumulator=’i32’ is required. u8 x i8 is VNNI’s native pairing on x86 (unsigned activations against signed weights); ARM implements the symmetric pairings first instead. Either order is accepted here – a dot product is symmetric, so MTL5 swaps the operands onto whichever form the machine has rather than dropping to the generic loop.
The overflow contract is the same as the same-type form: products are exact, the sum wraps, and 8-bit operands give roughly 131000 terms of headroom in an int32.
dot(a: mtl5._core.DenseVector_fp8, b: mtl5._core.DenseVector_fp8, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_fp16, b: mtl5._core.DenseVector_fp16, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_posit8, b: mtl5._core.DenseVector_posit8, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_posit16, b: mtl5._core.DenseVector_posit16, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_posit32, b: mtl5._core.DenseVector_posit32, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_posit64, b: mtl5._core.DenseVector_posit64, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_fixpnt8, b: mtl5._core.DenseVector_fixpnt8, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_fixpnt16, b: mtl5._core.DenseVector_fixpnt16, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_lns16, b: mtl5._core.DenseVector_lns16, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_lns32, b: mtl5._core.DenseVector_lns32, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_cfloat32, b: mtl5._core.DenseVector_cfloat32, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_takum32, b: mtl5._core.DenseVector_takum32, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_dd_cascade, b: mtl5._core.DenseVector_dd_cascade, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_td_cascade, b: mtl5._core.DenseVector_td_cascade, accumulator: str | None = None, result: str | None = None) -> floatdot(a: mtl5._core.DenseVector_qd_cascade, b: mtl5._core.DenseVector_qd_cascade, accumulator: str | None = None, result: str | None = None) -> float