summaryrefslogtreecommitdiff
path: root/candle-onnx/src/eval.rs
Commit message (Collapse)AuthorAgeFilesLines
* Onnx Support for Sign operation #2641 (#2642)Ionut Mihalcea2024-11-261-0/+6
| | | | | | | | | * Support for Sign operation #2641 * Apply rustfmt. --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
* ONNX: GatherElements, Xor (#2568)Anubhab Bandyopadhyay2024-10-171-0/+53
|
* onnx: ReduceMin/Max Ops (#2563)Anubhab Bandyopadhyay2024-10-151-1/+173
| | | | | | | | | | | | | | | | | | | | | | | * Stella_en_1.5B_v5 * Separated creation. This is a critical step for numerical accuracy and would be documented in the readme * EmbedDim would require clone and copy * WIP: example * Examples added * a litte more in README * WIP: ONNX Reduce-max ops * WIP: tests for ReduceMin * Reduce min/ max v18+ * Reformatting tests for better review readability * Error on empty set, backward compatibility (13 and below) with 'axes'
* Clippy fixes for onnx + fix a broken test. (#2510)Laurent Mazare2024-09-261-14/+13
|
* Expand split ops (#2505)Steven Lovegrove2024-09-261-14/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * candle-onnx: Add Split and Expand operators, Fix Where Op Implemented based on https://github.com/onnx/onnx/blob/main/docs/Operators.md Test cases based on those examples. TODO: Should add the remaining Split examples as tests TODO: Add.test case that motivates Where fix * candle-onnx: Add ReduceSum operator Implemented based on https://github.com/onnx/onnx/blob/main/docs/Operators.md Test cases based on those examples. TODO: Should add the remaining ReduceSum examples as tests * candle-onnx: Add ReduceL2 operator Implemented based on https://github.com/onnx/onnx/blob/main/docs/Operators.md Test cases based on those examples. TODO: Should add the remaining ReduceSum examples as tests * candle-onnx: Fix Clip operator empty string as default arg issue Optional input args may be signified by an empty string. The length of the input array is not enough because non optional args may follow optional ones. I encountered this when trying to use the ONNX model found at https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2 for example. The LSTM op has a utility which I factored to be more generally accessible, and I have used it in the ops I have recently created or debugged. I believe it is likely that this issue may also manifest in other ops, but I didn't want to change anything that I'm not testing. * fix formatting * fix small mistake made during refactor
* onnx: support negative index in Gather (#2440)shua2024-08-221-0/+12
| | | | | | index_select does not support negative indexing, but this change adds just enough workarounds in onnx to allow evaluating silero-vad models (which make use of negative indices).
* onnx: workaround pow with negative base (#2439)shua2024-08-221-2/+9
| | | | | | | | | | | | * onnx: workaround pow with negative base rather than fully defining pow in the cpu backend (as in #2318), this implements a much smaller change which is sufficient to evaluate silero-vad onnx models. Specifically, checking if pow is run with 2.0 exponent, and if so evaluate as simply `x*x` instead of the cpu backend of `e^(2.0 * ln(x))`. * PR: use Tensor::powf insead powf correctly handles a negative base.
* onnx: implement LSTM op (#2268)shua2024-08-191-0/+239
| | | use candle-nn LSTM
* onnx: fix pad, unsqueeze (#2317)shua2024-07-231-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * onnx: fix pad, unsqueeze both implementations have off-by-one errors: - Pad 'reflect' cycle for eg `dim==3` is `[0,1,2,1]` which has length of 4 (or `dim*2 - 2`) not 5 (current code `dim*2 - 1`) - Unsqueeze(-1) for tensor with `dim==3` should be 3 (ie `dim+index+1`) not 2 (ie currently `dim+index`) in addition, Pad is incorrectly calculating the starting padding. If we want to pad out 2 elements to the start, and we have this cycle of indices of length 6, then we should skip 4 elements, but currently we skip 2. A more visual representation of what's going on is below: ``` pad_start: 2 data: [a,b,c,d] indices: [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, ..] // zigzag between 0..4 actual: skip [ c d| c b a b] expected: ~ skip ~ [ c b| a b c d] ``` The values between `[` and `|` are padding and the values between `|` and `]` in the example should match the original data being padded. * Fix clippy lints. --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
* onnx: implement Size op (#2316)shua2024-07-071-0/+7
|
* Adding Gemm and ArgMax operators to candle-onnx (#2231)drCathieSo.eth2024-06-281-0/+24
| | | | | | | | | | | | | * feat(gemm): implement Gemm operator in candle-onnx * feat(onnx): Add support for ArgMax operator in candle-onnx * Apply rustfmt. * Remove argmax as it was already present. --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
* implement Slice op (#2260)shua2024-06-121-0/+80
|
* implement if, and pad reflect mode (#2251)shua2024-06-061-3/+98
| | | | | | | | | | | | | * implement if, and pad reflect mode The intent of this change is to allow eval of the current silero_vad.onnx (v4). This onnx file uses 'If' and 'Pad' nodes, which had not been supported by simple_eval until now * Cleanup (fmt, clippy, minor test tweaks). --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
* Apply rustfmt. (#2247)Laurent Mazare2024-06-041-7/+26
|
* ONNX: add ArgMin, ArgMax and LeakyRelu (#2246)B1rtek2024-06-041-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add basic RandomUniform implementation * Use is_some to check if seed is present * Added Exp operator implementation * Added ArgMin operator implementation * Added tests for ArgMin * ArgMin now returns a tensor with i64 * Added tests from pytorch examples * Added ArgMax operator implementation * Added tests for ArgMax * Added LeakyRelu implementation * Added a test for LeakyRelu * Typo fix * Fix a weird automatic RustRover change --------- Co-authored-by: Mateusz Okulus <mmokulus@gmail.com>
* ONNX: Add Floor and Ceil (#2235)mokulus2024-06-021-0/+10
|
* Add RandomNormal ONNX operator (#2200)mokulus2024-05-211-8/+14
|
* candle-onnx: add operators RandomUniform and Exp (#2116)B1rtek2024-04-231-0/+45
| | | | | | | | | | | * Add basic RandomUniform implementation * Use is_some to check if seed is present * Added Exp operator implementation --------- Co-authored-by: Mateusz Okulus <mmokulus@gmail.com>
* Add missing onnx operations (#2096)Gabriel2024-04-201-7/+153
| | | | | | | * Add missing onnx operations * Add tests and fix errors * Run rustfmt
* Add ReduceMean onnx operation (#2049)Gabriel2024-04-131-1/+24
| | | | | * Add ReduceMean onnx operation * Format code with rustfmt
* Handle more tensor shapes in onnx "Gather" operation (#2026)Gabriel2024-04-081-7/+23
| | | | | | | | | * Handle more tensor shapes in onnx "Gather" operation * Add more tests * Add comment * Fix typo
* add identity op (#1976)Mauro Sciancalepore2024-04-011-0/+5
|
* onnx: add the Flatten operator. (#1638)wanglong0012024-02-031-0/+10
| | | | | | | | | * onnx: add the Flatten operator. * onnx flatten: merge axis condition --------- Co-authored-by: 王泽龙 <wangzelong@shenqishen.com>
* Add the pow operator. (#1583)Laurent Mazare2024-01-131-0/+6
| | | | | * Add the pow operator. * Support the pow operation in onnx.
* Support for CumSum in ONNX models. (#1340)Laurent Mazare2023-11-171-0/+19
|
* fix: negative axis (#1296)YangNianYi2023-11-081-29/+4
| | | | | | | | | * fix: negative axis * Use normalize_axis. --------- Co-authored-by: Laurent <laurent.mazare@gmail.com>
* PyO3: Add optional `candle.onnx` module (#1282)Lukas Kreussel2023-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Start onnx integration * Merge remote-tracking branch 'upstream/main' into feat/pyo3-onnx * Implement ONNXModel * `fmt` * add `onnx` flag to python ci * Pin `protoc` to `25.0` * Setup `protoc` in wheel builds * Build wheels with `onnx` * Install `protoc` in manylinux containers * `apt` -> `yum` * Download `protoc` via bash script * Back to `manylinux: auto` * Disable `onnx` builds for linux
* [ONNX] Support a couple more ops. (#1284)Laurent Mazare2023-11-061-26/+109
| | | | | | | | | | | | | * Support the shape op in ONNX. * Share the axis normalization bits. * Add some limited support for gather. * Unsqueeze. * Comparison with broadcasting. * Add Not + handle i32.
* Add more models to the onnx example. (#1273)Laurent Mazare2023-11-051-15/+152
| | | | | | | | | | | | | | | * Add more models to the onnx example. * Input validation. * Input validation. * Bugfix. * Implement clip. * BatchNorm support. * Get the efficientnet onnx to work.
* [ONNX] Do not generate values for constants. (#1272)Laurent Mazare2023-11-051-3/+3
| | | | | * Do not generate values for constants. * Add an onnx based example using squeezenet.
* Better tensor initialization in ONNX. (#1270)Laurent Mazare2023-11-041-10/+103
| | | | | | | | | * Better tensor initialization in ONNX. * MaxPool support. * Add AvgPool. * Get the squeezenet example to work.
* Refactor the onnx attribute getters. (#1268)Laurent Mazare2023-11-041-73/+218
| | | | | | | | | * Refactor the onnx attribute getters. * Add get-attr-opt. * Add support for convolutions. * Add support for convolutions.
* Support more ONNX ops. (#1267)Laurent Mazare2023-11-041-0/+49
| | | | | * Add LogSoftmax. * Support for Transpose.
* Improve the ONNX basic example + bugfixes (#1266)Laurent Mazare2023-11-041-48/+156
| | | | | | | | | | | | | * Generate some zeros tensor in the onnx simple-eval example. * Fix the casting operation. * Support more ops. * Handle reshape. * Concat. * Softmax.
* ONNX casting support. (#1265)Laurent Mazare2023-11-041-10/+94
| | | | | | | * ONNX casting support. * Handle tensor constants. * Bugfix the binary ops.
* Add some preliminary ONNX support (#1260)Laurent Mazare2023-11-041-0/+81
* Add the onnx protos. * Move the reading bits. * Install protoc on the CI. * Install protoc on the cuda CI too. * Use clap for the onnx tool. * Tweak the CI protoc install. * Add some simple evalution function. * Add some binary operator support.