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

namespace Livt.ML.Tests.Activation

using Livt.ML.Activation

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

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

	/**
	 * Checks the midpoint case.
	 */
	@Test
	fn TestMidpoint()
	{
		var result = sig.Apply(128)
		assert result == 128
	}

	/**
	 * Checks the low saturation case.
	 */
	@Test
	fn TestLowSaturation()
	{
		var result = sig.Apply(0)
		assert result == 0
	}

	/**
	 * Checks the high saturation case.
	 */
	@Test
	fn TestHighSaturation()
	{
		var result = sig.Apply(255)
		assert result == 255
	}

	/**
	 * Checks the positive one case.
	 */
	@Test
	fn TestPositiveOne()
	{
		var result = sig.Apply(144)
		assert result == 186
	}

	/**
	 * Checks the negative one case.
	 */
	@Test
	fn TestNegativeOne()
	{
		var result = sig.Apply(112)
		assert result == 69
	}

	/**
	 * Checks the positive two case.
	 */
	@Test
	fn TestPositiveTwo()
	{
		var result = sig.Apply(160)
		assert result == 225
	}

	/**
	 * Checks the negative two case.
	 */
	@Test
	fn TestNegativeTwo()
	{
		var result = sig.Apply(96)
		assert result == 30
	}

	/**
	 * Checks that Clamp low.
	 */
	@Test
	fn TestClampLow()
	{
		var result = sig.Apply(-10)
		assert result == 0
	}

	/**
	 * Checks that Clamp high.
	 */
	@Test
	fn TestClampHigh()
	{
		var result = sig.Apply(300)
		assert result == 255
	}
}