Skip to main content

bindings of sonos/tract rust NN inference enging for python

Project description

tract-python

Project Archived: tract now maintains it's own Python package here.

License: MIT PyPI version CI

tract inference engine bindings in Python via FFI. It support Neural Network inference from NNEF or ONNX.

Why

No need to compile tract or have cargo installed, fast install.

tract-cli is very feature-full but reloading a model each time you wish to do an inference is computationaly costy and slow.

Think onnxruntime except it support NNEF, and it is based on tract.

Install

Install using pip:

pip install tract_python

Usage

import tract_python

print(tract_python.TRACT_VERSION)
# "X.X.X"

tract_model = tract_python.TractModel.load_from_path(
  # This parameter can be an ONNX or NNEF filepath (in case of NNEF it can be a dir or a tgz)
  './tests/assets/test_simple_nnef/' # simple graph that mul input by 2
)
# .run take as argument names the name of input nodes in your neural network
results = tract_model.run(input_0=np.arange(6).reshape(1, 2, 3).astype(np.float32))
print(results)
#{'output_0': array([[[ 0.,  2.,  4.],
#       [ 6.,  8., 10.]]], dtype=float32)}

Status

This project is maintained with latest tract version.

Scope

Our personnal usecase is to be able to run +10M inferences with 'tract' engine. So loading/running NNEF or ONNX is sufficient.

We would be happy to support some others tract-cli features:

  • computing: number of FMA operations
  • computing: profiling infos

(Thought it would be better to extract from tract-cli a tract-profile crate first in original repo to avoid code duplicate) We do not have the bandwith to do more and welcome any contributor that would wish to add more features.

Project details


Download files

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

Source Distribution

tract_python-0.2.12.tar.gz (21.8 kB view details)

Uploaded Source

Built Distributions

tract_python-0.2.12-py3-none-win_amd64.whl (5.4 MB view details)

Uploaded Python 3 Windows x86-64

tract_python-0.2.12-py3-none-manylinux_2_35_x86_64.whl (7.9 MB view details)

Uploaded Python 3 manylinux: glibc 2.35+ x86-64

tract_python-0.2.12-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (11.5 MB view details)

Uploaded Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

File details

Details for the file tract_python-0.2.12.tar.gz.

File metadata

  • Download URL: tract_python-0.2.12.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.2.3

File hashes

Hashes for tract_python-0.2.12.tar.gz
Algorithm Hash digest
SHA256 f68ec403b95b3a78664b96fe98314711a2a4c48d6b35d597364864593c757e87
MD5 72708befd759a98be7fe92b1845efae7
BLAKE2b-256 f76f4c31e906ab50bd42a97f404de57c0fc75eb6d1d63dfbb9a7a96bd7239091

See more details on using hashes here.

File details

Details for the file tract_python-0.2.12-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for tract_python-0.2.12-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8520afeee35d1279421a53757380eb171864fd7701254411e68de18fe4d0b60e
MD5 5e4403286b90919bfbf1ac3dd44287b5
BLAKE2b-256 587dbe1fffb3d2ff920244771aa1492fabd10a9029cf9f4e9e113b98e12fe7d1

See more details on using hashes here.

File details

Details for the file tract_python-0.2.12-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for tract_python-0.2.12-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7e8df16661ec37b07b3f2d97cc03de39be814dc5665bfe930cdd1e7013aeed32
MD5 b0e6be90231944982ef1263893af6d17
BLAKE2b-256 dd795b11dca2daba98cbe5df032be593dfbbff58121653dc0ddb2dc6b3311bd3

See more details on using hashes here.

File details

Details for the file tract_python-0.2.12-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for tract_python-0.2.12-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 fc44f4de94544facdbd02626cb659555c908486da42ab24c72f5baa66796c630
MD5 dd159667fc936611629232656b1c3fe6
BLAKE2b-256 8f96220b8ac2c50e64b3d90b833259abb4558385053865a54ceab6c8ca4e1c2b

See more details on using hashes here.

Supported by

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