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

namespace Livt.ML.Tests.Activation

using Livt.ML.Activation

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

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

	/**
	 * Checks that the component passes positive values.
	 */
	@Test
	fn PassesPositiveValues()
	{
		assert relu.Apply(42) == 42
		assert relu.Apply(32767) == 32767
		assert relu.Apply(1) == 1
	}

	/**
	 * Checks that Clamp s non positive values to zero.
	 */
	@Test
	fn ClampsNonPositiveValuesToZero()
	{
		assert relu.Apply(-5) == 0
		assert relu.Apply(0) == 0
		assert relu.Apply(-128) == 0
	}
}