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(go): keep the onnx suite to graphs CI has

Adeshina Lasisifb8a0adf0214
diff --git a/laya-go/onnx/lifecycle_test.go b/laya-go/onnx/lifecycle_test.go
index a4b4b9e4..bcf3a76e 100644
--- a/laya-go/onnx/lifecycle_test.go
+++ b/laya-go/onnx/lifecycle_test.go
@@ -245,34 +245,18 @@ func TestCloseWaitsForRunsInFlight(t *testing.T) {
}
}
-func TestOtherGraphs(t *testing.T) {
- p := need(t)
+// TestLayoutErrors needs no graph beyond the shared one: the split layout and a missing file are
+// built in a temporary directory.
+func TestLayoutErrors(t *testing.T) {
+ need(t)
closeShared(t)
-
- var ge *GraphError
- full := p.sibling("full-multilingual")
- if s, err := Open(full); !errors.As(err, &ge) || s != nil {
- t.Fatalf("Open(full) = %v, %v; want a *GraphError", s, err)
- }
- if ge.Path != full || !strings.Contains(ge.Problem, `"act_logits"`) || !strings.Contains(ge.Problem, "fixed batch") {
- t.Fatalf("GraphError = %v", ge)
- }
- if references() != 0 || ort.IsInitialized() {
- t.Fatalf("a rejected graph left refs %d, initialized %v", references(), ort.IsInitialized())
- }
-
- legacy, err := Open(p.sibling("legacy-multilingual"))
- if err != nil {
- t.Fatalf("legacy graph: %v", err)
- }
- b := makeBatch(3, 24, 4)
- out, err := legacy.Run(context.Background(), b)
- if err != nil || out.Check(b) != nil {
- t.Fatalf("legacy Run = %v, %v", out, err)
+ splitDir := t.TempDir()
+ for _, name := range []string{"encoder.onnx", "head.onnx"} {
+ if err := os.WriteFile(filepath.Join(splitDir, name), []byte("x"), 0o600); err != nil {
+ t.Fatal(err)
+ }
}
- legacy.Close()
-
- splitDir := filepath.Dir(p.sibling("multilingual"))
+ var ge *GraphError
if s, err := Open(splitDir); !errors.As(err, &ge) || s != nil || !strings.Contains(ge.Problem, "split encoder.onnx + head.onnx layout is not supported") {
t.Fatalf("Open(split) = %v, %v", s, err)
}
diff --git a/laya-go/onnx/localgraphs_test.go b/laya-go/onnx/localgraphs_test.go
new file mode 100644
index 00000000..e00f9594
--- /dev/null
+++ b/laya-go/onnx/localgraphs_test.go
@@ -0,0 +1,43 @@
+//go:build cgo && localgraphs
+
+package onnx
+
+import (
+ "context"
+ "errors"
+ "strings"
+ "testing"
+
+ ort "github.com/yalue/onnxruntime_go"
+)
+
+// TestOtherGraphs needs the older exports beside the shared graph (full-multilingual: a fixed
+// batch dimension; legacy-multilingual: weights embedded), which CI does not have. Run with
+// -tags localgraphs. The fixed-batch rejection itself is covered without a graph by TestCheckGraph.
+func TestOtherGraphs(t *testing.T) {
+ p := need(t)
+ closeShared(t)
+
+ var ge *GraphError
+ full := p.sibling("full-multilingual")
+ if s, err := Open(full); !errors.As(err, &ge) || s != nil {
+ t.Fatalf("Open(full) = %v, %v; want a *GraphError", s, err)
+ }
+ if ge.Path != full || !strings.Contains(ge.Problem, `"act_logits"`) || !strings.Contains(ge.Problem, "fixed batch") {
+ t.Fatalf("GraphError = %v", ge)
+ }
+ if references() != 0 || ort.IsInitialized() {
+ t.Fatalf("a rejected graph left refs %d, initialized %v", references(), ort.IsInitialized())
+ }
+
+ legacy, err := Open(p.sibling("legacy-multilingual"))
+ if err != nil {
+ t.Fatalf("legacy graph: %v", err)
+ }
+ b := makeBatch(3, 24, 4)
+ out, err := legacy.Run(context.Background(), b)
+ if err != nil || out.Check(b) != nil {
+ t.Fatalf("legacy Run = %v, %v", out, err)
+ }
+ legacy.Close()
+}