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/classifier/StreamingArgMaxTest.lvt

namespace Livt.ML.Tests.Classifier

using Livt.ML.Classifier

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

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

	/**
	 * Checks that Select s best without storing the stream.
	 */
	@Test
	fn SelectsBestWithoutStoringTheStream()
	{
		this.dut.Reset()
		assert !this.dut.HasValue()
		this.dut.Accept(100, -9)
		this.dut.Accept(50256, 12)
		this.dut.Accept(7, 11)
		assert this.dut.HasValue()
		assert this.dut.GetIndex() == 50256
		assert this.dut.GetValue() == 12
	}

	/**
	 * Checks the lowest index wins ties regardless of order case.
	 */
	@Test
	fn LowestIndexWinsTiesRegardlessOfOrder()
	{
		this.dut.Reset()
		this.dut.Accept(9, 42)
		this.dut.Accept(3, 42)
		this.dut.Accept(7, 42)
		assert this.dut.GetIndex() == 3
	}
}