Skip to main content

ONNXRuntime Extensions

Project description

ONNXRuntime-Extensions

Build Status

What's ONNXRuntime-Extensions

Introduction: ONNXRuntime-Extensions is a C/C++ 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.

Quickstart

The library can be utilized as either a C/C++ library or other advance language packages like Python, Java, C#, etc. To build it as a shared library, you can use the build.bat or build.sh scripts located in the root folder. The CMake build definition is available in the CMakeLists.txt file and can be modified by appending options to build.bat or build.sh, such as build.bat -DOCOS_BUILD_SHARED_LIB=OFF. For more details, please refer to the C API documentation.

Python installation

pip install onnxruntime-extensions

The nightly build is also available for the latest features, please refer to nightly build

Usage

1. Generation of Pre-/Post-Processing ONNX Model

The onnxruntime-extensions Python package provides a convenient way to generate the ONNX processing graph. This can be achieved by converting the Huggingface transformer data processing classes into the desired format. For more detailed information, please refer to the API below:

help(onnxruntime_extensions.gen_processing_models)

NOTE:

The generation of model processing requires the ONNX package to be installed. The data processing models generated in this manner can be merged with other models using the onnx.compose if needed.

2. Using Extensions for ONNX Runtime inference

Python

There are individual packages for the following languages, please install it for the build.

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());

C#

SessionOptions options = new SessionOptions()
options.RegisterOrtExtensions()
session = new InferenceSession(model, options)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ x86-64

onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_universal2.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ universal2 (ARM64, x86-64)

onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

onnxruntime_extensions-0.14.0-cp312-cp312-win_amd64.whl (909.8 kB view details)

Uploaded CPython 3.12Windows x86-64

onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_universal2.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ universal2 (ARM64, x86-64)

onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

onnxruntime_extensions-0.14.0-cp311-cp311-win_amd64.whl (909.5 kB view details)

Uploaded CPython 3.11Windows x86-64

onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_universal2.whl (2.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ universal2 (ARM64, x86-64)

onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

onnxruntime_extensions-0.14.0-cp310-cp310-win_amd64.whl (908.2 kB view details)

Uploaded CPython 3.10Windows x86-64

onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_universal2.whl (2.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ universal2 (ARM64, x86-64)

onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

onnxruntime_extensions-0.14.0-cp39-cp39-win_amd64.whl (906.9 kB view details)

Uploaded CPython 3.9Windows x86-64

onnxruntime_extensions-0.14.0-cp38-cp38-win_amd64.whl (908.5 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32895efb0d2e45fb3f17639686c62c9973e97409888042024f657d6eb802d88e
MD5 7fb860691a73168d3d59e07f818bcad3
BLAKE2b-256 b7d2a93aebd60b99ceadd4ad1fe62d103b716a3356e2f81e6e0d7a290c37c781

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f454086d3c3ee7ba65bbbcf39c98a07272831ba124710fe19c4f0c87efae95a0
MD5 fbdc56053d3bf6ea4314b834e6ce38d7
BLAKE2b-256 8d444cb10c243d8f48af401b4e914826f80601a7454d29eac89c42916f1a6017

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 21d18964e4c57404fc3dfa1a80807a9f05a500d8cfb94ed65c6f8ac30be5c9a6
MD5 055e8e39be8b3321aec4f6f0a2982b48
BLAKE2b-256 06e2a4566efd6f04fd8222ec7e393911d42a5122b2d0c359f7b5fa11d16d26f1

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 06fc3dc8ebe7f8903ae679f194616dc9554de9a91e815ab01d36b26b5563502f
MD5 09bb2bf0015d8671564049e9c6e44c2c
BLAKE2b-256 fca626b1df5afba1d6b4fe3407edc245edd9c7dedcaf5331d82a243204573310

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99c5f2c642cf47d35ebc94cc1ba2841e9e80669abab7a6e00bcf96cd8ed6ef37
MD5 b4f40099f83473b46d94998aebfeed73
BLAKE2b-256 b821df9e8ca1ce120b8e3d1c9dd7f719c3c67e69833055b7200257f899c86a85

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2dae88eab94b0d8d564e425a33360da4b208fa24f9a8f9e7eaf12c734a3428a0
MD5 5067ad4114430e9b6afb87c8f0c9df51
BLAKE2b-256 8b6ac8c51366c6c8060390e54d59dd3a4d5f0d88bb60f8abe8aeba46f171d445

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5786a482c02e8310b6ec1ab165487ca37a218cb5807ec7f063d2bfc6a0c5744
MD5 de7c902411eb82d16beff2dcf98f4dac
BLAKE2b-256 5e4e2731df3fb27a3642a34aec51e7ac85e066861a76fd1c8747df51c41416f6

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0d66a539948d1c9d26e0eaeab4f7ae39043db58181fdeb12436f918aec345675
MD5 84aef501fcf405d0d7c6f10aca4c2951
BLAKE2b-256 5ce9c0a647831d16bfd513906be1236a4595499f4ad731f6acb0a6671b72db0d

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 290aee38f4d2fd9c09f99d21e5975d5e9cbe6ea80b80182ce01210db7c6400e8
MD5 db50f08646229c4cc67d7e8124f8c8d7
BLAKE2b-256 dfa871ab508393c5f0ba94414e02fbfc7b1ec290c12757667d83a50699efa27a

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 47334605538fb1d28138a7c0ffb8db31a03c52fde2e0bcb16ec6e314428d6819
MD5 dd95446078895e0d99e02fa3b21a1329
BLAKE2b-256 78c0b271e9c4a1da71d584ea698cac37c5a9642ae494637c1f9b19bce04509e7

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19845ea7a29c800e7253608fe1f4d3f6604fd1433bda616b2fdf5f8679334bed
MD5 095c560ce4992cb3bd052638920d7f99
BLAKE2b-256 9b6af46e8821a64c18e24b079fba59f13d776ab6b40d82d49712a920e4ba2b41

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 23341440d59b61042e640407e0284340706715cebb041ea01ca7efc5d6a428bd
MD5 50f201693e9a7d6164617c0a27d6a284
BLAKE2b-256 4549eb0ae4e10b6f2fb220d7e155c7f72125ce3c13a39ed8ed8ff6f8a18455b6

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32843f72d0cd9b6d2b5b3884461fc6d6f24f395488ae3bc5c0ec97200f23840f
MD5 6d50a13c4e59410654f614108b2fdb97
BLAKE2b-256 f0a3f51ec2afe5a269e14a01b3f2a1537fb7237e91436bd2203addeedf29208c

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 940b6627ef7e0f13dff245a3eea4a36eb2a7a30f823b9233a70b65b912cb5a82
MD5 bbedc6b896e331e75d781f4909720ec7
BLAKE2b-256 f9a7f038a5b569420d601e570799c7d86703b435004684bc4258f5eb786cb3ef

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c951a900dd89670d6684ae9cd1201ced226307b0845fa326bd5e130f7611ddde
MD5 c70f6f153213cd14c9f8c9baad69500c
BLAKE2b-256 6cd8c69f4c88336223e8da64b51f97523028998bca415bc9721c0999b0e7ab45

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 acda6b310d1e29d30c141b2af1e62f12d2bf7a8de8f4725ec6684dee964bba88
MD5 7808c81a11ca5256a1abd4178fed3470
BLAKE2b-256 3c23c2a4548b28eab4cab2acc130181369c72d58a7f772ff452b70f3b194a9d4

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26392da86d8fad4997f33bf154d45d79ce796aaab5696585becb915df9e337a6
MD5 cf53de13905900714dddd08166532793
BLAKE2b-256 c35c8fe4c7598366083c9d08afba2c88f41609f9a48ee3c0fde1f876f8ff8872

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 39302725dcfa0bd436244348bf45116c96dce6a7356638d62723b4193ae5aab2
MD5 cd878732edcd865e511393f98ff013e7
BLAKE2b-256 e9c0bf3abb8abec2ffe2b42c45fcadde28f994672ddbb7fdf3dde13dc7415f1a

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 766cc8e8540afbec9b39c2fd3b23943eafa1d52c8ac4fefab8b2ead276bad814
MD5 17e4eec209d88e63b20b0480eede8a98
BLAKE2b-256 52e8bf695e86841d1b522f625c7bb8cd16c62d7aed7e117801dc7d0cf3f853f2

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 507739fd34a4f78905af8b3a31443b8e944dafe4e24eff18377d44cffa43fbc9
MD5 810c315fcec007f8bce47ce4301f3161
BLAKE2b-256 fd80b637730447aadb57ec6414b8246ec45ee68644d453253baba2d9a7b23cf7

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 878c11581d1d5e0ff3fb5a401f875d4597d8dd26d5942eb11a68d120db4d92f0
MD5 a5b1a2dc361b8eacb1cce319d8f75069
BLAKE2b-256 eb94e8ed6fdd25fdfe82f454b09614695ef41dfac8fb953593b8a14655c2dc74

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 9aa57911f69ab67126aee5d49eef2d16eae7e17f109b3c1fed168c49f91736ee
MD5 7e1a63209bb5ab1d5737afab6e121c99
BLAKE2b-256 87882cea6a9a8a2c2348881e298b61f04bbf0fa012dfb6d1ab9c5f2d07f7f653

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b5f77b9b6e613fe61c6d72c78f982bfc823bc5721753555c58ee23852761ba0
MD5 0835738e373da60a651a0696f1834aa7
BLAKE2b-256 9294cf1b60c9bea53b809d10635d8c46864a850c48baf85de69f66a13427d777

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 51bd94a4c16753333eaf0b9391a85d2cbbf7e0c6bc6426dbc0bfd9b8bd0ae7f5
MD5 d7109adcdb9791456eec89185384be79
BLAKE2b-256 8b638b3dc64903090845ccd993bf1b8afb3f994d3fab40371d6d795f521794ec

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.14.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.14.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3751f82d15f60bd4283fc9292b577b6a597b2fcb55d0cca0cae387363955fa4f
MD5 e8f346aabbb84b162533859d9d4a1abd
BLAKE2b-256 ec9c3f616435f796bfd306eb638e4088f655207c07ca12cb652b6e4c7e63d894

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page