https://github.com/apachecn-archive/tract

https://github.com/apachecn-archive/tract

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: apachecn-archive
  • License: other
  • Language: Rust
  • Default Branch: main
  • Size: 13.4 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 3 years ago · Last pushed about 3 years ago
Metadata Files
Readme Changelog License

README.md

tract-logo

rustc >= 1.42.0 MIT/Apache 2 Native Linux test status Embedded targets status Doc

Sonos' Neural Network inference engine.

This project used to be called tfdeploy, or Tensorflow-deploy-rust.

What ?

tract is a Neural Network inference toolkit. It can read Tensorflow 1, ONNX or NNEF, optimize them and run data through them.

Quick start

Tract in the landscape

ONNX

As of today (October 2020), tract passes successfully about 85% of ONNX backends tests. All "real life" integration tests in Onnx test suite are passing: bvlcalexnet, densenet121, inceptionv1, inception_v2, resnet50, shufflenet, squeezenet, vgg19, zfnet512.

The following operators are implemented and tested.

Abs, Acos, Acosh, Add, And, ArgMax, ArgMin, Asin, Asinh, Atan, Atanh, AveragePool, BatchNormalization, Cast, CategoryMapper, Ceil, Clip, Compress, Concat, Constant, ConstantLike, ConstantOfShape, Conv, ConvInteger, Cos, Cosh, DequantizeLinear, Div, Dropout, Elu, Equal, Erf, Exp, Expand, EyeLike, Flatten, Floor, GRU, Gather, Gemm, GlobalAveragePool, GlobalLpPool, GlobalMaxPool, Greater, GreaterOrEqual, HardSigmoid, Hardmax, Identity, InstanceNormalization, IsInf, IsNaN, LRN, LSTM, LeakyRelu, Less, LessOrEqual, Log, LogSoftmax, MatMul, MatMulInteger, Max, MaxPool, Mean, Min, Mod, Mul, Neg, NonZero, Not, Or, PRelu, Pad, ParametricSoftplus, Pow, QLinearConv, QLinearMatMul, QuantizeLinear, RNN, Reciprocal, ReduceL1, ReduceL2, ReduceLogSum, ReduceLogSumExp, ReduceMax, ReduceMean, ReduceMin, ReduceProd, ReduceSum, ReduceSumSquare, Relu, Reshape, Resize, Round, Rsqrt, ScaledTanh, Scan, Selu, Shape, Shrink, Sigmoid, Sign, Sin, Sinh, Size, Slice, Softmax, Softplus, Softsign, Split, Sqrt, Squeeze, Sub, Sum, Tan, Tanh, ThresholdedRelu, Tile, Transpose, Unsqueeze, Where, Xor

We test these operators against Onnx 1.4.1 (operator set 9), Onnx 1.5.0 (operator set 10), Onnx 1.6.0 (operator set 11), and Onnx 1.7.0 (operator set 12). Many networks in operator set 8 are also working.

TensorFlow

Even if tract is very far from supporting any arbitrary model, it can run Google Inception v3 and Snips wake word models. Missing operators are relatively easy to add. The lack of easy to reuse test suite, and the wide diversity of operators in Tensorflow make it difficult to target a full support.

The following operators are implemented and tested:

Abs, Add, AddN, AddV2, Assign, AvgPool, BatchToSpaceND, BiasAdd, BlockLSTM, Cast, Ceil, ConcatV2, Const, Conv2D, DepthwiseConv2dNative, Div, Enter, Equal, Exit, ExpandDims, FakeQuantWithMinMaxVars, Fill, FloorMod, FusedBatchNorm, GatherNd, GatherV2, Greater, GreaterEqual, Identity, Less, LessEqual, Log, LogicalAnd, LogicalOr, LoopCond, MatMul, Max, MaxPool, Maximum, Mean, Merge, Min, Minimum, Mul, Neg, NoOp, Pack, Pad, Placeholder, Pow, Prod, RandomUniform, RandomUniformInt, Range, RealDiv, Relu, Relu6, Reshape, Rsqrt, Shape, Sigmoid, Slice, Softmax, SpaceToBatchND, Squeeze, StridedSlice, Sub, Sum, Switch, Tanh, Tile, Transpose, VariableV2

TensorFlow-Lite

TensorFlow-Lite is a TensorFlow subproject that also focuses on inference on smaller devices. It uses a precompiler to transform a TensorFlow network to its own format. It only supports a subset of operators from TensorFlow though, and is only optimised for devices with Arm Neon support.

