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/activation/SiLUApproxTest.lvt

namespace Livt.ML.Tests.Activation

using Livt.ML.Activation

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

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

	/**
	 * Checks that Compute s zero vector.
	 */
	@Test
	fn ComputesZeroVector()
	{
		var input: int[8]

		silu.Compute(input)

		assert silu.GetOutput(0) == 0
		assert silu.GetOutput(7) == 0
	}

	/**
	 * Checks that Compute s approximation.
	 */
	@Test
	fn ComputesApproximation()
	{
		var input: int[8] = [2, 4, 8, 20, 0, 0, 0, 0]

		silu.Compute(input)

		assert silu.GetOutput(0) == 1
		assert silu.GetOutput(1) == 3
		assert silu.GetOutput(2) == 7
		assert silu.GetOutput(3) == 19
		assert silu.GetOutput(8) == 0
	}
}