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.
Quickstart
Python installation
pip install onnxruntime-extensions
Nightly Build
on Windows
pip install --index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/pypi/simple/ onnxruntime-extensions
Please ensure that you have met the prerequisites of onnxruntime-extensions (e.g., onnx and onnxruntime) in your Python environment.
on Linux/macOS
Please make sure the compiler toolkit like gcc(later than g++ 8.0) or clang are installed before the following command
python -m pip install git+https://github.com/microsoft/onnxruntime-extensions.git
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
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
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424ad465b2112a3b877ce0663c7ed78ca5b485e0b143348261372abd141b3a89 |
|
MD5 | 2086a0b18650e586ea1cbd7cab75fc8a |
|
BLAKE2b-256 | dee8d7c0a9fa0e2b5ec74094895e6188fe96a03c1c93a448155947355e5a9f2e |
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8477b9bbed8a72841d11920de0a39d05877cdb2818914c1022f53c4dee5f35d2 |
|
MD5 | 078d715f8ca871cf70df7f45cfa45316 |
|
BLAKE2b-256 | fccb43549af1a076161ed590d48ccb019a5400bceaef814e20e3b859af33c6cc |
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 315e05b3d95d3290fb50fb43a66f5ceccca8958a78b795efeaaca66cbd5cac4e |
|
MD5 | 706b72894a51047ba946efe63b455667 |
|
BLAKE2b-256 | ffe96f5ec9ea6ecb9a40be6f88adcc5bfd18cdbc1670a384c9c7a0261c556d70 |
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c85668925393e25c33386068dd15530bcc895e9ef13c466128d950de0508f1 |
|
MD5 | af292f5221a5b4af08964948a7c113d0 |
|
BLAKE2b-256 | ac83f3668859ba77bdb18cd7c56b5995702f6852b2802fe30aee35042f7cba84 |
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0716630bab22db213597cef3192d2945b637ffe17324daddb19b7621a720043b |
|
MD5 | 21c6cce9ae669afe49cc90e05d16ecad |
|
BLAKE2b-256 | 51bb177ea8b2c5331d490da6531373e1740451aaa5818927bfdf5fb4567e341e |
Hashes for onnxruntime_extensions-0.12.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b626c2f9fd526351002eaa433390e0e54ae0caf5c3bc79cda40afe9710ef9ba1 |
|
MD5 | 5fa651efd8e375f1dea2d200baf66dcf |
|
BLAKE2b-256 | b41c2cce87265302b90af9266cdc58f397b5d39a96db49f192da01264787474f |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0c914db2f28c0673b19db979bbd34916bb0fee7d974fb9ca0e3348bb113d9fb |
|
MD5 | 83d8a56dad360f507997574a67241c19 |
|
BLAKE2b-256 | 12f89fab66293435aa388d95088a2956262180dca4080ab39292b227d0a886f0 |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b94cdf93ad358696524fc7f34a56172fdff26a152c25ef1e64675ddc885c151 |
|
MD5 | f1845af331f5837e015d914143b1a7a6 |
|
BLAKE2b-256 | fb45adfee2a4d511cbd37f5c69fd1024bf69744f5da0627c7be5865c15728e11 |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11d11be38064dfecd16fb7f83cf0e09d42ff0955af13c759bc8f968fbd23ea85 |
|
MD5 | b6ba30c37574871e85928a93e737d935 |
|
BLAKE2b-256 | 93728b7cad54d06081daeffc7c6965a1f1f99799e04ff8a2dccf96178b901e36 |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fed5cd208e46732f0e03a02b2a3e52cceae438864c751996a75bc2c06e549554 |
|
MD5 | c1df97afdda4a0885c2c8d80bf312021 |
|
BLAKE2b-256 | 20ca6f5dff70293b1725edbf4f14feff43c363a8825ae8e5ea82af1f67dbbd61 |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97a66f2c798d5e8aa0bdbe07a8518e4d6ce2daceace0aa7d481df7b75e0a688a |
|
MD5 | 844b27fd52a1503f529559649ce39ee0 |
|
BLAKE2b-256 | 462e3561aca01f7f719f8dd85cab9489724730785f9a76f0f04eb77eeb042944 |
Hashes for onnxruntime_extensions-0.12.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e58c0c81bc6997a3bba8869428e87b0593970ca331d46e926d9dbce1e14cd179 |
|
MD5 | f12b2db2d907cb02caf3c82afc24dcae |
|
BLAKE2b-256 | 25884963a469829fe31937bc67f5027cb50eb21a7572b0374433e8d83a57a801 |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe25a3c1a3ced49c7ae1592e7e439c0f0aaad762e9a0356416db132e390ad80c |
|
MD5 | 54a9e6b9cb32c3b9f3f062cccfb30365 |
|
BLAKE2b-256 | dc6edccccf44722a6a203500034a85de1196d6f6b168104bdbcd4cf7da533f8d |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f66a89f9dfde82111c997f08db633af13a9168c813918fb045f59c3381387629 |
|
MD5 | df75ca27137401d96f8f3ef1e78a4e39 |
|
BLAKE2b-256 | 00e57499ce8d24a6333dc858dc4e116fa85b2c0a6577eb9a4470a756a9f62054 |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15716a850cff373f9508d189ca6b36f5a243b40b4cccb675fd58cb068737d8d2 |
|
MD5 | 2cbba85a0fabd16f1e0a954aaef2b340 |
|
BLAKE2b-256 | 513bcba68f79b4600c37c0bb1d6e00958f716e8b3b6699b79acafde4b588dfb9 |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 858ec517f4e7d95445ffea9c64bb8da59fa39b5fe64e94c72d35aa2b97a6f6e8 |
|
MD5 | 19e5e34feb09ea494613771cdfd1274b |
|
BLAKE2b-256 | 7cf4c35da2c897dc516ed4b0f0711cfb50ece48ca97acaa8682f9b5fb2177ed1 |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba796559efeb666a00b54e128ad25d2131420bfdf0518471d8a15e381924825c |
|
MD5 | aab3f99775724400741ad17757fb62d7 |
|
BLAKE2b-256 | fbbbc43fb0b13915afd269625fd02c57c01fd3c8b6f242680b56f8b0d7fcf3d4 |
Hashes for onnxruntime_extensions-0.12.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3858e5b7756566b91ffab813b1c7a3fca7468e699b7ad3fb77fdafaa54928e2 |
|
MD5 | 309e416a732327113c7dc89658edf359 |
|
BLAKE2b-256 | 820759e0e227a8e9467a0c1d0eb87170b35be6352376b4f4ca7aaeb009fe594a |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | febcf51136f564fd93924d8cbf2d44faf9585a13b87b8310008851928c0be034 |
|
MD5 | 3d42fa1385759a90af3af3db87a2048a |
|
BLAKE2b-256 | 157ed351469eb00254bb2cdcf6aae706fda1797d32df003cd18d6259ae9125de |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b7d321bb33ea2dd5ae83552b0d8023025d8287a38d69213e097f971e0d2af31 |
|
MD5 | 63ecf41b6abc8acc15191b713e2de287 |
|
BLAKE2b-256 | 396107ee700741dcb8e1fa5338b6aad27c4474bf58a73b55d4990f875c975220 |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1619e0f323811291dc5a29055bc24a808e559b42fe9f5b349b08a4ef80d72868 |
|
MD5 | 523af4c70169ebad2d89694ca9910d40 |
|
BLAKE2b-256 | c48604707b1a5415c4788f9e892b073bc9b8e38c4d904e2cb2b16e4414158ca1 |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bb407765824ea54acfc76f8313aa7d26aa4800556da9c7b283a6654fda62b9d |
|
MD5 | e5ad220cfb42c4e8c12e3316b499a5f4 |
|
BLAKE2b-256 | 59962250926a415a02d7f44dc4221d687ba1ea5b7b6edaea9add70d47d6816b2 |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88e0439225645ca4b6a37cdc7a43c33a847b04efb62105203469ee4881a67a0c |
|
MD5 | 0b56aa2f3fd3f247b03bb1f7c09e7aa6 |
|
BLAKE2b-256 | 182f44234f72a1fa94d41a6cb0cb4e8732e634938975647ccfd36741e39e5ccd |
Hashes for onnxruntime_extensions-0.12.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f95e6dc6de09f1f51c365a29658decc7ae34ac768823c37a5dfa77c786641cd5 |
|
MD5 | 646052ce5d44be2ee817ea46de3ed13e |
|
BLAKE2b-256 | 3b5ca86a8c5723b3e54fac6c9218cc48fb10f8aaacb1b83e7029b57e9f447554 |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51b6ed83f165e09d923ead2f994e6467e617b8d88bbff8ff790409bf3ee2c90a |
|
MD5 | 12fd10d1f36d271b5cdec54a9a9feadd |
|
BLAKE2b-256 | 1bf458f60f0130b7e5be7b2018f0d1bcdcca131a2479c722572e70c3f94c4bbd |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0164fad327b59e7abae34b2a795801d9141bc8c79682959ba6ecbe0524d8b17 |
|
MD5 | a34b57f468581a612530966848618fbc |
|
BLAKE2b-256 | 95d7f21ee2db33f6da019cf7de1dffe18239f2d2761a338835e9c490e1fe8dd4 |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3986e5b4a062b276493f5f11fa115ea2a653f121f8b86332ea2ab8424cf770cb |
|
MD5 | 89fa498a0a89de3cf74464cd7f952134 |
|
BLAKE2b-256 | 9c232f15f466aa42206002475edc61bb84e7beaf3cd3c1f5514bfa1719227d5c |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dcf1e2971bce3a2a57ca8124e870ed3d8331f31bf5a0877ec93e9057b34e79c |
|
MD5 | db65f4572259552d323788b3c9839072 |
|
BLAKE2b-256 | 4220c337acc13db70c0a9b5f549cfef84ea48b6dfd29161b948ea80631f0604f |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f30f36129dfde0794d49a838e9e906dc82dcd7547edccf6227665016be701f9b |
|
MD5 | d06de9838ee7b23f2f57d39ac0575d83 |
|
BLAKE2b-256 | 7a767390dfde6b66844b681eb95617021e1da5a8bf429d208d074a7940e7727a |
Hashes for onnxruntime_extensions-0.12.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b45e4e4e00e54f65c396393d9dea902560cebb367593420c4f9cbeb9c3da067a |
|
MD5 | e98aea9bdb33519955a9bd4eaad24078 |
|
BLAKE2b-256 | b36104ae58ac936e4e490d0427ad02a489f3ed746a94b688e32007043e1c9cf3 |