(Translated by https://www.hiragana.jp/)
Halide Fork me on GitHub

Halide

a language for fast, portable computation on images and tensors

Halide is a programming language designed to make it easier to write high-performance image and array processing code on modern machines. Halide currently targets:

Rather than being a standalone programming language, Halide is embedded in C++. This means you write C++ code that builds an in-memory representation of a Halide pipeline using Halide's C++ API. You can then compile this representation to an object file, or JIT-compile it and run it in the same process.

The following function defines and sets the schedule for a 3x3 box filter defined as a series of two 3x1 passes:

Func blur_3x3(Func input) {
  Func blur_x, blur_y;
  Var x, y, xi, yi;

  // The algorithm - no storage or order
  blur_x(x, y) = (input(x-1, y) + input(x, y) + input(x+1, y))/3;
  blur_y(x, y) = (blur_x(x, y-1) + blur_x(x, y) + blur_x(x, y+1))/3;

  // The schedule - defines order, locality; implies storage
  blur_y.tile(x, y, xi, yi, 256, 32)
        .vectorize(xi, 8).parallel(y);
  blur_x.compute_at(blur_y, x).vectorize(x, 8);

  return blur_y;
}

First, install Halide. Even if you only intend to use Halide from C++, pip may be the easiest way to get a binary build of Halide. Full releases may be installed from PyPI like so:

$ pip install halide

Every commit to main is published to Test PyPI as a development version and these may be installed with a few extra flags:

$ pip install halide --pre --extra-index-url https://test.pypi.org/simple

We also provide binary tarballs on GitHub.

For the freshest builds, see the continuous build server. The status of the build on each platform is here. If it's green, then it has passed all of our internal tests.

If you would prefer to build Halide from source, see README for instructions.

To get started writing code, look through the tutorials, and the example apps. The tests are small self-contained programs that cover all corners of the language, so they can also be instructive. However they're not designed to teach, so you may find them cryptic.

If you have a question, post on our GitHub Discussions board.

Videos

We gave a talk on Halide at CppCon 2020 that serves as a good overview of what the language is all about.


To go deeper, here's how an expert actually uses Halide, scheduling the same algorithm described in the talk above.


Course Notes

We taught a course on Halide at CVPR 2015. The course notes are a useful introduction to Halide.

Frédo Durand also taught an introduction to Halide in his 6.815/6.865 computational photography course at MIT.

These academic publications describe the ideas behind Halide and its scheduling model. Halide syntax changes over time, so don't rely on them for correct syntax. The tutorials are a better introduction to Halide's syntax.

Halide: decoupling algorithms from schedules for high-performance image processing
Jonathan Ragan-Kelley, Andrew Adams, Dillon Sharlet, Connelly Barnes, Sylvain Paris, Marc Levoy, Saman Amarasinghe, Frédo Durand.
Communications of the ACM (Research Highlights)

Learning to Optimize Halide with Tree Search and Random Programs
Andrew Adams, Karima Ma, Luke Anderson, Riyadh Baghdadi, Tzu-Mao Li, Michaël Gharbi, Benoit Steiner, Steven Johnson, Kayvon Fatahalian, Frédo Durand, Jonathan Ragan-Kelley.
SIGGRAPH 2019

Differentiable Programming for Image Processing and Deep Learning in Halide
Tzu-Mao Li, Michaël Gharbi, Andrew Adams, Frédo Durand, Jonathan Ragan-Kelley.
SIGGRAPH 2018

Automatically Scheduling Halide Image Processing Pipelines
Ravi Teja Mullapudi, Andrew Adams, Dillon Sharlet, Jonathan Ragan-Kelley, Kayvon Fatahalian.
SIGGRAPH 2016

Decoupling Algorithms from the Organization of Computation for High Performance Image Processing: The design and implementation of the Halide language and compiler
Jonathan Ragan-Kelley
Ph.D. dissertation, MIT, May 2014.

Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines
Jonathan Ragan-Kelley, Connelly Barnes, Andrew Adams, Sylvain Paris, Frédo Durand, Saman Amarasinghe.
PLDI 2013

Decoupling Algorithms from Schedules for Easy Optimization of Image Processing Pipelines
Jonathan Ragan-Kelley, Andrew Adams, Sylvain Paris, Marc Levoy, Saman Amarasinghe, Frédo Durand.
SIGGRAPH 2012


This older talk is a companion to the papers. It describes the philosophy of Halide, and the ideas behind the scheduling model.

Development
tutorials
docs
wiki
issues
code
Mailing Lists
halide-announce - announcement of releases and other news.
halide-dev - technical discussion on the development and use of Halide. When in doubt, ask here for help.
Stack Overflow
#halide
License
Halide is open source, under a commercially permissive MIT license. We encourage you to use it in other projects, open source or commercial!