Tract supports a wider subset of TensorFlow operators, and has been optimised for CPU of the previous generation (ARM VFP), also targetting devices in the Raspberry Pi Zero family that TensorFlow Lite does not address.

NNEF

Long story short, TensorFlow and Onnx formats are good for designing and training networks. They need to move fast to follow the research field, tend to integrate new features and operators greedily. They also exhibit a high level of expressivity to facilitate network design.

On the other hand, only a subset of operators and network features actually reach production, so systems running production network do not have to deal with so many operators. Furthermore, some information required for training can be stripped from the network before going to production for prediction.

NNEF tries to bridge the gap between training frameworks and inference by proposing a format dedicated to production and prediction.

Tract supports NNEF:

  • tract_nnef can load and execute NNEF networks
  • tract supports most of the NNEF specification, the most notable exception being the ROI operators and deconvolution
  • tract introduces tract-OPL, a series of NNEF extensions to support other operators (or extend some operators semantics) in order to represent the full range of tract-core neural network support: any network understood by tract should be serializable to tract-OPL. This is a work in progress.
  • tract command line can translate networks from TensorFlow or ONNX to NNEF/OPL.

Example of supported networks

These models among others, are used to track tract performance evolution as part of the Continuous Integration jobs. See .travis/README.md and .travis/bundle-entrypoint.sh for more information.

Keyword spotting on Arm Cortex-M Microcontrollers

https://github.com/ARM-software/ML-KWS-for-MCU

ARM demonstrated the capabilited of the Cortex-M family by providing tutorials and pre-trained models for keyword spotting. While the exercise is ultimately meant for micro-controllers, tract can run the intermediate TensorFlow models.

For instance, on a Rasperry Pi Zero, the "CNN M" model runs in about 70 micro-seconds, and 11 micro-seconds on a Raspberry Pi 3.

Snips wake word models

https://arxiv.org/abs/1811.07684

Snips uses tract to run the wake word detectors. While earlier models were class-based and did not require any special treatment, tract pulsing capabilities made it possible to run WaveNet models efficiently enough for a Raspberry Pi Zero.

Inception v3

| Device | Family | TensorFlow-lite | tract | |---------------------|----------------|-------------------|---------| | Raspberry Pi Zero | Armv6 VFP | 113s | 39s | | Raspberry Pi 2 | Armv7 NEON | 25s | 7s | | Raspberry Pi 3 | aarch32 NEON | 5s | 5s |

Notes:

  • while the Raspberry Pi 3 is an Armv8 device, this bench is running on Raspbian, an armv6 operating system, crippling the performance of both benches
  • there exists other benches on the internet that show better performance results for TensorFlow (not -Lite) on the Pi 3. They use all four cores of the device. Both TensorFlow-Lite and tract here have been made to run on a single-core.

Roadmap

One important guiding cross-concern: this library must cross-compile as easily as practical to small-ish devices (think 20$ boards).

  • nearly complete ONNX support, and wraps it as a backend
  • integrate other TF models to use as example, test and benches
    • https://github.com/ARM-software/ML-KWS-for-MCU
    • https://github.com/mozilla/DeepSpeech
  • consider acting as kaldi backend

License

Note: files in the tensorflow/protos directory are copied from the TensorFlow project and are not covered by the following licence statement.

Note: files in the onnx/protos directory are copied from the ONNX project and are not covered by the following licence statement.

Apache 2.0/MIT

All original work licensed under either of * Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Owner

  • Name: ApacheCN 归档
  • Login: apachecn-archive
  • Kind: organization
  • Email: wizard.z@qq.com

防止重要项目丢失而设立的归档

GitHub Events

Total
Last Year

Dependencies

.github/workflows/beta-and-nightly.yml actions
  • actions/checkout v1 composite
.github/workflows/binaries.yml actions
  • actions/checkout v2 composite
  • softprops/action-gh-release v1 composite
.github/workflows/cross-platform.yml actions
  • actions/checkout v1 composite
.github/workflows/full.yml actions
  • actions/checkout v1 composite
.github/workflows/linux.yml actions
  • actions/cache v2 composite
  • actions/checkout v1 composite
.github/workflows/macos.yml actions
  • actions/checkout v1 composite
.github/workflows/musl.yml actions
  • actions/checkout v2 composite
  • softprops/action-gh-release v1 composite
.github/workflows/release.yml actions
  • actions/create-release latest composite
