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/Int8LinearAccumulator.lvt
namespace Livt.ML.Linear
using Livt.Math.Arithmetic
/**
* Storage-free signed-int8 linear-output accumulator with int32 accumulation.
* Callers stream one activation/weight pair at a time, allowing weights to
* reside in constants, Livt.IO RAM, or an external memory controller.
*/
component Int8LinearAccumulator
{
// Owned arithmetic worker used by serialized operations.
mac: MacInt32
// Configured coefficients and numeric scaling parameters.
inputZeroPoint: int
weightZeroPoint: int
/**
* Creates the owned int32 MAC. Begin configures the bias and zero points for each output
* reduction.
*/
new()
{
this.mac = new MacInt32()
}
/**
* Starts one output with its bias and quantization zero points.
*/
public fn Begin(bias: int, inputZeroPointValue: int, weightZeroPointValue: int)
{
this.mac.Reset()
this.mac.Add(bias)
inputZeroPoint = inputZeroPointValue
weightZeroPoint = weightZeroPointValue
}
/**
* Adds one centered activation-by-weight product.
*/
public fn Accumulate(activation: int, weight: int)
{
this.mac.Accumulate(activation - inputZeroPoint, weight - weightZeroPoint)
}
/**
* Returns the signed int32 accumulator.
*/
public fn GetAccumulator() int
{
return this.mac.GetResult()
}
}