Skip to content

ONNX Backend #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 302 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
302 commits
Select commit Hold shift + click to select a range
08af18b
Sort operators
mrezanvari Aug 14, 2023
923532e
Remove unused imports
mrezanvari Aug 14, 2023
7ba5b9a
Add Reshape operator
mrezanvari Aug 14, 2023
55e802a
Add MatMul operator
mrezanvari Aug 15, 2023
b49a12e
Merge branch 'abetlen:main' into main
mrezanvari Aug 16, 2023
fb1a2ec
Use utils functions for shape and dtype
mrezanvari Aug 16, 2023
20bbc64
Add Concat operator and tests
mrezanvari Aug 16, 2023
7f08f67
Add Where operator
mrezanvari Aug 16, 2023
c58ce0d
Add Pow operator
mrezanvari Aug 17, 2023
1e09841
Merge branch 'abetlen:main' into main
mrezanvari Aug 17, 2023
507268d
Merge branch 'main' of github.com:mrezanvari/ggml-python
mrezanvari Aug 17, 2023
8794750
Use set_tensor_out
mrezanvari Aug 17, 2023
3f9198b
Cleanup warnings and stdout logs
mrezanvari Aug 17, 2023
caaa2fd
Remove duplicate Pow test
mrezanvari Aug 17, 2023
842530d
Add support for np.bool_
mrezanvari Aug 17, 2023
2812df1
Add eval_tensor, can_quantize, broadcasting rules
mrezanvari Aug 18, 2023
866ef96
Add test_ggml_onnx_qweights
mrezanvari Aug 18, 2023
74bbd70
Remove unwanted comments
mrezanvari Aug 18, 2023
71ca5ff
Merge branch 'main' into mrezanvari/main
abetlen Aug 19, 2023
94fffbd
Remove unnecessary dependencies
abetlen Aug 19, 2023
4036cbb
Simplify onnx tests and reduce number of backend methods
abetlen Aug 19, 2023
9838115
cleanup and enable passing tests
abetlen Aug 19, 2023
a89fd6a
Update return types
abetlen Aug 19, 2023
75fe261
broadcast subtract
abetlen Aug 19, 2023
cba2502
Enable some tests for implemented operators
abetlen Aug 19, 2023
fed802e
Fix Reshape
dmille Aug 19, 2023
f299f69
Update GH Actions setup
dmille Aug 19, 2023
709174c
resolve deps
dmille Aug 19, 2023
59c44e4
add missing test deps
dmille Aug 19, 2023
47c7c26
?
dmille Aug 19, 2023
7d210dd
remove non-fix
dmille Aug 19, 2023
b6913c1
.
dmille Aug 20, 2023
c98c925
Merge branch 'abetlen:main' into main
mrezanvari Aug 21, 2023
4f1e49e
Eval node for required operators
mrezanvari Aug 21, 2023
b0b94c7
Merge changes from `mrezanvari/main` branch
mrezanvari Aug 21, 2023
7b33a4a
Fix test cases
mrezanvari Aug 21, 2023
ce7192a
Exclude `Pad` operator tests
mrezanvari Aug 21, 2023
5f4120c
Fix Cast
mrezanvari Aug 21, 2023
baf9eda
Include new tests
mrezanvari Aug 21, 2023
3ab1842
Merge branch 'main' into mrezanvari/main
abetlen Aug 22, 2023
8183f35
Fix Constant, MatMul, Shape, Less and Greater ops
mrezanvari Aug 22, 2023
2cdb2f3
Fix Transpose, add new tests
mrezanvari Aug 22, 2023
77a797c
Don't run test matrix on python3.7
dmille Aug 22, 2023
775b41f
Exclude test_reshape_allowzero-reordered_ tests
dmille Aug 22, 2023
7243100
Update GH action
dmille Aug 22, 2023
b2f3fba
fix install
dmille Aug 22, 2023
424be03
Remove python3.7 from test matrix: GH actions
dmille Aug 22, 2023
cd5c50a
fix typo
dmille Aug 22, 2023
541fb18
Merge branch 'abetlen:main' into main
mrezanvari Aug 23, 2023
2adf95b
Fix Max, Min and Unsqueeze
mrezanvari Aug 23, 2023
8cc8d3f
Improve Constant operator
mrezanvari Aug 23, 2023
25befc0
Improve ReduceMean
mrezanvari Aug 23, 2023
e4f9721
Merge branch 'abetlen:main' into main
mrezanvari Aug 23, 2023
687e6f4
Merge branch 'abetlen:main' into main
mrezanvari Aug 23, 2023
6f8335c
Merge branch 'main' of github.com:abetlen/ggml-python into onnx-backend
dmille Aug 23, 2023
4f7af5b
Merge branch 'mrezanvari/main' into onnx-backend
dmille Aug 23, 2023
2bf7933
Merge branch 'main' of github.com:mrezanvari/ggml-python into onnx-ba…
dmille Aug 23, 2023
d2f38a8
Merge branch 'main' of github.com:abetlen/ggml-python into onnx-backend
dmille Aug 23, 2023
ea59af1
Install .[convert] for tests
dmille Aug 23, 2023
b99f44e
Skip broken tests
dmille Aug 23, 2023
c8c2f29
relu
dmille Aug 24, 2023
d007388
Add LogSoftmax
dmille Aug 24, 2023
92c2116
Fix name
dmille Aug 24, 2023
d6d13b1
Added logical operators
dmille Aug 24, 2023
7b9004f
softmax
dmille Aug 24, 2023
ed7e4d0
Enable CUDA tests
dmille Aug 24, 2023
3b92069
Add comments to failing tests
dmille Aug 24, 2023
a16f5ee
Merge branch 'main' of github.com:abetlen/ggml-python into onnx-backend
dmille Aug 24, 2023
922234b
conditional onnx tests
dmille Aug 24, 2023
2ba162c
typo
dmille Aug 24, 2023
5ba538f
onnx tests
dmille Aug 24, 2023
dd3c4dc
ignore-glob=onnx
dmille Aug 24, 2023
6e5920e
conditional tests on windows and osx
dmille Aug 24, 2023
ea0fdc3
conditional tests on windows and osx
mrezanvari Aug 24, 2023
e75a6b7
Create progress.md
mrezanvari Aug 25, 2023
15c7a58
Merge branch 'abetlen:main' into main
mrezanvari Aug 25, 2023
927f03b
Merge branch 'main' of github.com:mrezanvari/ggml-python
mrezanvari Aug 25, 2023
9357f98
Add Elu, Mean and Neg operators
mrezanvari Aug 25, 2023
b57150c
Add And, Not and Xor operators
mrezanvari Aug 25, 2023
62cce98
Add Size, Sigmoid and HardSigmoid
mrezanvari Aug 25, 2023
6461168
Add Hardmax
mrezanvari Aug 25, 2023
ef8e247
Add ReduceMin, ReduceProd and ReduceSumSquare + bug fix
mrezanvari Aug 28, 2023
d998de5
Add note to table
mrezanvari Aug 28, 2023
a2d5e4e
Merge branch 'main' into onnx-backend
abetlen Aug 28, 2023
974787f
Remove unnecessary tests
abetlen Aug 28, 2023
258c0d3
Add Floor, Flatten, ArgMax, ArgMin and Ceil
mrezanvari Aug 28, 2023
b84c9d7
Typing and docstring improvements
abetlen Aug 28, 2023
6170f85
Add PRelu operator
mrezanvari Aug 28, 2023
78a1949
Merge branch 'abetlen:main' into main
mrezanvari Aug 28, 2023
505322e
Merge branch 'main' of github.com:mrezanvari/ggml-python
mrezanvari Aug 28, 2023
fd3ea92
Add Softsign, Softplus and Squeeze operators
mrezanvari Aug 29, 2023
a6b92b8
Add Sum, Tanh and Tile
mrezanvari Aug 29, 2023
00209c7
Update mkdocs config to allow emoji shortcuts
abetlen Aug 29, 2023
4175858
Add onnx documentation
abetlen Aug 29, 2023
45931e8
Add Identity, LRN and Reciprocal
mrezanvari Aug 29, 2023
b830e81
Add tests for graph optimizer and quantization
abetlen Aug 29, 2023
e92ac4f
Merge branch 'main' into onnx-backend
abetlen Aug 29, 2023
9489686
Add ReduceL1 and ReduceL2 + fix Cast operator
mrezanvari Aug 29, 2023
20f27a7
Sort tests + add Equal tests
mrezanvari Aug 29, 2023
53b64d1
Update progress table
mrezanvari Aug 29, 2023
b8ec875
Add support for multiple outputs
abetlen Aug 29, 2023
4ddde7b
Merge branch 'abetlen:main' into main
mrezanvari Aug 29, 2023
3c012bf
Merge branch 'main' of github.com:mrezanvari/ggml-python
mrezanvari Aug 29, 2023
0301324
Use nbytes_pad
abetlen Aug 29, 2023
b8253d9
Update test_ggml_onnx.py
mrezanvari Aug 29, 2023
10c40a5
Merge changes from onnx-backend
mrezanvari Aug 29, 2023
e6d2fa1
Merge branch 'onnx-backend'
mrezanvari Aug 29, 2023
5932e2a
Update onnx.py
mrezanvari Aug 29, 2023
b550235
Progress doc cleanup
mrezanvari Aug 29, 2023
7fc5804
Fix Softsign
mrezanvari Aug 29, 2023
d5355c6
Add transpose transpose rewrite rule
abetlen Aug 29, 2023
707e2aa
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Aug 29, 2023
dd9efbc
Add TopK operator
mrezanvari Aug 29, 2023
c535f07
Add Split operator
mrezanvari Aug 30, 2023
c5ba003
Add SpaceToDepth + sort operators
mrezanvari Aug 30, 2023
c07261f
Remove quantization from prepare
abetlen Aug 30, 2023
4ed259f
Add Gemm operator
mrezanvari Aug 30, 2023
4a1c638
Add DepthToSpace, fix ConstantOfShape
mrezanvari Aug 30, 2023
b7d7315
Add InstanceNormalization operator
mrezanvari Aug 30, 2023
53d5bf2
Update onnx.py
mrezanvari Aug 30, 2023
e1f977e
Add PyTorch converted model operator tests
mrezanvari Aug 31, 2023
e479e1f
Add partial implementation for Conv
mrezanvari Aug 31, 2023
34a9833
Add partial implementation for ConvTranspose
mrezanvari Aug 31, 2023
65e431d
Update onnx.md
mrezanvari Aug 31, 2023
8914ac2
Add partial implementation for Dropout operator
mrezanvari Aug 31, 2023
09741c7
Merge pull request #28 from mrezanvari/main
dmille Aug 31, 2023
fe8818c
WIP
dmille Sep 1, 2023
1626fdf
pad operator
dmille Sep 1, 2023
53bd2a6
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
dmille Sep 1, 2023
c19a220
Fix pad operator
dmille Sep 1, 2023
442834c
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 1, 2023
4145cb6
Add debug build and test
abetlen Sep 2, 2023
3f42566
Merge branch 'main' into onnx-backend
abetlen Sep 3, 2023
194cba6
Avoid stripping debug info for debug builds
abetlen Sep 3, 2023
aa31b52
Reshape scalar numpy values to shape = (1,)
dmille Sep 7, 2023
12db36e
Merge branch 'main' into onnx-backend
abetlen Sep 8, 2023
4b89534
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 8, 2023
c692484
Merge branch 'main' into onnx-backend
abetlen Sep 10, 2023
b0479d3
Return empty numpy array if tensor data->NULL
dmille Sep 12, 2023
5a480ff
Merge branch 'main' into onnx-backend
abetlen Sep 13, 2023
ebfbc9d
Allocate input context seperately
abetlen Sep 13, 2023
15af1a2
use graph plan to compute graph
abetlen Sep 13, 2023
06067bf
Refactor graph context into class
dmille Sep 16, 2023
70b9156
Merge branch 'main' into onnx-backend
abetlen Sep 18, 2023
37bc6ba
Merge branch 'main' of github.com:abetlen/ggml-python into onnx-backend
dmille Sep 18, 2023
44618dc
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
dmille Sep 18, 2023
5dfebea
Remove pypy tests from GH actions tests
dmille Sep 18, 2023
e8b5419
fix
dmille Sep 18, 2023
715112b
Wrap to_numpy/from_numpy with Context method
dmille Sep 19, 2023
7933fe6
Implement Slice op
dmille Sep 19, 2023
c24e7d5
Format
abetlen Sep 19, 2023
a964860
Fix typing
abetlen Sep 19, 2023
a49553a
Add single _compute_graph
abetlen Sep 19, 2023
c54f2c1
Move eval_tensor and compute_graph to execution context
abetlen Sep 19, 2023
a0a04be
Fix slice
dmille Sep 19, 2023
732e65c
Fix Constant operator
dmille Sep 19, 2023
1aaa1f3
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 19, 2023
76ac430
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 19, 2023
1c2972e
Use closures for custom operators
abetlen Sep 19, 2023
7f8b024
Support concat of >2 tensors
dmille Sep 20, 2023
df92756
Use ctx.from_numpy in all operators
abetlen Sep 20, 2023
b12d692
Dynamic memory allocation
abetlen Sep 20, 2023
79a9e67
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 20, 2023
5fff347
fix eval_tensor call
dmille Sep 20, 2023
4de126b
Save overloaded dtypes in execution context dict
abetlen Sep 20, 2023
6fac253
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 20, 2023
1abf44d
Fix several type issues
abetlen Sep 20, 2023
15d2124
Remove unnused import
abetlen Sep 21, 2023
ce5d9d2
Remove unnused operator returns
abetlen Sep 21, 2023
1bad529
rename ggml_operator to register_ggml_operator
abetlen Sep 25, 2023
879bb2e
Replace set_tensor_out with np.copyto
abetlen Sep 25, 2023
f92ebfb
Fix transpose identity test
abetlen Sep 26, 2023
05e3090
Ensure new graph has zero Transpose nodes
abetlen Sep 26, 2023
001e88a
Add doctstring to transpose identity rule
abetlen Sep 26, 2023
6a943a7
Rename OnnxGraphRule and OnnxGraphRuleEngine
abetlen Sep 27, 2023
f9705b2
Update quantization test
abetlen Sep 27, 2023
b463882
Merge branch 'main' into onnx-backend
abetlen Sep 27, 2023
77516bb
Fix concat return
dmille Sep 28, 2023
570a4a7
Add fallbacks
dmille Sep 28, 2023
ba01d23
Mul np fallback
dmille Sep 28, 2023
1cb96bd
Fix quantized onnx graph test
abetlen Sep 29, 2023
902ada4
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Sep 29, 2023
5e4e691
Fix transpose so it handles any n_dims
dmille Sep 30, 2023
c717e91
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
dmille Sep 30, 2023
667b003
Merge branch 'main' into onnx-backend
abetlen Sep 30, 2023
ada6f26
Merge branch 'main' into onnx-backend
abetlen Oct 5, 2023
bbe99bc
Fix Mul shape
dmille Oct 7, 2023
dce167f
Add numpy fallback Add op
dmille Oct 7, 2023
62b7e2d
Fix Where op
dmille Oct 7, 2023
6951246
Fix unsqueeze
dmille Oct 8, 2023
75778c1
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
dmille Oct 8, 2023
52525e3
Merge branch 'main' into onnx-backend
abetlen Oct 11, 2023
9275099
Fix allocate tensor for view tensors
abetlen Oct 12, 2023
0d9876f
Merge branch 'main' into onnx-backend
abetlen Oct 12, 2023
265b55c
Fixes: Conv, Add, Div, Pad, Or, Concat, Cast
dmille Oct 13, 2023
64bb52c
Merge branch 'main' into onnx-backend
abetlen Oct 15, 2023
f46e8fb
Merge branch 'main' into onnx-backend
abetlen Oct 15, 2023
9350741
Save
dmille Oct 21, 2023
dfa64c4
Handle SIGABRT from GGML
dmille Oct 21, 2023
67f5c85
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
dmille Oct 21, 2023
0f4ddd6
Fix instance norm
dmille Oct 24, 2023
7140aa9
Fix sigmoid
dmille Oct 24, 2023
eb48457
Use tensor.contents address for shape dict key
dmille Nov 10, 2023
67d1e66
Handle permuted MatMul tensor input src1
dmille Nov 10, 2023
839fa96
Resize with restricted parameters implemented. Only nearest-neighbor …
dmille Nov 10, 2023
6065ce4
upscale using ggml_upscale
dmille Nov 21, 2023
119d2d2
Merge branch 'main' into onnx-backend
abetlen Nov 21, 2023
e5010ad
Update onnx runtime to latest ggml api
abetlen Nov 21, 2023
0eaaedb
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Nov 21, 2023
bb4c2fa
Remove IPython import
abetlen Nov 21, 2023
9224e03
Attempt fix python3.12 setuptools bug
abetlen Nov 21, 2023
0c4a0af
Temporarily disable python3.12 tests
abetlen Nov 21, 2023
5bbf656
Install onnx dependencies for metal test
abetlen Nov 21, 2023
89b5a4e
Fix windows tests
abetlen Nov 21, 2023
c881ba2
Fix concat, add cos and si
dmille Nov 22, 2023
9f4eb57
Copy tensor if permuted in Conv operator
dmille Nov 22, 2023
2508d6b
Merge branch 'onnx-backend' of github.com:abetlen/ggml-python into on…
abetlen Nov 22, 2023
33e643b
Fix
abetlen Nov 22, 2023
cd8759c
Merge branch 'main' into onnx-backend
abetlen Nov 23, 2023
e22d539
Remove unnused imports
abetlen Nov 24, 2023
bd997f0
Fix re-evaluate bug, allow for max tensors in graph to be set dynamic…
abetlen Nov 29, 2023
88a76fe
Merge branch 'main' into onnx-backend
abetlen Feb 12, 2024
0e61da7
Merge branch 'main' into onnx-backend
abetlen Feb 13, 2024
18a67cf
docs: Add achknowledgements
abetlen Feb 20, 2024
18f53eb
Temporarily disable setting data in from_numpy
abetlen Feb 20, 2024
66aa960
Test multiple ggml graph chaining
abetlen Feb 20, 2024
13686c4
Update ggml_gallocr_new signature
abetlen Feb 20, 2024
c27fd6e
Add debugging docs
abetlen Feb 20, 2024
9cf3fc7
Update onnx to new ggml alloc apis
abetlen Feb 20, 2024
33473e3
Merge branch 'main' into onnx-backend
abetlen Feb 21, 2024
62e116b
Merge branch 'main' into onnx-backend
abetlen Feb 25, 2024
91d0daa
Merge branch 'main' into onnx-backend
abetlen Feb 25, 2024
81d62a9
fix: test
abetlen Feb 25, 2024
32b8f36
Merge branch 'main' into onnx-backend
abetlen Feb 25, 2024
14a64fa
fix: Re-enable tensor set in from_numpy
abetlen Feb 25, 2024
fd5c79d
Track node shapes
abetlen Feb 28, 2024
7c8d10f
Add simple parameterized test to compare runtimes
abetlen Feb 28, 2024
e159755
Merge branch 'main' into onnx-backend
abetlen Feb 28, 2024
7d3c8ee
Add shape tracking to more ops
abetlen Feb 28, 2024
207ff2e
Fix more onnx ops
abetlen Mar 3, 2024
f862535
Merge branch 'main' into onnx-backend
abetlen Mar 3, 2024
ebd2c7c
Disable transpose test
abetlen Mar 3, 2024
a36f437
Merge branch 'main' into onnx-backend
abetlen Mar 4, 2024
58c092d
check ggml_status
abetlen Mar 4, 2024
af5996c
Merge branch 'main' into onnx-backend
abetlen Mar 4, 2024
522af2a
Merge branch 'main' into onnx-backend
abetlen Apr 8, 2024
80183bd
Update tests
abetlen Apr 8, 2024
e53bb98
Merge branch 'main' into onnx-backend
abetlen Apr 8, 2024
166fcdd
Update tensor allocator api
abetlen Apr 9, 2024
a91780b
Fix type issues
abetlen Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ on:

