Livt packages
Livt.ML
Version 1.6.1
Fixed-size quantized inference, tensor storage, attention, and transformer building blocks for Livt.
Published files (132)
- DotProduct.lvt
- FixedPointAccumulator.lvt
- Int8BroadcastMac64x8.lvt
- Int8BroadcastMac64x8Primitive.lvt
- Int8BroadcastMac64x8Primitive.vhd
- Int8Dot64x8.lvt
- Int8Dot64x8Primitive.lvt
- Int8Dot64x8Primitive.vhd
- Int8Linear4x8.lvt
- Int8Linear8x3.lvt
- Int8LinearAccumulator.lvt
- Int8Mac8.lvt
- Int8MatrixAccumulator32.lvt
- Int8MatrixAccumulator32Primitive.lvt
- Int8MatrixAccumulator32Primitive.vhd
- Int8MatrixAccumulator32Stream.lvt
- Linear8x8.lvt
- MatrixVectorMultiplication.lvt
- QLinearMatMul256x10.lvt
- QLinearMatMul256x10Ram.lvt
- QLinearMatMul256x10Stream.lvt
- QuantizedMatrix.lvt
- VecAdd.lvt
src/linear/DotProduct.lvt
namespace Livt.ML.Linear
/**
* Computes a saturated dot product for two fixed 8-element integer vectors.
*/
component DotProduct
{
// Number of integer elements consumed from each input vector.
public const VECTOR_SIZE: int = 8
// Positive saturation limit for the accumulated result.
public const ACC_MAX: int = 32767
/**
* Returns the dot product of a and b, clamped to ACC_MAX on positive overflow.
*/
public fn Compute(a: int[8], b: int[8]) int
{
var acc = 0
for (var i = 0; i < VECTOR_SIZE; i++) {
acc = acc + a[i] * b[i]
}
if (acc > ACC_MAX) {
acc = ACC_MAX
}
return acc
}
}