Giter Site home page Giter Site logo

onnx2code's Introduction

onnx2code

Generate plain C++ code for inference of ONNX models without dependencies

This project was made as an alternative to a final exam for the assignment "Computer Organization II". You can read the writeup in docs/TP Final onnx2code.pdf (in Spanish).

Model support

The following models have been tested and work as expected.

Model Size
mnist 26 KB
Super_Resolution 240 KB
squeezenet1.1 9 MB
emotion_ferplus 34 MB
inception-v2 44 MB
resnet50-caffe2-v1 98 MB
VGG 16 and VGG 16-bn 527 MB
VGG 19 and VGG 19-bn 548 MB
VGG 19-caffe2 561 MB
  • Minimum ONNX opset version: 7
  • Quantized models are not supported

Operator support

Only float data type is supported.

Operator Attribute support
Add, Div, Mul, Sub ✅ with broadcasting
Concat ✅ with multiple inputs
✅ axis
Conv ✅ bias
✅ stride
✅ padding (and auto_pad)
❌ dilations
❌ depthwise (group != 1)
Sum ✅ with multiple inputs
❌ with broadcasting
Relu, Tanh, Sigmoid, Clip
Gemm ✅ with bias
❌ transpose A
✅ tranpose B
❌ alpha != 1
❌ beta != 1
Identity
MaxPool, AveragePool ✅ stride
✅ padding (and auto_pad)
❌ dilations
❌ storage_order != 0
❌ count_include_pad != 0
Softmax ✅ stride
✅ axis
Transpose ✅ perm

Setting up with Docker

We provide a ready to use Docker image:

docker run --rm -it -v $pwd/mnist.onnx:/app/input.onnx:ro -v $pwd/output:/app/output:rw mlomb/onnx2code:latest --variations=im2col,loop-tiling --checks=3

The command above will generate C++ code for the mnist.onnx model in the output folder.

Setting up locally

Prerequisites

  • gcc (required if checking models)
  • Python 3.10
  • pipenv

Clone and install dependencies with pipenv install.

Run

To generate code from an ONNX model, run the following command inside a pipenv shell:

python -m onnx2code --variation=im2col,loop-tiling mnist.onnx output_folder --checks=3

onnx2code's People

Contributors

mlomb avatar nachovigilante avatar sponja23 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

quanglets1fvr

onnx2code's Issues

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.