OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Onnx2C

Onnx2c is a command-line compiler that reads an ONNX model and generates a C source file for inclusion in a software project, targeting inference on microcontrollers.

Independent OpenViST project profile, based on linked sources.

Onnx2C — Generating a single C file that can be included in an existing project
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use onnx2c when a trained model is available in ONNX format and a microcontroller project is already in place, and you want generated C inference code rather than running a general model runtime on the device.

Who it is for

  • Embedded developers integrating trained ONNX models into microcontroller projects.
  • TinyML developers who need model inference code with compile-time buffer allocation.

Documented uses

  • Convert an ONNX model file into C source for an embedded project.
  • Call the generated model entry function from a microcontroller application.
  • Explore whether an ONNX model may fit an MCU target using the documented helper script.
Before you choose

Requirements & limits

  • The workflow requires an ONNX model and an existing project to integrate the generated code.
  • Building the converter requires Protocol Buffers dependencies, submodules and CMake.
  • Generated code has no stated library requirement beyond the standard C math library; floating-point hardware is recommended.
  • The project reports partial ONNX operator support, so model operator coverage matters.
  • The project documents inference conversion, not backpropagation or accelerator support.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Convert an ONNX model into C source

Generate a C file from an ONNX model for inclusion in an existing project.

Before you start

  • An ONNX model file.
  • A built onnx2c binary.

Steps

  1. Run ./onnx2c [your ONNX model file] > model.c.

  2. Include the generated C file in the project and call its entry(...) function from the main program.

Expected outcome

A generated C source file containing the model inference function.

Guide limitations

  • ONNX operator coverage is partial; the README says 91 of 166 operators are at least partially implemented.
  • Generated code requires the standard C math library; floating-point hardware is recommended.
Source-based practical guide

Build the onnx2c command-line compiler

Compile the repository into the onnx2c binary used to convert ONNX files.

Before you start

  • Protocol Buffers libraries and compiler.
  • Git, submodule support, CMake and make.

Steps

  1. Clone https://github.com/kraiskil/onnx2c.git and enter the repository directory.

  2. Run the command below.

    Documented command
    git submodule update --init
  3. Create a build directory, enter it, run cmake -DCMAKE_BUILD_TYPE=Release .., then run the command below.

    Documented command
    make onnx2c

Expected outcome

The build produces an `onnx2c` binary.

Guide limitations

  • The README notes a Release-build issue on at least Protocol Buffers 3.6 and suggests Debug mode or updating Protocol Buffers.
  • For Protocol Buffers 3.6 or earlier, the README describes modifying onnx/onnx/onnx.proto; versions between 3.6 and 3.12 are uninvestigated.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
14 November 2026
Original website title
kraiskil/onnx2c · Official homepage title · retained in its source language