onemodelDocs
onemodel docs
Everything about OneModel: getting started, running models, exact mode and precision, the operators, the kernels, how it is checked against ONNX Runtime and the ONNX backend tests, and the reference. OneModel is a preview: 0.3.0-preview.1.
Start
Getting startedInstall the OneModel preview for .NET 10, run an ONNX model with one call, read its inputs and outputs, and see which kernels it picked. No native binaries, no ONNX Runtime.OverviewA neural-network runtime for .NET in pure managed C#, with no native binaries and no dependency beyond the shared framework. It loads ONNX models and our own format and runs them on SIMD CPU kernels, with training to follow on the same kernels. The name is provisional.
Running models
Sessions and plansThis note says how an imported model becomes something that runs: how operators are described, how a plan for one set of input shapes is made, how memory is reused, and what a session promises. The C# types are named for orientation; the rules are the contract.ONNX importHow a model file becomes the in-memory graph. A port can follow this text without the C# code. The schema is onnx.proto and the rules are ONNX's IR.md; the wire format is the protobuf encoding specification. Nothing here depends on a protobuf library.The OneModel formatA model file with the graph and its weights in one place, laid out so the weights can be used straight from a memory map. This text is normative: a reader or writer in another language can be built from it alone. Format version 1. Unstable until 1.0: version 1 files may stop…Graph passesRewrites applied to the compiled graph when a session is created, selected by SessionOptions.OptimizationLevel and the mode. Interface and ownership rules: graph-runtime.md section 6.
Exact mode and precision
Exact modeExact mode gives bit-identical results on every operating system, CPU, instruction set, thread count and runtime (including WebAssembly), so a port to another language or platform can reproduce them from this text alone. Fast mode (the default) gives up that promise for…Golden hashesExact mode (see exact-mode.md) promises the same bits on every OS, CPU, instruction set, thread count and runtime. This file records the check of that promise: the SHA-256 of every output of the reference models, run in ExecutionMode.Exact, and how the rows compared. Only…Exact transcendentalsNormative. A port that follows this text reproduces the exact results bit for bit. Source: src/OneModel/Kernels/Exact/Transcendental.cs (the algorithms) and TranscendentalOps.cs (the lane operations). Coefficients come from tools/transcendentals/fit.py (minimax fits in…Half-precision storageThe library computes in binary32. A model stored in binary16 or bfloat16 runs with half-precision storage between operators and binary32 arithmetic inside them. The conversion rules are in tensors.md section 10; this note says how they are used.int8 inferenceOperators, kernels and graph rewrites for 8-bit quantized models. Integer arithmetic is exact, so every int8 kernel gives the same bits on every instruction set and every thread count. The float parts around it (scales, dequantization) follow the order written here.
Operators
Operators for coverageSemantics the ONNX text leaves open, as settled by ONNX's backend-test data or, where that is silent, by ONNX Runtime 1.31.1's output on crafted inputs. Operators are checked against the backend tests (docs/conformance.md) and against ONNX Runtime on random inputs…Element-wise operatorsNormative notes for the operators in src/OneModel/Graph/Operators/Elementwise/. Semantics come from the ONNX operator specification; where the specification leaves a case open, the choice below was settled by running ONNX Runtime 1.31.1 on a crafted input (cases in…Normalization and reductionsNormative for the exact flavour; the fast flavour is the same unless a section says otherwise. Source: src/OneModel/Kernels/Exact/NormKernels.cs, Exact/ReduceKernels.cs, Kernels/Softmax.cs, src/OneModel/Graph/Operators/Norms/. Operators and opsets served:Convolution and poolingBehaviour of the operators of this family beyond what the ONNX operator text says: which cases are supported, how the open edges were settled, and which bits each operator promises. The kernels' arithmetic is in kernels-gemm.md (Conv) and below. Edge behaviour was settled by…Shape and indexingNotes on the operators that move, select or describe elements without computing on them: what each one does where the ONNX text leaves room, and how each choice was settled. Semantics come from ONNX's Operators.md and Changelog.md; open points were settled by running ONNX…RNN, GRU, LSTMSemantics are those of Operators.md (opsets 7, 14, 22 are one implementation: the attributes and inputs did not change in a way that needs a second one; layout arrived in opset 14). This note records what the specification leaves open, how each point was settled, and the…CTC decodingA helper for consumers of recognisers and speech models (not an ONNX operator): RecursiveAI.OneModel.Tensors.Ctc. It turns per-step class scores into label sequences. Scores are row-major [steps, classes] (a batch is [batch, steps, classes]), either logits or natural-log…
Kernels
Tensors and memoryNormative description of the tensor layer: element types, shapes and strides, views, layouts, buffer ownership, version counters, the backward record, the kernel seam and the numeric conversions. Source: src/OneModel/Tensors/. A port to another language must reproduce the…Matrix product kernelsfp32, row-major, C = A * B with A m x k, B k x n and row strides lda, ldb, ldc; convolution in NCHW. Both modes exist for every kernel; the exact mode's definition is in exact-mode.md.Attention and softmaxNormative for the exact flavour. Source: src/OneModel/Kernels/Attention.cs, Softmax.cs, Exact/Transcendental*.cs.Depthwise convolutionApplies to a Conv with Groups == Cin (one input channel per group; Cout = Cin * multiplier). Other convolutions are lowered to the matrix product (kernels-gemm.md), which would be all overhead here because k = KH * KW.
How it is checked
ONNX backend testsGenerated by tools/conformance.sh (it runs OnnxSweep conformance over the frozen ONNX 1.22.0 backend-test data, then tools/conformance_table.py). Nothing here is edited by hand. The method is at the end.Reference modelsThe seven reference models run through Model.Load(path).Run(...) or Session.Run(...) and are compared with ONNX Runtime's outputs stored by tools/make_reference.py (opset-17 exports, files and pins in tools/models.json, method in oracles.md).Oracles and reference dataONNX Runtime and PyTorch are used as black boxes: they produce reference outputs, export models and quantize them. Their code is never read, copied or linked into the library. Everything below is reproduced by the scripts in tools/; paths come from ONEMODEL_HOME (default…Benchmark methodA row compares two engines on one model file with the same inputs in the same harness: ONNX Runtime (the Microsoft.ML.OnnxRuntime package pinned in docs/oracles.md) and this library (a placeholder until its session exists).