You will need to install protobuf and numpy to build ONNX. An easy way to get these dependencies is via Anaconda:
# Use conda-forge protobuf, as defaults doesn't come with protoc
conda install -c conda-forge protobuf numpy
During development, it's convenient to install ONNX in development mode (for ONNX-ML, set environment variable ONNX_ML=1
):
git clone --recursive https://github.com/onnx/onnx.git
pip install -e onnx/
Then, after you have made changes to Python and C++ files:
Python files
: the changes are effective immediately in your installation. You don't need to install these again.C++ files
: you need to install these again to trigger the native extension build.
onnx/
: the main folder that all code lies underonnx.proto
: the protobuf (v2.6.1) that contains all the structureschecker.py
: a utility to check whether a serialized ONNX proto is legalhelper.py
: tools for graph operationdefs/
: a subfolder that defines the ONNX operatorstest/
: test files
Operator docs in Operators.md are automatically generated based on C++ operator definitions. To refresh these docs, run the following command from the repo root and commit the results:
python onnx/defs/gen_doc.py
ONNX uses pytest as a test driver. To run tests, you'll first need to install pytest:
pip install pytest-cov nbval
After installing pytest, run
pytest
to begin the tests.