Giter Site home page Giter Site logo

connx's Introduction

CONNX - C implementation of ONNX runtime.

github Build Status GPL

CONNX

CONNX is abbreviation of C language implementation of ONNX Runtime. It's targeted to running on IoT devices such as ESP32, Raspberry Pi 3/4 or FreeRTOS. CONNX can be used as an alternative of tflite.

MNIST example on ESP32

Architecture

Features

  • Portability
    • It can be ported any platform, because it's written in C.
    • No Dependency : It runs standalone without any libs(BLAS, eigen...)
    • HAL(Hardware Abstraction Layer) : It seperates logic and platform-dependent code.
  • Small Footprint
    • Operator plugin : It reduce the size of the footprint by selecting operator at the time of compile.
    • Preprocessor : onnx-connx project pre-processes and Strip ONNX to reduce footprint size by 0.5 to 5%.
    • CONNX format : Conversion to connx format. It's functionally identical to ONNX but simple to parse
  • High Performance
    • It isolate the Tensor operation from the
  • Open source

Usage

  • Infrencing : better performance for a wide variety of ML models
  • Edge ML : can be used any tiny devices

How to use

CONNX running process overview

  1. Load the ONNX model.
  2. Create the runtime to run ONNX model.
  3. After feeding C-ONNX Tensor input into the runtime, the output is in C-ONNX Tensor format.

Installation instructions

Run examples

# Run MNIST example.
connx/build$ poetry run ninja mnist
# Run MOBILENET example.
connx/build$ poetry run ninja mobilenet
# Run YOLOV4 example.
connx/build$ poetry run ninja yolov4

or use connx excutable

connx/build$ ./connx ../examples/mnist/ ../examples/mnist/test_data_set_1/input_0.data

or use python script

connx$ python3 bin/run.py examples/mnist/ examples/mnist/test_data_set_1/input_0.data

Notice: If you want to run on Raspberry Pi 3, please compile with Release mode(CMAKE_BUILD_TYPE=Release) for sanitizer makes some problem.

Using python bindings

import connx

model = connx.load_model('examples/mnist')
input_data = connx.load_data('examples/mnist/test_data_set_0/input_0.data')
reference_data = connx.load_data('examples/mnist/test_data_set_0/output_0.data')

# Run model with input data
output_data = model.run([input_data])
# output_data is an array that contains output tensors

# Convert to numpy ndarray
reference_nparray = reference_data.to_nparray()
output_nparray = output_data[0].to_nparray

# Check output with reference_data
assert reference_data.shape == output_data[0].shape
import numpy
numpy.allclose(reference_nparray, output_nparray)

# You can also convert numpy.ndarray to connx.Tensor
connx.Tensor.from_nparray(ndarray)

Please refer bin/run.py for more information

ONNX compatibility test

ONNX compatibility test is moved to onnx-connx project.

Ports

Contribution

See CONTRIBUTING.md

Supported platforms

  • x86_64
  • x86 - with CLFAGS=-m32
  • Raspberry pi 4 (w/ 64-bit O/S)
  • Raspberry pi 3 (32-bit O/S)
  • ESP32 (No O/S, firmware)
  • ZYNQ (No O/S, firmware)

License

CONNX is licensed under GPLv3. See LICENSE If you need other license than GPLv3 for proprietary use or professional support, please mail us to contact at tsnlab dot com.

connx's People

Contributors

goodsw4all avatar makerj avatar michellejin12 avatar semihlab avatar tribela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

connx's Issues

Conv performance

Conv performance is very low.

  • Iterator occupy CPU more than 50%
  • Conv code is too generalized
  • Specialized Resize outperforms generalized one more than 10 times
  • We need to try change the code to dimension specialized ones

Implement more ONNX operators

Currently, Only few operators are supported on connx to run mnist, yolov4, resnet.
Implement more onnx operators to compatibility and more models to run.

YOLOv4 operator is required

  • Add
  • Cast (without string)
  • Concat
  • Conv
  • Exp
  • Gather
  • GlobalMaxPool
  • GreaterOrEqual
  • LeakyRelu
  • MaxPool
  • Mul
  • NonZero
  • Reshape
  • Resize
  • Shape
  • Sigmoid
  • Slice
  • Softplus
  • Split
  • Squeeze
  • Sub
  • Tanh
  • Tile
  • Transpose

Resize operator optimization

Firstly, thanks for making the ONNX resize operator available in connx! However, when benchmarking a basic model ONNX model that makes use of this operator, basic linear resizing appears to be more than 50 times slower than the rest of the model combined. So it would really help if there'd be some way to optimize it.

안녕하세요. ONNX첫걸음 책 잘 보고있습니다.

안녕하세요.

ONNX첫걸음 책 잘 보고있습니다.
좋은 내용으로 책을 써주셔서 감사합니다.

Coral, Jetson을 활용해 AI모델을 구동해보는 내용을 다루는 2판은 언제쯤 출간되나요?

감사합니다.

Multi-platform/version CI is need

Multiple platforms

  • Linux/x86_64
  • Linux/x86
  • Linux/aarch64
  • Linux/aarch32
  • FreeRTOS/Zynq

Multiple onnx versions

  • 1.5.0
  • 1.6.0
  • 1.7.0
  • 1.8.1
  • 1.9.0
  • 1.10.2
  • 1.11.0

Error: illegal mode: lose input

While converting an ONNX model I have:

Fatal: Cannot import onnx model, got exception from ONNX: illegal mode: lose input onnx::Concat_296

I think it has something to do with the Identity operator. Help with solving this is greatly appreciated.

pip install connx

If connx is installed using pip, onnx-connx's dependency problem can be fixed easily. And connx installation will be easy too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.