Repository navigation
Commit 3c4d7e7
feat(onnx): derive io_spec from the model — register with just a path
Cuts the ONNX registration UX from ~10 lines of nested JSON to one line.
predict_register now reads a model's input/output tensors and fills in the
io_spec automatically, so the common case is:
SELECT predict_register('clf', '/models/clf.onnx');
SELECT * FROM predict(NULL, 'SELECT id, f1, f2 FROM t', '{"model":"clf"}');
- predict0_onnx_introspect() opens the model and derives layout (1 input ->
vector, 3 named x_train/y_train/x_query -> in_context), tensor names,
output kind (float [N,K>1] -> probs, [N,1]/[N] -> value), and class count
(labels default 0..K-1). It builds the io_spec via json_object, and refuses
to guess ambiguous shapes (multi-output, non-float, unnamed 3-input) by
asking for an explicit io_spec.
- predict_register accepts a bare weights path or a JSON config; runtime
('onnx'), kind ('student'), and license ('unspecified', which the gate
allows) all default. in-context adds a top-level target (a SQL column
introspection can't infer), spliced into the derived io_spec via json_set.
- features[] is now optional everywhere: absent -> positional mapping (apply
column order), validated against the model's input width; present ->
name-based mapping (the override). The tensor feature dim F is computed per
call instead of assumed == named-feature count.
- The explicit-io_spec path is unchanged (all prior tests pass), and the
ASan/LSan soak now also exercises the introspection + positional path.
5 new tests cover bare-path vector/regressor registration, in-context
weights+target, the unspecified-license default, and positional count
validation. README/ARCHITECTURE/CHANGELOG updated.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: mstrathman <matthew.strathman@gmail.com>1 parent 6f82fbf commit 3c4d7e7
9 files changed
Lines changed: 8480 additions & 133 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
86 | 98 | | |
87 | 99 | | |
88 | 100 | | |
| 101 | + | |
89 | 102 | | |
90 | | - | |
91 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
92 | 107 | | |
93 | 108 | | |
94 | 109 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
200 | 210 | | |
201 | 211 | | |
202 | 212 | | |
| |||
0 commit comments