jobs:
build-linux:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -24,44 +23,46 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --verbose --editable .
python3 -m pip install --upgrade pip cmake scikit-build setuptools
python3 -m pip install --verbose --editable .[test,onnx,onnx-tests,convert]

- name: Test with pytest
run: |
python3 -m pytest

build-windows:

runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
with:
submodules: "true"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --verbose --editable .
python3 -m pip install --upgrade pip cmake scikit-build setuptools
python3 -m pip install --verbose --editable .[test,onnx,onnx-tests,convert]

- name: Test with pytest
run: |
python3 -m pytest

build-macos:

runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -71,10 +72,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --verbose --editable .
python3 -m pip install --upgrade pip cmake scikit-build setuptools
python3 -m pip install --verbose --editable .[test,onnx,onnx-tests,convert]

- name: Test with pytest
run: |
python3 -m pytest
Expand Down Expand Up @@ -119,7 +122,7 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --verbose --editable . --config-settings=cmake.args='-DGGML_METAL=On'
python3 -m pip install --verbose --editable .[test,onnx,onnx-tests,convert] --config-settings=cmake.args='-DGGML_METAL=On'
- name: Test with pytest
run: |
python3 -m pytest
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,30 @@ If you are having trouble installing `ggml-python` or activating specific featur
pip install ggml-python --verbose --no-cache-dir --force-reinstall --upgrade
```

# Debugging

## Error: `SIGSEGV` or `Aborted (core dumped)`

Godspeed! You are about to enter the world of debugging native code.
If you are seeing a `SIGSEGV` or `Aborted (core dumped)` error something has gone horribly wrong.
A good first step is to try to reproduce the error with a debug build of `ggml-python` and `ggml` and then use a debugger like `gdb` to step through the code and find the issue.


```bash
$ git clone https://github.com/abetlen/ggml-python.git
$ cd ggml-python
$ make build.debug # this preserves debug symbols
$ gdb --args python3 your_script.py
```

From there you can use `run` to start the script and `bt` to get a backtrace of native code and `py-bt` to get a backtrace of python code.

Additionally, you should use python's built in `breakpoint()` function to set breakpoints in your python code and step through the code.

# API Stability

This project is currently in alpha and the API is subject to change.

# License

This project is licensed under the terms of the MIT license.
152 changes: 152 additions & 0 deletions docs/contrib/onnx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# GGML ONNX Runtime

## Getting Started

### Installation

```bash
pip install ggml-python[onnx]
```

### Usage

```python
import onnx
from ggml.contrib.onnx import GgmlRuntimeBackend

