Hexir

Hexir is a small compiler for neural networks. You give it a graph of operations, it decides which ones run on the CPU and which on the GPU, and it turns them into code you can run.

It is built on MLIR, and it is small enough to read. That is the point: the gap between MLIR’s Toy tutorial and a production compiler like IREE is enormous, and Hexir sits in the middle.

        flowchart LR
    A["your program<br/>tensors"] --> B["decide<br/>where each op runs"]
    B --> C["turn each op<br/>into a kernel"]
    C --> D["run it now<br/>JIT"]
    C --> E["write a file<br/>.hxb"]
    E --> F["run it later<br/>hexir-run"]
    

Two ways to run the same program:

  • Now — compile and execute in one process, the usual way to develop.

  • Later — write a .hxb file and run it with hexir-run, a small program that contains no compiler at all. A GPU kernel is compiled to a CUBIN and embedded, so the runtime launches it with no compiler present.

Start here

If you want to use it, read Getting started.

If you want to understand how it works, read How it works first. It is a picture and eight paragraphs. Then pick whichever of the detailed pages you need.

Where it stands

Hexir is research software. Some parts are finished and some are scaffolding, and the docs say which is which rather than leaving you to find out.

Works

Partly

Not yet

CPU path, end to end

GPU kernels are one block, one thread

Transfer insertion in the JIT path

Per-operation placement

CPU kernels in .hxb are descriptions, not code

Memory planning

.hxb artifacts, CPU and GPU

More operations, and a frontend