Livt packages
Livt.ML
Version 1.6.1
Fixed-size quantized inference, tensor storage, attention, and transformer building blocks for Livt.
Published files (132)
tests/numeric/RequantizeInt8Test.lvt
namespace Livt.ML.Tests.Numeric
using Livt.ML.Numeric
/**
* Exercises RequantizeInt8 with a shared fixture instance. Each scenario establishes the
* inputs and state it needs.
*/
@Test
component RequantizeInt8Test
{
// Shared fixture instances, signals, and observation state.
requantize: RequantizeInt8
/**
* Creates the shared fixture instances (RequantizeInt8). Tests initialize the state
* required by their scenario.
*/
new()
{
requantize = new RequantizeInt8()
}
/**
* Checks that Round s nearest with ties to even.
*/
@Test
fn RoundsNearestWithTiesToEven()
{
assert requantize.Apply(14, 10, 0) == 1
assert requantize.Apply(15, 10, 0) == 2
assert requantize.Apply(25, 10, 0) == 2
assert requantize.Apply(26, 10, 0) == 3
assert requantize.Apply(-15, 10, 0) == -2
assert requantize.Apply(-25, 10, 0) == -2
}
/**
* Checks the applies zero point and saturates case.
*/
@Test
fn AppliesZeroPointAndSaturates()
{
assert requantize.Apply(10, 10, 5) == 6
assert requantize.Apply(10000, 10, 0) == RequantizeInt8.MAX_VALUE
assert requantize.Apply(-10000, 10, 0) == RequantizeInt8.MIN_VALUE
}
/**
* Checks that the component handles invalid divisor deterministically.
*/
@Test
fn HandlesInvalidDivisorDeterministically()
{
assert requantize.Apply(100, 0, 7) == 7
assert requantize.Apply(100, -1, 200) == RequantizeInt8.MAX_VALUE
}
}