Name | ndonnx JSON |
Version |
0.9.3
JSON |
| download |
home_page | None |
Summary | ONNX backed array library compliant with Array API standard. |
upload_time | 2024-10-25 09:19:19 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
numpy
onnx
array-api
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ndonnx
[![CI](https://img.shields.io/github/actions/workflow/status/quantco/ndonnx/ci.yml?style=flat-square&branch=main)](https://github.com/quantco/ndonnx/actions/workflows/ci.yml)
[![Documentation](https://readthedocs.org/projects/ndonnx/badge/?version=latest)](https://ndonnx.readthedocs.io/en/latest/?badge=latest)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/ndonnx?style=flat-square&logoColor=white&logo=conda-forge)](https://anaconda.org/conda-forge/ndonnx)
[![pypi](https://img.shields.io/pypi/v/ndonnx.svg?logo=pypi&logoColor=white)](https://pypi.org/project/ndonnx)
An ONNX-backed array library that is compliant with the [Array API](https://data-apis.org/array-api/) standard.
## Installation
Releases are available on PyPI and conda-forge.
```bash
# 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:
```bash
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 API`](https://data-apis.org/array-api/) standard. Standard compliant code can be executed without changes across numerous backends such as like `NumPy`, `JAX` and now `ndonnx`.
```python
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.to_numpy() == jax_result == 0.75
```
- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.
```python
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.
```python
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 is tracked in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!
Summary(1119 total):
- 961 passed
- 107 failed
- 51 deselected
Run the tests with:
```bash
pixi run arrayapitests
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ndonnx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "numpy, onnx, array-api",
"author": null,
"author_email": "Aditya Goel <agoel4512@gmail.com>, Christian Bourjau <christian.bourjau@quantco.com>",
"download_url": "https://files.pythonhosted.org/packages/39/23/8bb224d332b3e0a568c4383901fea50fb6d6f1ce2579751756f85d3d2cb6/ndonnx-0.9.3.tar.gz",
"platform": null,
"description": "# ndonnx\n\n[![CI](https://img.shields.io/github/actions/workflow/status/quantco/ndonnx/ci.yml?style=flat-square&branch=main)](https://github.com/quantco/ndonnx/actions/workflows/ci.yml)\n[![Documentation](https://readthedocs.org/projects/ndonnx/badge/?version=latest)](https://ndonnx.readthedocs.io/en/latest/?badge=latest)\n[![conda-forge](https://img.shields.io/conda/vn/conda-forge/ndonnx?style=flat-square&logoColor=white&logo=conda-forge)](https://anaconda.org/conda-forge/ndonnx)\n[![pypi](https://img.shields.io/pypi/v/ndonnx.svg?logo=pypi&logoColor=white)](https://pypi.org/project/ndonnx)\n\nAn ONNX-backed array library that is compliant with the [Array API](https://data-apis.org/array-api/) standard.\n\n## Installation\n\nReleases are available on PyPI and conda-forge.\n\n```bash\n# using pip\npip install ndonnx\n# using conda\nconda install ndonnx\n# using pixi\npixi add ndonnx\n```\n\n## Development\n\nYou can install the package in development mode using:\n\n```bash\ngit clone https://github.com/quantco/ndonnx\ncd ndonnx\n\n# For Array API tests\ngit submodule update --init --recursive\n\npixi shell\npre-commit run -a\npip install --no-build-isolation --no-deps -e .\npytest tests -n auto\n```\n\n## Quick start\n\n`ndonnx` is an ONNX based python array library.\n\nIt has a couple of key features:\n\n- It implements the [`Array API`](https://data-apis.org/array-api/) standard. Standard compliant code can be executed without changes across numerous backends such as like `NumPy`, `JAX` and now `ndonnx`.\n\n ```python\n import numpy as np\n import ndonnx as ndx\n import jax.numpy as jnp\n\n def mean_drop_outliers(a, low=-5, high=5):\n xp = a.__array_namespace__()\n return xp.mean(a[(low < a) & (a < high)])\n\n np_result = mean_drop_outliers(np.asarray([-10, 0.5, 1, 5]))\n jax_result = mean_drop_outliers(jnp.asarray([-10, 0.5, 1, 5]))\n onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5]))\n\n assert np_result == onnx_result.to_numpy() == jax_result == 0.75\n ```\n\n- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.\n\n ```python\n import ndonnx as ndx\n import onnx\n\n # Instantiate placeholder ndonnx array\n x = ndx.array(shape=(\"N\",), dtype=ndx.float32)\n y = mean_drop_outliers(x)\n\n # Build and save ONNX model to disk\n model = ndx.build({\"x\": x}, {\"y\": y})\n onnx.save(model, \"mean_drop_outliers.onnx\")\n ```\n\n You can then make predictions using a runtime of your choice.\n\n ```python\n import onnxruntime as ort\n import numpy as np\n\n inference_session = ort.InferenceSession(\"mean_drop_outliers.onnx\")\n prediction, = inference_session.run(None, {\n \"x\": np.array([-10, 0.5, 1, 5], dtype=np.float32),\n })\n assert prediction == 0.75\n ```\n\nIn 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.\n\n## Array API coverage\n\nArray API compatibility is tracked in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!\n\nSummary(1119 total):\n\n- 961 passed\n- 107 failed\n- 51 deselected\n\nRun the tests with:\n\n```bash\npixi run arrayapitests\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "ONNX backed array library compliant with Array API standard.",
"version": "0.9.3",
"project_urls": {
"repository": "https://github.com/quantco/ndonnx"
},
"split_keywords": [
"numpy",
" onnx",
" array-api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "be8abe0346856879cda6c3b09b5aac327e791c4050fe78c8b4f4992359b60d27",
"md5": "a740b3e73e8704079b11e990925d52f7",
"sha256": "c9e9759440b15106a483bf9752cecad863a422262da1590fa0b8a08263ed5a64"
},
"downloads": -1,
"filename": "ndonnx-0.9.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a740b3e73e8704079b11e990925d52f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 54462,
"upload_time": "2024-10-25T09:19:18",
"upload_time_iso_8601": "2024-10-25T09:19:18.550465Z",
"url": "https://files.pythonhosted.org/packages/be/8a/be0346856879cda6c3b09b5aac327e791c4050fe78c8b4f4992359b60d27/ndonnx-0.9.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "39238bb224d332b3e0a568c4383901fea50fb6d6f1ce2579751756f85d3d2cb6",
"md5": "9623c4e0e0cb0906c81772e192dd0821",
"sha256": "05b4acb485bd99e1e410cb67bf0e73440325ee38927783fa9103dcb0a1471430"
},
"downloads": -1,
"filename": "ndonnx-0.9.3.tar.gz",
"has_sig": false,
"md5_digest": "9623c4e0e0cb0906c81772e192dd0821",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 307804,
"upload_time": "2024-10-25T09:19:19",
"upload_time_iso_8601": "2024-10-25T09:19:19.549986Z",
"url": "https://files.pythonhosted.org/packages/39/23/8bb224d332b3e0a568c4383901fea50fb6d6f1ce2579751756f85d3d2cb6/ndonnx-0.9.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-25 09:19:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "quantco",
"github_project": "ndonnx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ndonnx"
}