mirror of
https://github.com/hanzoai/ml.git
synced 2026-11-19 23:50:51 +00:00
ai.onnx.ml is the classical half of ONNX — the operator set every scikit-learn, boosting and support-vector model exports to, carrying its whole model in node attributes rather than in graph edges. Reading it needed two things the evaluator did not have. A node's operator is (domain, op_type), not op_type: both domains define a Cast, so a table keyed on the name alone answers with the wrong operator. Domain::of reads NodeProto.domain and dispatches; an unknown domain is refused by name. A value on an edge is a tensor, text or a table. ZipMap sits on the probability output of every default classifier export and produces seq(map(K, tensor(float))); a classifier fitted on string labels reports tensor(string), which has no DType and cannot be a Tensor. Value is that sum, Edges::insert takes anything that is one, and the 87 arithmetic operators kept reading tensors unchanged. Sixteen operators: the tree ensembles, linear and support-vector classifiers and regressors, ZipMap, and the feature transforms in front of them. Min, Max, Sum and Mean collapse to one variadic fold, since the classical exporters wrap their nodes in that arithmetic. Identity reads the edge so it can carry a text label. CastMap, DictVectorizer and the opset-5 TreeEnsemble are refused by name with the fix in the message: the first two read a map from an edge that nothing here produces, the third is a different attribute schema. Every expectation comes from a trusted implementation, never from this evaluator: a real export is checked against the fitting library's own prediction, and a hand-built single-operator graph against onnxruntime, which is what pins the behaviour the specification leaves open — the binary widening rule, AVERAGE against base_values, MAX normalization of a negative row. tests/ml/generate.py writes each fixture and its expectation in one pass, because separately generated halves compare an unseeded forest against a different unseeded forest.