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/linear/Int8LinearAccumulatorTest.lvt

namespace Livt.ML.Tests.Linear

using Livt.ML.Linear

/**
 * Exercises Int8LinearAccumulator with a shared fixture instance. Each scenario
 * establishes the inputs and state it needs.
 */
@Test
component Int8LinearAccumulatorTest
{
	// Shared fixture instances, signals, and observation state.
	dut: Int8LinearAccumulator

	/**
	 * Creates the shared fixture instances (Int8LinearAccumulator). Tests initialize the state
	 * required by their scenario.
	 */
	new()
	{
		this.dut = new Int8LinearAccumulator()
	}

	/**
	 * Checks the centers values and preserves int32 range case.
	 */
	@Test
	fn CentersValuesAndPreservesInt32Range()
	{
		this.dut.Begin(100, 2, -3)
		this.dut.Accumulate(4, 5)
		this.dut.Accumulate(0, -5)
		assert this.dut.GetAccumulator() == 120
		this.dut.Begin(0, 0, 0)
		this.dut.Accumulate(1000, 1000)
		assert this.dut.GetAccumulator() == 1000000
	}
}