# Load an ONNX model
model = onnx.load("model.onnx")

# Create a runtime session
ggml_backend_rep = GgmlRuntimeBackend.prepare(model)

# Run inference
input = np.random.randn(1, 3, 224, 224).astype(np.float32)
output = ggml_backend_rep.run([input])
```

## Technical Overview

The GGML ONNX runtime is a backend for the [ONNX](https://onnx.ai/) model format. It is designed to be used as a drop-in replacement for the ONNX Runtime which leverages ggml for efficient model inference on a wide range of devices.

To use the runtime:

- Models are first converted from PyTorch, TensorFlow, and other frameworks to ONNX
- ONNX models are then optimized for ggml inference. This includes:
- Weight Quantization
- Dynamic Subgraph Detection
- GPU Offloading
- The optimized ONNX models are then executed in the GGML ONNX runtime


## Operator Support

This table is generated from [`operator_sets.h`](https://github.com/onnx/onnx/blob/main/onnx/defs/operator_sets.h) and may not include all ONNX operators. These are core operators available in all versions starting from ai.onnx version 1.

| ONNX Operator | Status | Implementation Method |
|:--------------------------------------------------------------------------------------------------|:------------------:|:----------------|
| [Abs](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Abs) | :white_check_mark: | `ggml_abs` |
| [Add](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Add) | :white_check_mark: | `ggml_add` |
| [And](https://github.com/onnx/onnx/blob/main/docs/Operators.md#And) | :white_check_mark: | |
| [ArgMax](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ArgMax) | :white_check_mark: | |
| [ArgMin](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ArgMin) | :white_check_mark: | |
| [AveragePool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#AveragePool) | | |
| [BatchNormalization](https://github.com/onnx/onnx/blob/main/docs/Operators.md#BatchNormalization) | | |
| [Cast](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Cast) | :white_check_mark: | |
| [Ceil](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Ceil) | :white_check_mark: | |
| [Clip](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Clip) | | |
| [Concat](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Concat) | :white_check_mark: | `ggml_concat` |
| [Constant](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Constant) | :white_check_mark: | |
| [ConstantOfShape](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ConstantOfShape) | :white_check_mark: | |
| [Conv](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Conv) | ⚙️ (in progress) | |
| [ConvTranspose](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ConvTranspose) | ⚙️ (in progress) | |
| [DepthToSpace](https://github.com/onnx/onnx/blob/main/docs/Operators.md#DepthToSpace) | :white_check_mark: | |
| [Div](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Div) | :white_check_mark: | `ggml_div` |
| [Dropout](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Dropout) | ⚙️ (in progress) | |
| [Elu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Elu) | :white_check_mark: | `ggml_elu` |
| [Equal](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Equal) | :white_check_mark: | |
| [Exp](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Exp) | :white_check_mark: | |
| [Flatten](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Flatten) | :white_check_mark: | |
| [Floor](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Floor) | :white_check_mark: | |
| [GRU](https://github.com/onnx/onnx/blob/main/docs/Operators.md#GRU) | :x: | |
| [Gather](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gather) | :white_check_mark: | |
| [Gemm](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Gemm) | :white_check_mark: | |
| [GlobalAveragePool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#GlobalAveragePool) | | |
| [GlobalLpPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#GlobalLpPool) | | |
| [GlobalMaxPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#GlobalMaxPool) | | |
| [Greater](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Greater) | :white_check_mark: | |
| [HardSigmoid](https://github.com/onnx/onnx/blob/main/docs/Operators.md#HardSigmoid) | :white_check_mark: | |
| [Hardmax](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Hardmax) | :white_check_mark: | |
| [Identity](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Identity) | :white_check_mark: | |
| [If](https://github.com/onnx/onnx/blob/main/docs/Operators.md#If) | :x: | |
| [InstanceNormalization](https://github.com/onnx/onnx/blob/main/docs/Operators.md#InstanceNormalization)| :white_check_mark: | |
| [LRN](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LRN) | :white_check_mark: | |
| [LSTM](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LSTM) | :x: | |
| [LeakyRelu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LeakyRelu) | ⚙️ | |
| [Less](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Less) | :white_check_mark: | |
| [Log](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Log) | :white_check_mark: | `ggml_log` |
| [LogSoftmax](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LogSoftmax) | :white_check_mark: | |
| [Loop](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Loop) | :x: | |
| [LpNormalization](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LpNormalization) |:x: (Test case not provided)| |
| [LpPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#LpPool) | | |
| [MatMul](https://github.com/onnx/onnx/blob/main/docs/Operators.md#MatMul) | :white_check_mark: | `ggml_mul_mat` |
| [Max](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Max) | :white_check_mark: | `ggml_max` |
| [MaxPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#MaxPool) | |`ggml.ggml_pool_2d`|
| [MaxRoiPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#MaxRoiPool) | | |
| [Mean](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Mean) | :white_check_mark: |~~`ggml_mean`~~<br />`ggml_add` + `ggml_div`|
| [Min](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Min) | :white_check_mark: | |
| [Mul](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Mul) | :white_check_mark: | `ggml_mul` |
| [Neg](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Neg) | :white_check_mark: | `ggml_neg` |
| [Not](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Not) | :white_check_mark: | |
| [Or](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Or) | :white_check_mark: | |
| [PRelu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#PRelu) | :white_check_mark: | |
| [Pad](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Pad) | | |
| [Pow](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Pow) | :white_check_mark: | |
| [RNN](https://github.com/onnx/onnx/blob/main/docs/Operators.md#RNN) | :x: | |
| [RandomNormal](https://github.com/onnx/onnx/blob/main/docs/Operators.md#RandomNormal) |:x: (Test case not provided)| |
| [RandomNormalLike](https://github.com/onnx/onnx/blob/main/docs/Operators.md#RandomNormalLike) |:x: (Test case not provided)| |
| [RandomUniform](https://github.com/onnx/onnx/blob/main/docs/Operators.md#RandomUniform) |:x: (Test case not provided)| |
| [RandomUniformLike](https://github.com/onnx/onnx/blob/main/docs/Operators.md#RandomUniformLike) |:x: (Test case not provided)| |
| [Reciprocal](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Reciprocal) | :white_check_mark: | |
| [ReduceL1](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceL1) | :white_check_mark: | |
| [ReduceL2](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceL2) | :white_check_mark: | |
| [ReduceLogSum](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceLogSum) | :white_check_mark: | |
| [ReduceLogSumExp](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceLogSumExp) | ⚙️ | |
| [ReduceMax](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceMax) | :white_check_mark: | |
| [ReduceMean](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceMean) | :white_check_mark: | |
| [ReduceMin](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceMin) | :white_check_mark: | |
| [ReduceProd](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceProd) | :white_check_mark: | |
| [ReduceSum](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceSum) | :white_check_mark: | |
| [ReduceSumSquare](https://github.com/onnx/onnx/blob/main/docs/Operators.md#ReduceSumSquare) | :white_check_mark: | |
| [Relu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Relu) | :white_check_mark: | `ggml_relu` |
| [Reshape](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Reshape) | :white_check_mark: | `ggml_reshape` |
| [Selu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Selu) | :white_check_mark: | |
| [Shape](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Shape) | :white_check_mark: | |
| [Sigmoid](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Sigmoid) | :white_check_mark: | |
| [Size](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Size) | :white_check_mark: | |
| [Slice](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Slice) | | |
| [Softmax](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Softmax) | :white_check_mark: | `ggml_soft_max` |
| [Softplus](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Softplus) | :white_check_mark: | |
| [Softsign](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Softsign) | :white_check_mark: | |
| [SpaceToDepth](https://github.com/onnx/onnx/blob/main/docs/Operators.md#SpaceToDepth) | :white_check_mark: | |
| [Split](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Split) | :white_check_mark: | |
| [Sqrt](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Sqrt) | :white_check_mark: | `ggml_sqrt` |
| [Squeeze](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Squeeze) | :white_check_mark: | |
| [Sub](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Sub) | :white_check_mark: | `ggml_sub` |
| [Sum](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Sum) | :white_check_mark: | `ggml_sum` |
| [Tanh](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Tanh) | :white_check_mark: | `ggml_tanh` |
| [Tile](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Tile) | :white_check_mark: | |
| [TopK](https://github.com/onnx/onnx/blob/main/docs/Operators.md#TopK) | :white_check_mark: | |
| [Transpose](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Transpose) | :white_check_mark: | `ggml_transpose` |
| [Unsqueeze](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Unsqueeze) | :white_check_mark: | |
| ~~[Upsample](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Upsample)~~ | :x: (Deprecated) | |
| [Xor](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Xor) | :white_check_mark: | |

## Acknowledgements

The GGML ONNX runtime is built on top of the [ONNX](https://onnx.ai/) and [GGML](ggml.ai)

The core of the runtime was written by Andrei Betlen (@abetlen), David Miller (@dmille), and
Mohammadreza Anvari (@mrezanvari)

This work would also not be possible without the ggml community, in particular @slaren for their work on the ggml backends and memory allocation api.
1 change: 1 addition & 0 deletions examples/instructor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
instructor_base_onnx/
Loading