Questions tagged [halide]

For question related to the Halide domain-specific language including scheduling, and computations. Halide supports different languages such as C, C++, Matlab/octave and Python. Please consider a language tag as well.

Overview

Halide is an open-source domain-specific language which allows flexibility in iterating over dimensions to apply computations.

There are two basic parts to Halide code. One describes the computations and the second is the schedule. The schedule allows trade-offs between redundant computations, cache locality and parallelism as the computations iterate over the data space.

Halide is principally used for image processing and computational photography, but it can be applied to audio, encryption, machine vision, and physical simulation. In some ways, Halide is an aspect oriented framework; it separates the description of the algorithm from the definition of how that algorithm is to be implemented via a schedule.

Halide is embedded within C++ and uses the LLVM plug-in mechanics to generate code. Two modes are supported:

  1. JIT (just in time) - in this mode, the code is created at run time. The generated code is available to be called. The Halide code consists of templates and classes which may be updated at runtime. This mode is very flexible for iterating over different design choices.
  2. AOT (ahead of time) - this is like a more traditional compilation mode. Two executeables are built. One is a generator which creates an object file with several functions. The object file take parameters (buffers, etc) and produces outputs (buffers, constants). The generates object can be linked to many languages that are ABI compliant, such as even thought the primary language used to code Halide is C++.

It can be helpful to specify which mode you are targeting when asking questions.

Resources/References

The Halide tutorials give a gentle introduction to topics and concepts related to the framework.

More information can be found on the website: http://halide-lang.org

Much of the information here is taken from a CppCon 2020 video by Alex Reinking.

253 questions
1
vote
1 answer

Setting Bounds on Vars in Halide Funcs

I have a 3x3 Convolution Function defined like this conv(x, y) = 0; conv(x, y) += kernel(r.x, r.y) * in(x + r.x - 1, y + r.y - 1); Size of the input buffer is 16 x 16 If I want to execute it with padding I can directly do in =…
Arnab Mitra
  • 127
  • 1
  • 6
1
vote
1 answer

Halide Func reshape

I want to convert the dimensions of a Halide Func. For example consider the following, func1(x, y, z) = some operation I know the range of each dimension of the function. Lets assume they are x = [0, 3], y = [0, 3], z = [0, 15] Now if I want to…
Arnab Mitra
  • 127
  • 1
  • 6
1
vote
1 answer

rfactor schedule for descriptor matching

I'm trying to use Halide for brute-force descriptor (e.g SIFT) matching. I'd like to try rfactor in the schedule, but I can't seem to get the associativity prover to oblige. So far I have the following: Var c("c"), i("i"); Func diff("diff"),…
1
vote
1 answer

Halide: Reduction over a domain for the specific values

I got a func f(x, y, z) in which the values is either 1 and 0, and I need to get the the first 100 coordinates of the values which equals to 1, to reduction/update them to 0. This is very simple to realize in c and other languages, However, I've…
1
vote
1 answer

Convert halide image to opencv mat faster?

I am trying to convert buffer image to opencv mat by mat.at(i,j),but it runs 20 ms .It's too slow.How to improve the speed ?or another method to convert buffer image to cv::Mat? Halide::Func gray; Halide::Var x, y; gray(x, y) =…
tso2386710
  • 13
  • 4
1
vote
2 answers

Combining multiple halide functions but keeping the dimensions same

I have three Halide functions which have the following output dimensions: 40 x 40 x 64 40 x 40 x 128 40 x 40 x 64 I want to combine them into a single function so that I get a function handle for later use. So for here , the resulting function…
Arnab Mitra
  • 127
  • 1
  • 6
1
vote
1 answer

Halide: Computing a result image (2D buffer) from a stack of input images (3D buffer)

I am a beginner with Halide. I would like to compute a result image from a stack of input images, and I want to accelerate it using the GPU (currently I am using CUDA as the target). For example, I want to calculate the atan2 of 4 images such as…
Øystein
  • 21
  • 2
1
vote
2 answers

How to make Halide use the sliding window optimization?

I'm learning Halide and I'm struggling with the scheduling part. I'm trying to make Halide do the same thing as a hand coded implementation of the algorithm. I don't want to parallelize it but to vectorize it, but first I wanted to understand how to…
Fran6co
  • 173
  • 6
1
vote
1 answer

Initialize Func from an array

Is it possible to initialize a Func from an array in a generator class? The code should look like this. class SobelConv: public Halide::Generator { const signed char kernelx[3][3] = { {-1, 0, 1}, {-2, 0, 2}, {-1, 0,…
aristg
  • 62
  • 6
1
vote
1 answer

Exploitation of GPU using Halide

I'm implementing an algorithm using Halide while comparing hand-tuned(using CUDA) version of same algorithm. Acceleration of the Halide implementation mostly went well, but still slower a bit than hand-tuned version. So I tried to see exact…
xoke
  • 23
  • 4
1
vote
1 answer

Are there any restrictions with LUT: unbounded way in dimension

When trying to run the sample code below (similar to a look up table), it always generates the following error message: "The pure definition of Function 'out' calls function 'color' in an unbounded way in dimension 0". RDom r(0, 10, 0, 10); Func…
Marcelo
  • 33
  • 5
1
vote
0 answers

Bilateral Grid with OpenGL/GLSL schedule

I am trying to re-implement the bilateral grid example with multi-channel input/output(3 channels image). And try to use the OpenGL/GLSL schedule. Here is the code segments that I wrote. class BilateralGrid : public Halide::Generator
bourne
  • 11
  • 2
1
vote
0 answers

Example for Halide generated mex usage in windows matlab

Summary: When trying to run halide-mex from Matlab with an example similar to iir_blur.cpp and apps\HelloMatlab\run_blur.m in windows - the Matlab application crashes on calling mex. The halide generator under evalution has two parameters one float…
1
vote
1 answer

Halide: How to process image in (overlapping) blocks?

I'm discovering Halide and got some success with a pipeline doing various transformations. Most of these are based on the examples within the sources (color-transformations, various filters, hist-eq). My next step needs to process the image in…
sascha
  • 32,238
  • 6
  • 68
  • 110
1
vote
1 answer

Is there any way to combine Funcs into a Func has one more dimension?

I started to learn Halide from last month. And finally encounterd big problem for me. I'm trying to implement function like following C-like code in Halide. for( int y = 0; y < 3; ++y ){ for( int x = 0; x < 3; ++x ){ out(x, y) =…
xoke
  • 23
  • 4