Skip to content

Commit

Permalink
dialects: (onnx) remove ONNX-related code (#3738)
Browse files Browse the repository at this point in the history
ONNX, which I was hoping would be a convenient way to define NNs in
Python to then compile using xDSL, has proven to be a massive
maintenance burden, and generally not very good. They are slow to
support new Python versions, poor typing support, and the import
mechanism is not very stable, so I couldn't even reliably import
networks. Our code for it is fairly buggy, and the bug fixes weren't all
merged before Kayode finished his masters project.

Given Quidditch and IREE's support for importing ONNX, I don't see the
point of having our implementation in xDSL, hence this PR.
  • Loading branch information
superlopuh authored Jan 13, 2025
1 parent e8de136 commit e30ec3b
Show file tree
Hide file tree
Showing 28 changed files with 9 additions and 4,765 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/ci-mlir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ jobs:
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/
uv run pytest --nbval docs/mlir_interoperation.ipynb --maxfail 1 -vv
- name: Test ONNX-dependent marimo notebooks
run: |
cd xdsl
# Add mlir-opt to the path
export PATH=$PATH:${GITHUB_WORKSPACE}/llvm-project/build/bin/
uv run make tests-marimo-onnx
- name: Combine coverage data
run: |
cd xdsl
Expand Down
22 changes: 1 addition & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,10 @@ tests-marimo: uv-installed
done
@echo "All marimo tests passed successfully."

.PHONY: tests-marimo-onnx
tests-marimo-onnx: uv-installed
@if uv run python -c "import onnx" > /dev/null 2>&1; then \
echo "onnx is installed, running tests."; \
if ! command -v mlir-opt > /dev/null 2>&1; then \
echo "MLIR is not installed, skipping tests."; \
exit 0; \
fi; \
for file in docs/marimo/onnx/*.py; do \
echo "Running $$file"; \
error_message=$$(uv run python3 "$$file" 2>&1) || { \
echo "Error running $$file"; \
echo "$$error_message"; \
exit 1; \
}; \
done; \
echo "All marimo onnx tests passed successfully."; \
else \
echo "onnx is not installed, skipping tests."; \
fi

# run all tests
.PHONY: tests-functional
tests-functional: pytest tests-toy filecheck pytest-nb tests-marimo tests-marimo-onnx
tests-functional: pytest tests-toy filecheck pytest-nb tests-marimo
@echo All functional tests done.

# run all tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ In order to keep the set of dependencies ot a minimum, these extra dependencies
specified explicitly. To install these, use:

``` bash
pip install xdsl[gui,jax,riscv,onnx]
pip install xdsl[gui,jax,riscv]
```

To install the testing/development dependencies, use:
Expand Down
4 changes: 2 additions & 2 deletions docs/marimo/__marimo__/linalg_snitch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
"riscv_op_counter = OpCounter()\n",
"riscv_interpreter = Interpreter(riscv_module, listeners=(riscv_op_counter,))\n",
"\n",
"register_implementations(riscv_interpreter, riscv_ctx, include_onnx=False)\n",
"register_implementations(riscv_interpreter, riscv_ctx)\n",
"\n",
"riscv_interpreter.call_op(\"matmul\", (a_shaped.data_ptr.raw, b_shaped.data_ptr.raw, riscv_c_shaped.data_ptr.raw))\n",
"\n",
Expand Down Expand Up @@ -633,7 +633,7 @@
"\n",
"snitch_c_shaped = ShapedArray(TypedPtr.new_float64([0.0] * c_len), c_shape)\n",
"\n",
"register_implementations(snitch_interpreter, snitch_stream_ctx, include_onnx=False)\n",
"register_implementations(snitch_interpreter, snitch_stream_ctx)\n",
"\n",
"snitch_interpreter.call_op(\n",
" \"matmul\",\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/marimo/linalg_snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def _(TypedPtr, a_shape, b_shape, c_shape, mo, riscv_ctx, riscv_module):
riscv_op_counter = OpCounter()
riscv_interpreter = Interpreter(riscv_module, listeners=(riscv_op_counter,))

register_implementations(riscv_interpreter, riscv_ctx, include_onnx=False)
register_implementations(riscv_interpreter, riscv_ctx)

riscv_interpreter.call_op("matmul", (a_shaped.data_ptr.raw, b_shaped.data_ptr.raw, riscv_c_shaped.data_ptr.raw))

Expand Down Expand Up @@ -566,7 +566,7 @@ def _(

snitch_c_shaped = ShapedArray(TypedPtr.new_float64([0.0] * c_len), c_shape)

register_implementations(snitch_interpreter, snitch_stream_ctx, include_onnx=False)
register_implementations(snitch_interpreter, snitch_stream_ctx)

snitch_interpreter.call_op(
"matmul",
Expand Down
4 changes: 0 additions & 4 deletions docs/marimo/onnx/README.md

This file was deleted.

Loading

0 comments on commit e30ec3b

Please sign in to comment.