ONNXRuntime Extensions
Project description
ONNXRuntime-Extensions
What's ONNXRuntime-Extensions
Introduction: ONNXRuntime-Extensions is a library that extends the capability of the ONNX models and inference with ONNX Runtime, via ONNX Runtime Custom Operator ABIs. It includes a set of ONNX Runtime Custom Operator to support the common pre- and post-processing operators for vision, text, and nlp models. And it supports multiple languages and platforms, like Python on Windows/Linux/macOS, some mobile platforms like Android and iOS, and Web-Assembly etc. The basic workflow is to enhance a ONNX model firstly and then do the model inference with ONNX Runtime and ONNXRuntime-Extensions package.
⚠️ | NOTE: most ONNXRuntime-Extensions packages are in active development and most packages require building from source. The package information will be updated here if it is published. |
Quickstart with the experimental Python package
on Windows
pip install --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ onnxruntime-extensions
on Linux/macOS
the packages are not ready yet, so it could be installed from source. Please make sure the compiler toolkit like gcc(later than g++ 8.0) or clang, and the tool cmake are installed before the following command
python -m pip install git+https://github.com/microsoft/onnxruntime-extensions.git
Usage
1. Augment an ONNX model with a pre- and post-processing pipeline
check tutorial for a couple of examples on how to do it.
2. Using Extensions for ONNX Runtime inference
Python
import onnxruntime as _ort
from onnxruntime_extensions import get_library_path as _lib_path
so = _ort.SessionOptions()
so.register_custom_ops_library(_lib_path())
# Run the ONNXRuntime Session, as ONNXRuntime docs suggested.
# sess = _ort.InferenceSession(model, so)
# sess.run (...)
C++
// The line loads the customop library into ONNXRuntime engine to load the ONNX model with the custom op
Ort::ThrowOnError(Ort::GetApi().RegisterCustomOpsLibrary((OrtSessionOptions*)session_options, custom_op_library_filename, &handle));
// The regular ONNXRuntime invoking to run the model.
Ort::Session session(env, model_uri, session_options);
RunSession(session, inputs, outputs);
Java
var env = OrtEnvironment.getEnvironment();
var sess_opt = new OrtSession.SessionOptions();
/* Register the custom ops from onnxruntime-extensions */
sess_opt.registerCustomOpLibrary(OrtxPackage.getLibraryPath());
Use exporters to generate graphs with custom operators
The PyTorch and TensorFlow converters support custom operator generation if the operation from the original framework cannot be interpreted as a standard ONNX operators. Check the following two examples on how to do this.
Add a new custom operator to onnxruntime-extensions
You can contribute customop C++ implementations directly in this repository if they have general applicability to other users. In addition, if you want to quickly verify the ONNX model with Python, you can wrap the custom operator with PyOp.
import numpy
from onnxruntime_extensions import PyOp, onnx_op
# Implement the CustomOp by decorating a function with onnx_op
@onnx_op(op_type="Inverse", inputs=[PyOp.dt_float])
def inverse(x):
# the user custom op implementation here:
return numpy.linalg.inv(x)
# Run the model with this custom op
# model_func = PyOrtFunction(model_path)
# outputs = model_func(inputs)
# ...
Check development.md for build and test
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 Distributions
Built Distributions
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c21bbd4ca967bad8f6534836dd25d1f46f1eb70ba4559e3edda7a8ef93e2339 |
|
MD5 | 67da2642c186fa32830a96b26ffb285f |
|
BLAKE2b-256 | 1812275eaeea1f436f7ca9539c2c880866de2b4cf8222160cd9bd672fc38b135 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49fb6091dea9e99976442c6872cd6341ca27f527799b85b89b3cec5418deb802 |
|
MD5 | 4d6f628bc21dc89d50b222b9ff2a6bc1 |
|
BLAKE2b-256 | 36fa0d6e4593f61228bc67e839dcc29451387b6768269f1484fe46a7fbbfa9e2 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b589da7a60ae3ed0163f99d775f92a296160faf54e36f2ff521229d87c36c0 |
|
MD5 | f46e0f703181b7f5b399951a3b2761f4 |
|
BLAKE2b-256 | b71a6570381460d97a7fab488307287477c87614aab4e30c74c31969980cce14 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6801ac19ff66d97f23394cb1f40fff5ce05fbbde3a12186dbfc2f3088ca82a8 |
|
MD5 | b632ba1b002f46bed41e00aa4ffeac4d |
|
BLAKE2b-256 | 74c0b44a87e6aaae288eb6d1ee0b0188bbb7756f58071e81c51e10cf3f299396 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 680fe084bc34976c4fc7669f9e0ce19273effbd2741ed0996b11a487cbd4ab4a |
|
MD5 | b56441caa03a9cc29a6c0199a30ea5f4 |
|
BLAKE2b-256 | fc24c21274f4f9126afe7488ba53a7f6d8b44fe2828bf54d68fb05fe8dbdfcd0 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_universal2.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70f5a82082357521127b5b52fe3c7912558412c00061737e1b14a4b23691506c |
|
MD5 | d3f6d84113a04e625d05f55d8d405f13 |
|
BLAKE2b-256 | 3d7a2dc79e89eee6e103a4e395321191249b16f6ec42f16474816b722cdf7368 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d854c77cd2013498666b5e3810a2955a777abca487d6804ff0758be5aa08f106 |
|
MD5 | 5d9ee468408f25ba535e33c5aed69d9d |
|
BLAKE2b-256 | 2bee66a6201d4fa4c6ce90eb7bf78b80431a1721b3d79f2b7095849831b9b306 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 285308f39129e32810f7a38f0a06f3e54ed1d15036651fae93dceee0375de852 |
|
MD5 | b24cf7bb833debd96bdde32a4b2e9c1f |
|
BLAKE2b-256 | 8bc13e372cc8ea1c57c4b8bd74ed2cf8c29047eacc76deaecadb5d180f9a8259 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec50d8636768b18b0daaf756046e2ad0eb9f60472263f01c1384b9a255b7b196 |
|
MD5 | e3a175a87f34ab320061d930da7852ff |
|
BLAKE2b-256 | 2fd71bdf6f31b748faf00d18f8a0b12b07c86f75f662c0b25b41a6761e976ffd |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efead65e2ec903749f10ae65aedb2e77c0b6e58f810e9f1007b4197e02479b0b |
|
MD5 | 5df35aadb6521f94a73d365599190a94 |
|
BLAKE2b-256 | 094cb2cce3f0fa524f8065edffbfcd7051c2a3c5f9fb8dae7614284acf950540 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fce78766b46e0573e6ff2a70a54e3da00cd20c4a59e5a4a3638be87822fccdc8 |
|
MD5 | 3541ac4da93e02bc491a0fdbcd31e20f |
|
BLAKE2b-256 | a51bdd426b39f7d82eb75714a6d33bb583d33beb8b466cd334a42b447354bc17 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_universal2.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bd7d175952b77834becde5c5ec97895311930a757fa16cb5ac7c1442e888b4b |
|
MD5 | 79ea4dad2e2e729590caadc29c4720d3 |
|
BLAKE2b-256 | e2456604600394192d65d20402d839a59da3f3c44fa017ba332581ef37d00c43 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96db8d365b5805e007b57939105903cbd3dfa9b919908feda5d3e962cd496213 |
|
MD5 | 326c8b8636c546892760685918d8bbe0 |
|
BLAKE2b-256 | 48537f50f602de4466236215cc3fcf0171f39b27b19892da39d6ee850494dc34 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f789d6d5923ef10e96737e8bcd27d226f1eff7076b470261fe597d3fd3a1b637 |
|
MD5 | f4385d567a751257ded87d0feb365cee |
|
BLAKE2b-256 | fa04885455047e26dae4f2ecbed0a4de229c0244977d37b3555f24e97a32f9de |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0666a35b6ef622d44abac9a3cb139e33b1e09c937b0b21edb4313cc3f787d4d0 |
|
MD5 | ce8667c3b148c837b8181f32d4b967e7 |
|
BLAKE2b-256 | 0aeee4931280909d7712c14e387b6566928fd2895044e48415e20d6b80286da1 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4a91717ef577b3b775c847a44e90a5eabede8e4b4c0bc167e839e81cfca4cf9 |
|
MD5 | 4391524fd743d718dd485fe79447c58a |
|
BLAKE2b-256 | 914eee29fca06ad403d72fb02f11adc3c2af1cbc61277595999d2fd98f1f961c |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f63a2387e4c2a60a94618729f3e7ed01eef816d9711744cd6cdc740cdc947ed |
|
MD5 | 1fc330a0a9ac517a5de8c2cc6e85ff1c |
|
BLAKE2b-256 | 428fe46746283c6b3e69a7f185be07c0942851b4942ffbe794834fbd7a750752 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_universal2.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_universal2.whl
- Upload date:
- Size: 3.7 MB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a58eaabe5716519481af2a166f4f7f4a6418a040f2909d6eaf4cb8cae02825d1 |
|
MD5 | 89527b143bdd78ce791135ea44a0bcbc |
|
BLAKE2b-256 | 894122d55240eb0b537789ae2822a60557316eebcf123c9f67b537dd1390e256 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6f92183b482f3df2ee5bce2be98a923e19eeebfa25e95fa5ea5c45fe75847da |
|
MD5 | 72f666b73ef0e0af270e9bf8eb367fef |
|
BLAKE2b-256 | 8f01312c9c73293c0bb84567892058738318f9767afda1fd7a525fa7b181654b |
File details
Details for the file onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4cc979b6f5586d9bcfde2687bfcfcbf7fa1afc95477a203b522162521aa3e7c |
|
MD5 | a00ea5df7e15f33620cb3a4a0949e344 |
|
BLAKE2b-256 | 41aa7c4024a59ec1f509cc29e57ab26959141556502433ff2e82bf438853a6e7 |
File details
Details for the file onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a5a29d454f90a07018b79f18ee6c1b7eb48d3e567efe3428aa74fb74de684d1 |
|
MD5 | ceeaf8df5a30d19a2c8af60ca2af80e9 |
|
BLAKE2b-256 | 173a041f4e7550301b56f4ba2d0a87b7db04dc6fc551faa16c6e39011ad6ae1d |