.github/workflows/upload-musl-release.yml actions
  • actions/checkout v2 composite
  • softprops/action-gh-release v1 composite
.github/workflows/windows.yml actions
  • actions/checkout v1 composite
Cargo.toml cargo
cli/Cargo.toml cargo
core/Cargo.toml cargo
  • criterion 0.3 development
  • env_logger 0.7 development
  • lazy_static 1 development
  • proptest 0.10 development
  • anyhow 1
  • bit-set 0.5
  • derive-new 0.5
  • downcast-rs 1.0
  • dyn-clone 1
  • educe =0.4.11
  • half 1.3
  • itertools 0.9
  • lazy_static 1
  • log 0.4
  • maplit 1
  • ndarray =0.13.0
  • num-integer 0.1
  • num-traits 0.2
  • smallvec 1
data/Cargo.toml cargo
examples/jupyter-keras-tract-tf1/Cargo.toml cargo
examples/jupyter-keras-tract-tf2/Cargo.toml cargo
examples/nnef-dump-mobilenet-v2/Cargo.toml cargo
examples/nnef-mobilenet-v2/Cargo.toml cargo
examples/onnx-mobilenet-v2/Cargo.toml cargo
examples/pytorch-resnet/Cargo.toml cargo
examples/tensorflow-mobilenet-v2/Cargo.toml cargo
harness/core-proptest-pulse/Cargo.toml cargo
  • env_logger 0.7 development
  • log 0.4 development
  • proptest 0.10 development
harness/lstm-proptest-onnx-vs-tf/Cargo.toml cargo
harness/nnef-inceptionv3/Cargo.toml cargo
  • dinghy-test 0.4 development
  • env_logger 0.7 development
  • log 0.4 development
  • flate2 1
  • image 0.23
harness/onnx-test-suite/Cargo.toml cargo
  • env_logger 0.7 development
  • bytes 1
  • fs2 0.4
  • log 0.4.6
  • prost 0.7
harness/onnx-test-suite/debug-utils/Cargo.toml cargo
harness/tf-inceptionv3/Cargo.toml cargo
  • criterion 0.3 development
  • dinghy-test 0.4 development
  • env_logger 0.7 development
  • log 0.4 development
  • image 0.23
harness/tf-mobilenet-v2/Cargo.toml cargo
  • dinghy-test 0.4 development
  • image 0.23
harness/tf-moz-deepspeech/Cargo.toml cargo
  • env_logger 0.7 development
  • log 0.4
hir/Cargo.toml cargo
  • env_logger 0.7 development
  • derive-new 0.5
  • educe =0.4.11
  • log 0.4
kaldi/Cargo.toml cargo
linalg/Cargo.toml cargo
  • criterion 0.3 development
  • proptest 0.10 development
  • derive-new 0.5
  • downcast-rs 1.0
  • dyn-clone 1
  • educe =0.4.11
  • half 1.3
  • lazy_static 1.3
  • libc 0.2
  • log 0.4
  • num-traits 0.2
nnef/Cargo.toml cargo
onnx/Cargo.toml cargo
onnx-opl/Cargo.toml cargo
pulse/Cargo.toml cargo
pulse-opl/Cargo.toml cargo
tensorflow/Cargo.toml cargo
  • criterion 0.3 development
  • env_logger 0.7 development
  • proptest 0.10 development
  • rand 0.7 development
  • bytes 1
  • derive-new 0.5
  • educe =0.4.11
  • log 0.4
  • prost 0.7
  • prost-types 0.7
  • tensorflow 0
harness/tf-moz-deepspeech/smoketest-builder/Dockerfile docker
  • ubuntu bionic build
examples/jupyter-keras-tract-tf1/environment.yml pypi
examples/jupyter-keras-tract-tf2/environment.yml pypi
  • fire ==0.3.1
  • joblib ==0.16.0
  • keras2onnx ==1.7.0
  • onnx ==1.7.0
  • onnxconverter-common ==1.7.0
  • onnxmltools ==1.7.0
  • pyyaml ==5.3.1
  • scikit-learn ==0.23.2
  • skl2onnx ==1.7.0
  • tensorflow-addons ==0.11.2
  • threadpoolctl ==2.1.0
  • typeguard ==2.9.1
  • typing-extensions ==3.7.4.3
examples/pytorch-resnet/requirements.txt pypi
  • torch ==1.3.1
  • torchvision ==0.4.2