Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(dotnet): a default router keeps both checkpoints with real models

kevin-gatimu7ac3e18dc076
diff --git a/laya-dotnet/tests/Laya.Tests/RouterEndToEndTests.cs b/laya-dotnet/tests/Laya.Tests/RouterEndToEndTests.cs
index 743f46f0..d45a9b8f 100644
--- a/laya-dotnet/tests/Laya.Tests/RouterEndToEndTests.cs
+++ b/laya-dotnet/tests/Laya.Tests/RouterEndToEndTests.cs
@@ -51,6 +51,34 @@ public sealed class RouterEndToEndTests
AssertRoutesAndMatchesGolden(router, LayaCheckpoint.Multilingual, "case_sample_app_hindi.json");
}
+ [Fact]
+ public void DefaultOptionsAlternateTwoLanguagesWithoutReloading()
+ {
+ RequireEnglishAndMultilingual();
+ // Python's Router(max_loaded=2): with default options, switching back and forth between
+ // an English and a Hindi request builds each checkpoint once and keeps both resident.
+ var builds = new System.Collections.Concurrent.ConcurrentDictionary<LayaCheckpoint, int>();
+ using var router = new LayaRouter(new LayaRouterOptions(), checkpoint =>
+ {
+ builds.AddOrUpdate(checkpoint, 1, (_, n) => n + 1);
+ return LayaEngine.Create(new LayaOptions
+ {
+ Checkpoint = checkpoint,
+ ModelDirectory = TestArtifacts.For(checkpoint).Directory,
+ });
+ });
+
+ for (var round = 0; round < 2; round++)
+ {
+ AssertRoutesAndMatchesGolden(router, LayaCheckpoint.English, "case_sample_app_english.json");
+ AssertRoutesAndMatchesGolden(router, LayaCheckpoint.Multilingual, "case_sample_app_hindi.json");
+ }
+
+ Assert.Equal(1, builds[LayaCheckpoint.English]);
+ Assert.Equal(1, builds[LayaCheckpoint.Multilingual]);
+ Assert.Equal(2, router.Loaded.Count);
+ }
+
private static void AssertRoutesAndMatchesGolden(LayaRouter router, LayaCheckpoint expectedCheckpoint, string file)
{
var golden = GoldenData.For(expectedCheckpoint);