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

If you're not sure about the file name format, learn more about wheel file names.

onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ x86-64

onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_universal2.whl (3.5 MB view details)

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

onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_universal2.whl (3.5 MB view details)

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

onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_universal2.whl (3.5 MB view details)

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

onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_universal2.whl (3.5 MB view details)

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

onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de3506eae2be7beb27921d8a596dbbdc118c0260c47b21084a9ca446c5a05a79
MD5 9044864021b3eb98cca7bec70996b1e7
BLAKE2b-256 b10c4d6dc572feb31afe33b6ebd4c9f11a1082079bf2875c7dab82b4c6d47d08

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e98f3f84759db69dd101f68ccdc577ba66be2140307e84ae76c07021dc5f4644
MD5 99586572a22fe1a44abc909cd53a452b
BLAKE2b-256 22cd728ae7203ea20a16b0ffc715e41ef82e942699c8b9a46b0f67d1ea183306

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 ee19b88eee9bcf62717ff1673fe10c56bd09e3adc56b5c952cba592674de960f
MD5 4dfc822fcc3498f3d13313aae3f25a0c
BLAKE2b-256 9a1f0889d9c366788eecedb3065f940fbffe6e526d3b128dae5f80993dcffde7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8b354c0f06ef1a5053f4ee3f8bc8c21a3d6ee9e1d1c9cdfb5e14d1b099597857
MD5 ce42e6e09d07e55fab723239d5ce518f
BLAKE2b-256 0d597d74d1d7898f1a84337d0a4d9341dc5d95dadeaff795f25addf4de92b548

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b94dd079499e7de7242b665c67153d09b45b3a013e68e71bc48dd766f8637616
MD5 481c2f595819d917b5a4d524af8bd607
BLAKE2b-256 0f5ac5e843ae9e0e4f8270178ebc6840b109b0f6fbfc50f10ec637fd1661cca2

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c159a9d05c3133122a92d1b4ade8be4c216222e15736dbd73d9aef3eb12da27f
MD5 6cf74011cd7aa5fe8aa9da1556cadf71
BLAKE2b-256 a8b564ac09815875afa7fadec5dbc52ec9f0b9039bbf614223b2408209fa84b9

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc9c4a7ef0e1da68c5792406f883db670eb616cc0af7fa85c74ac851fef3d334
MD5 49b44154e23782587f9a25b5312aadcd
BLAKE2b-256 564d4c20c172f232498ce71e80ab8bc7281ee43cfc2f1d99440b37dc0f65e287

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 38d8898ac4d5b92fa8a9e15c010191767fa78d7c6e0c040e9ebf377f9e1a5141
MD5 924fb6849f20e15c66c0430e43aa454c
BLAKE2b-256 2375711b2f9c6a1467bda1d2dc1c1e496a12f7e5ea011fccbcccfd9610592b54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 8deef9b8a2f7a2cde109db7a28c2e64bf4f4cdb7cc62462ff8e2d30bc439ddf5
MD5 9b2c405a88314047f3a393e3391932f4
BLAKE2b-256 766bd405cd16c4ff25e0e4dc3c5d128282da515f7ec841a1dd71014422f9e6d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5f53065f014ed4bf424e668456019cf6dae98fbe86b9f8494af9a33c75728280
MD5 7c3167a46332bd1c233e39da7e38785d
BLAKE2b-256 ecdbc19329597724766194291d4366f77807570dddd36ad623fc244630000f8a

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 47f19c732a24f400a8c6a845ebdf1a9b83fa3e779e9dcf1bdfe864e72c77e15a
MD5 6366f91244965e3ec74a1581c42005a5
BLAKE2b-256 2eaff3230010393e38b9066445a8c7c065b7084523efd4b3f0febd19aa67f3af

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e507a9310aa2e200cc5b471bf04b4e95139be37af248a41c95e6528fa1ac065
MD5 6fba9573239c60265ad87096563da359
BLAKE2b-256 581c6c2355415b98a25e02c9e3c9fdb41f9c4c7e8cb6914067bebc2b11f15dad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 acca61cb0ab5c54e2d237b3629c9bb73c686a727c014d375c1400d8db1c8bc05
MD5 7d2746a3415ad71a0edae568f3b03223
BLAKE2b-256 d0b724134afe15b5e3dee898e47b199b8661609b36d5848ef72cefe6186ed7c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 dadc2d2c33dac1a4e5fa082827f26995bff649df72b16e7d8bc97a484f9477df
MD5 401f32236c889b38b5fd48f6a154fcc7
BLAKE2b-256 e5ebb8b967e5a0a61d5d86fe3843be2998738ab490fdb068ee4d93085c2fc6a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 042f93582dd97b488c63ea45f607c6666833373f1be28f0fa7d3874cbd5b60cb
MD5 5c601e638d8e2b0aa880a123a49f7f73
BLAKE2b-256 83c7adece52214441020be22cbc25ad4c21a77cd2ed83d00ce47b38f3d9ed4c9

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f758d04f9d25a48c762a297b55d7e9ba06a852d8b3dd0f9cf86b8de15c973f90
MD5 b252b34902056ed6e9c7bb25e9f8f98c
BLAKE2b-256 e56989ee9676b8bfe2d96610f9edcf353b4dc2b5b53847089bffcfa419cbebe1

See more details on using hashes here.

File details

Details for the file onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 90fff213cb494378376222eed1ad58a938f7742a4c5bf056cb0a9c98c1a3adf5
MD5 bf7a45ea34a2e2c356074cb473bb9b62
BLAKE2b-256 cfc1a235f0cb7428bf3e698166b7f37a6d873a301f386de77e01c28e96f77065

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 41f1dacc1deb8602af590772fb5ff3a0cc75cfb58979bf8316876dd3a1ace407
MD5 8e785367a07b44d990916ec13a1f2d7c
BLAKE2b-256 ce5882204b7b07ac58fb30e070290985495bfdec38a9fa35b399e3a0dab9db58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 65b52ed700e951632e9d6de74fe6dfa00886866cdba24e98f8dfa7aae69759ae
MD5 fed0cb8bc737f57c003fd60b40d5defc
BLAKE2b-256 ad4b973a67415c8ff955c15f4ac841c4ba6dd9fdcbd6b7e7c4c162bbe0f13eb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for onnxruntime_extensions-0.15.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad718d5398fb81b97cb73c2ebc85236fc993bc384eb621b29698207d297ad6ff
MD5 2bbc2d6fe6925f3e41c6afbcb6f8d6b6
BLAKE2b-256 466dfed922439bc9362546a0b18b8ec4886b70a8ad2d2cb86cab24f55aa7d268

See more details on using hashes here.

Supported by

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