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.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
test(onnx): close the shared agents before exit; document Close for statics
Adeshina Lasisi6a1f98ac025f
diff --git a/laya-cpp/include/laya/onnx.hpp b/laya-cpp/include/laya/onnx.hppindex 428b9393..c65b80fd 100644--- a/laya-cpp/include/laya/onnx.hpp+++ b/laya-cpp/include/laya/onnx.hpp@@ -25,8 +25,9 @@ std::string RuntimeVersion();// A Session over one fused laya.onnx (+ laya.onnx.data beside it). Checks the graph's inputs and// outputs at once. Run is thread-safe and stops in flight when its CancelToken fires (kCancelled).// Close is idempotent, refuses new runs, terminates the runs in flight and returns once they have-// left. A Session or Agent may be held in a static: the process-wide ONNX Runtime environment is a-// static built on the first Open and does not need the session. No exception leaves this API.+// left. A Session or Agent held in a static should be Closed before exit: the process-wide ONNX+// Runtime environment is a static built on the first Open, and the runtime's own statics may be gone+// by static destruction. Close is cheap and idempotent. No exception leaves this API.Result<std::unique_ptr<infer::Session>> Open(const std::string& graph_path, const Options& options = {});} // namespace onnxdiff --git a/laya-cpp/tests/onnx_test.cpp b/laya-cpp/tests/onnx_test.cppindex 5755d7e1..6c672d38 100644--- a/laya-cpp/tests/onnx_test.cpp+++ b/laya-cpp/tests/onnx_test.cpp@@ -338,6 +338,20 @@ std::string Need(const char* var) {std::mutex g_agents_mu;std::map<std::string, std::unique_ptr<laya::agent::Agent>> g_agents;+// The agents hold ONNX Runtime sessions, which must be closed before static destruction begins: the+// runtime's statics may already be gone by then, and an agent still open at exit aborted some+// asan/tsan processes after their tests passed ("recursive_mutex lock failed"). Close is the+// supported way to end a session held in a static.+class CloseAgents : public ::testing::Environment {+ public:+ void TearDown() override {+ std::lock_guard<std::mutex> lock(g_agents_mu);+ for (auto& kv : g_agents) EXPECT_EQ(kv.second->Close(), "");+ g_agents.clear();+ }+};+const ::testing::Environment* const g_close_agents = ::testing::AddGlobalTestEnvironment(new CloseAgents);+// One agent per checkpoint for the whole process; the tests only read it.laya::agent::Agent* Shared(const Rig& rig, const std::string& graph, const std::string& dir) {auto& agents = g_agents;