ONNX backed array library compliant with Array API standard.
Project description
ndonnx
An ONNX-backed array library that is compliant with the Array API standard.
Installation
Releases are available on PyPI and conda-forge.
# using pip
pip install ndonnx
# using conda
conda install ndonnx
# using pixi
pixi add ndonnx
Development
You can install the package in development mode using:
git clone https://github.com/quantco/ndonnx
cd ndonnx
# For Array API tests
git submodule update --init --recursive
pixi shell
pre-commit run -a
pip install --no-build-isolation --no-deps -e .
pytest tests -n auto
Quick start
ndonnx is an ONNX based python array library.
It has a couple of key features:
-
It implements the
Array APIstandard. Standard compliant code can be executed without changes across numerous backends such as like NumPy, JAX and now ndonnx.import numpy as np import ndonnx as ndx import jax.numpy as jnp def mean_drop_outliers(a, low=-5, high=5): xp = a.__array_namespace__() return xp.mean(a[(low < a) & (a < high)]) np_result = mean_drop_outliers(np.asarray([-10, 0.5, 1, 5])) jax_result = mean_drop_outliers(jnp.asarray([-10, 0.5, 1, 5])) onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5])) assert np_result == onnx_result.unwrap_numpy() == jax_result == 0.75
-
It supports ONNX export. This allows you persist your logic into an ONNX computation graph.
import ndonnx as ndx import onnx # Instantiate placeholder ndonnx array x = ndx.array(shape=("N",), dtype=ndx.float32) y = mean_drop_outliers(x) # Build and save ONNX model to disk model = ndx.build({"x": x}, {"y": y}) onnx.save(model, "mean_drop_outliers.onnx")
You can then make predictions using a runtime of your choice.
import onnxruntime as ort import numpy as np inference_session = ort.InferenceSession("mean_drop_outliers.onnx") prediction, = inference_session.run(None, { "x": np.array([-10, 0.5, 1, 5], dtype=np.float32), }) assert prediction == 0.75
In the future we will be enabling a stable API for an extensible data type system. This will allow users to define their own data types and operations on arrays with these data types.
Array API coverage
Array API compatibility tested against the official array-api-tests suite.
Missing coverage is tracked in the skips.txt file.
Contributions are welcome!
Run the tests with:
pixi run arrayapitests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ndonnx-0.19.0.tar.gz.
File metadata
- Download URL: ndonnx-0.19.0.tar.gz
- Upload date:
- Size: 366.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08528933dca70f22d80681c90ec9728fe6430c100118a599888d4110c53e2d00
|
|
| MD5 |
831b1ab4f83a1c527dc7f0cd9779df53
|
|
| BLAKE2b-256 |
eb88bdebb0d04384fda69cfd909a9de3d178d0d97ebcc4e5f71f8bf9b9d2f3c7
|
Provenance
The following attestation bundles were made for ndonnx-0.19.0.tar.gz:
Publisher:
build.yml on Quantco/ndonnx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ndonnx-0.19.0.tar.gz -
Subject digest:
08528933dca70f22d80681c90ec9728fe6430c100118a599888d4110c53e2d00 - Sigstore transparency entry: 1547071906
- Sigstore integration time:
-
Permalink:
Quantco/ndonnx@6be20b3884b7151632c0b4f5809ab1a47fefa3c2 -
Branch / Tag:
refs/tags/0.19.0 - Owner: https://github.com/Quantco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@6be20b3884b7151632c0b4f5809ab1a47fefa3c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ndonnx-0.19.0-py3-none-any.whl.
File metadata
- Download URL: ndonnx-0.19.0-py3-none-any.whl
- Upload date:
- Size: 83.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1793c988d93bd9936f5952f8324fdc7fd37f86aa928b24bfe5cd578036b4cb7c
|
|
| MD5 |
b876709a8400c1e5cf6a0adcad77304f
|
|
| BLAKE2b-256 |
e8ffc328d49ae678b2b9acc56ea35ac49181f2a68033f6916bc67dac13df38f0
|
Provenance
The following attestation bundles were made for ndonnx-0.19.0-py3-none-any.whl:
Publisher:
build.yml on Quantco/ndonnx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ndonnx-0.19.0-py3-none-any.whl -
Subject digest:
1793c988d93bd9936f5952f8324fdc7fd37f86aa928b24bfe5cd578036b4cb7c - Sigstore transparency entry: 1547071918
- Sigstore integration time:
-
Permalink:
Quantco/ndonnx@6be20b3884b7151632c0b4f5809ab1a47fefa3c2 -
Branch / Tag:
refs/tags/0.19.0 - Owner: https://github.com/Quantco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@6be20b3884b7151632c0b4f5809ab1a47fefa3c2 -
Trigger Event:
push
-
Statement type: