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/GeluNewApproxQ8Test.lvt

namespace Livt.ML.Tests.Activation

using Livt.ML.Activation

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

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

	/**
	 * Checks that the component matches pinned lookup points and tails.
	 */
	@Test
	fn MatchesPinnedLookupPointsAndTails()
	{
		assert this.dut.Apply(-2048) == 0
		assert this.dut.Apply(-256) == -41
		assert this.dut.Apply(0) == 0
		assert this.dut.Apply(256) == 215
		assert this.dut.Apply(1024) == 1024
		assert this.dut.Apply(2048) == 2048
	}

	/**
	 * Checks the interpolates quarter steps case.
	 */
	@Test
	fn InterpolatesQuarterSteps()
	{
		assert this.dut.Apply(32) == 19
		assert this.dut.Apply(-32) == -13
	}

	/**
	 * Preserves signed division's truncation toward zero on descending LUT intervals.
	 */
	@Test
	fn TruncatesNegativeInterpolationTowardZero()
	{
		assert this.dut.Apply(-767) == -1
		assert this.dut.Apply(-736) == -1
		assert this.dut.Apply(-703) == -2
		assert this.dut.Apply(-639) == -4
	}
}