Skip to main content

ONNXRuntime-Extensions

Build Status

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.

  1. CustomOp conversion by pytorch.onnx.exporter
  2. CustomOp conversion by tf2onnx

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

Release files for onnxruntime_extensions 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for onnxruntime_extensions 0.7.0
File
onnxruntime_extensions-0.7.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-32 Details
onnxruntime_extensions-0.7.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_universal2.whl CPython 3.10 CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) Details
onnxruntime_extensions-0.7.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-32 Details
onnxruntime_extensions-0.7.0-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_universal2.whl CPython 3.9 CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) Details
onnxruntime_extensions-0.7.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-32 Details
onnxruntime_extensions-0.7.0-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details
onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_universal2.whl CPython 3.8 CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) Details
onnxruntime_extensions-0.7.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-32 Details

Total release size: 70.6 MB

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-win_amd64.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-win_amd64.whl
Size 1.6 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
8c21bbd4ca967bad8f6534836dd25d1f46f1eb70ba4559e3edda7a8ef93e2339
BLAKE2b-256 checksum
How to use checksums
1812275eaeea1f436f7ca9539c2c880866de2b4cf8222160cd9bd672fc38b135
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
49fb6091dea9e99976442c6872cd6341ca27f527799b85b89b3cec5418deb802
BLAKE2b-256 checksum
How to use checksums
36fa0d6e4593f61228bc67e839dcc29451387b6768269f1484fe46a7fbbfa9e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
07b589da7a60ae3ed0163f99d775f92a296160faf54e36f2ff521229d87c36c0
BLAKE2b-256 checksum
How to use checksums
b71a6570381460d97a7fab488307287477c87614aab4e30c74c31969980cce14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b6801ac19ff66d97f23394cb1f40fff5ce05fbbde3a12186dbfc2f3088ca82a8
BLAKE2b-256 checksum
How to use checksums
74c0b44a87e6aaae288eb6d1ee0b0188bbb7756f58071e81c51e10cf3f299396
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 3.7 MB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
680fe084bc34976c4fc7669f9e0ce19273effbd2741ed0996b11a487cbd4ab4a
BLAKE2b-256 checksum
How to use checksums
fc24c21274f4f9126afe7488ba53a7f6d8b44fe2828bf54d68fb05fe8dbdfcd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_universal2.whl

Download URL onnxruntime_extensions-0.7.0-cp310-cp310-macosx_10_9_universal2.whl
Size 3.7 MB
Tags CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
70f5a82082357521127b5b52fe3c7912558412c00061737e1b14a4b23691506c
BLAKE2b-256 checksum
How to use checksums
3d7a2dc79e89eee6e103a4e395321191249b16f6ec42f16474816b722cdf7368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-win_amd64.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-win_amd64.whl
Size 1.6 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
d854c77cd2013498666b5e3810a2955a777abca487d6804ff0758be5aa08f106
BLAKE2b-256 checksum
How to use checksums
2bee66a6201d4fa4c6ce90eb7bf78b80431a1721b3d79f2b7095849831b9b306
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
285308f39129e32810f7a38f0a06f3e54ed1d15036651fae93dceee0375de852
BLAKE2b-256 checksum
How to use checksums
8bc13e372cc8ea1c57c4b8bd74ed2cf8c29047eacc76deaecadb5d180f9a8259
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Size 3.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
ec50d8636768b18b0daaf756046e2ad0eb9f60472263f01c1384b9a255b7b196
BLAKE2b-256 checksum
How to use checksums
2fd71bdf6f31b748faf00d18f8a0b12b07c86f75f662c0b25b41a6761e976ffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-macosx_11_0_arm64.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
efead65e2ec903749f10ae65aedb2e77c0b6e58f810e9f1007b4197e02479b0b
BLAKE2b-256 checksum
How to use checksums
094cb2cce3f0fa524f8065edffbfcd7051c2a3c5f9fb8dae7614284acf950540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 3.7 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fce78766b46e0573e6ff2a70a54e3da00cd20c4a59e5a4a3638be87822fccdc8
BLAKE2b-256 checksum
How to use checksums
a51bdd426b39f7d82eb75714a6d33bb583d33beb8b466cd334a42b447354bc17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_universal2.whl

Download URL onnxruntime_extensions-0.7.0-cp39-cp39-macosx_10_9_universal2.whl
Size 3.7 MB
Tags CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
3bd7d175952b77834becde5c5ec97895311930a757fa16cb5ac7c1442e888b4b
BLAKE2b-256 checksum
How to use checksums
e2456604600394192d65d20402d839a59da3f3c44fa017ba332581ef37d00c43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-win_amd64.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-win_amd64.whl
Size 1.6 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
96db8d365b5805e007b57939105903cbd3dfa9b919908feda5d3e962cd496213
BLAKE2b-256 checksum
How to use checksums
48537f50f602de4466236215cc3fcf0171f39b27b19892da39d6ee850494dc34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f789d6d5923ef10e96737e8bcd27d226f1eff7076b470261fe597d3fd3a1b637
BLAKE2b-256 checksum
How to use checksums
fa04885455047e26dae4f2ecbed0a4de229c0244977d37b3555f24e97a32f9de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Size 3.8 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
0666a35b6ef622d44abac9a3cb139e33b1e09c937b0b21edb4313cc3f787d4d0
BLAKE2b-256 checksum
How to use checksums
0aeee4931280909d7712c14e387b6566928fd2895044e48415e20d6b80286da1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-macosx_11_0_arm64.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
Size 3.3 MB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d4a91717ef577b3b775c847a44e90a5eabede8e4b4c0bc167e839e81cfca4cf9
BLAKE2b-256 checksum
How to use checksums
914eee29fca06ad403d72fb02f11adc3c2af1cbc61277595999d2fd98f1f961c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 3.7 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
2f63a2387e4c2a60a94618729f3e7ed01eef816d9711744cd6cdc740cdc947ed
BLAKE2b-256 checksum
How to use checksums
428fe46746283c6b3e69a7f185be07c0942851b4942ffbe794834fbd7a750752
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_universal2.whl

Download URL onnxruntime_extensions-0.7.0-cp38-cp38-macosx_10_9_universal2.whl
Size 3.7 MB
Tags CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
a58eaabe5716519481af2a166f4f7f4a6418a040f2909d6eaf4cb8cae02825d1
BLAKE2b-256 checksum
How to use checksums
894122d55240eb0b537789ae2822a60557316eebcf123c9f67b537dd1390e256
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp37-cp37m-win_amd64.whl

Download URL onnxruntime_extensions-0.7.0-cp37-cp37m-win_amd64.whl
Size 1.6 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c6f92183b482f3df2ee5bce2be98a923e19eeebfa25e95fa5ea5c45fe75847da
BLAKE2b-256 checksum
How to use checksums
8f01312c9c73293c0bb84567892058738318f9767afda1fd7a525fa7b181654b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d4cc979b6f5586d9bcfde2687bfcfcbf7fa1afc95477a203b522162521aa3e7c
BLAKE2b-256 checksum
How to use checksums
41aa7c4024a59ec1f509cc29e57ab26959141556502433ff2e82bf438853a6e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL onnxruntime_extensions-0.7.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Size 3.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-32
SHA-256 checksum
How to use checksums
1a5a29d454f90a07018b79f18ee6c1b7eb48d3e567efe3428aa74fb74de684d1
BLAKE2b-256 checksum
How to use checksums
173a041f4e7550301b56f4ba2d0a87b7db04dc6fc551faa16c6e39011ad6ae1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

0.9.0

32 release files

0.8.0

29 release files

This release

0.7.0 This release

21 release files

0.4.0

14 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page