Livt packages
Livt.ML
Version 1.6.1
Fixed-size quantized inference, tensor storage, attention, and transformer building blocks for Livt.
Published files (132)
- DotProductTest.lvt
- Int8BroadcastMac64x8Test.lvt
- Int8Dot64x8Test.lvt
- Int8Linear4x8Test.lvt
- Int8Linear8x3Test.lvt
- Int8LinearAccumulatorTest.lvt
- Int8Mac8Test.lvt
- Int8MatrixAccumulator32StreamTest.lvt
- Int8MatrixAccumulator32Test.lvt
- Linear8x8Test.lvt
- MatrixVectorMultiplicationTest.lvt
- QLinearMatMul256x10RamTest.lvt
- QLinearMatMul256x10StreamTest.lvt
- QuantizedMatrixGroupingTest.lvt
- VecAddTest.lvt
tests/linear/VecAddTest.lvt
namespace Livt.ML.Tests.Linear
using Livt.ML.Linear
/**
* Exercises VecAdd with a shared fixture instance. Each scenario establishes the inputs
* and state it needs.
*/
@Test
component VecAddTest
{
// Shared fixture instances, signals, and observation state.
va: VecAdd
/**
* Creates the shared fixture instances (VecAdd). Tests initialize the state required by
* their scenario.
*/
new()
{
va = new VecAdd()
}
/**
* Checks that Add s zero vectors.
*/
@Test
fn AddsZeroVectors()
{
var a: int[8]
var b: int[8]
va.Compute(a, b)
assert va.GetOutput(0) == 0
assert va.GetOutput(7) == 0
}
/**
* Checks that Add s dense vectors.
*/
@Test
fn AddsDenseVectors()
{
var a: int[8] = [1, 1, 1, 1, 1, 1, 1, 1]
var b: int[8] = [1, 1, 1, 1, 1, 1, 1, 1]
va.Compute(a, b)
assert va.GetOutput(0) == 2
assert va.GetOutput(7) == 2
}
/**
* Checks that Add s residual pattern.
*/
@Test
fn AddsResidualPattern()
{
var residual: int[8] = [10, 20, 30, 0, 0, 0, 0, 0]
var sublayer: int[8] = [5, 3, 1, 0, 0, 0, 0, 0]
va.Compute(residual, sublayer)
assert va.GetOutput(0) == 15
assert va.GetOutput(1) == 23
assert va.GetOutput(2) == 31
assert va.GetOutput(8) == 0
}
}