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
0
votes
1 answer

scheduling prefetch in halide rdom update stage

I've been trying to recreate a hand tuned c function via halide. It is a a series of histograms done on vertical scanlines of the source image. As such I'm using an 1 dimension RDom to iterate the source image. RDom reductionY(0,…
0
votes
1 answer

Define a function with buffer as bounding box parameter in halide

I am trying to define a function to generate a mask image using halide. There is a buffer Buffer bounding_box; bounding_box(0, 0) = min_x0; bounding_box(0, 1) = max_x0; bounding_box(0, 2) = min_y0; bounding_box(0, 3) = max_y0; bounding_box(1,…
UNCAL LEE
  • 23
  • 3
0
votes
2 answers

No member named dim in Halide::GeneratorInput

I'm trying to translate the resize app from the halide repository from the inline declarations to a generator. Everything seems to work fine, except for this: Func clamped = BoundaryConditions::repeat_edge(input);` In the original code, input is…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

How to make performant AOT blur with variable kernel size?

What would be an effective single threaded scheduling for this type of code? I'm trying to define blur but with a variable kernel size in AOT. I tried https://github.com/halide/Halide/issues/180 solution but I can't figure a good way to schedule it…
Fran6co
  • 173
  • 6
0
votes
1 answer

Using Tuple with Halide AoT compilation

I'm using Halide for some parts of a C++ code base. I have a function with AoT compilation that evaluates a Tuple-valued Func so it was compiled to buffer_t structs as an input to the function before (now it's compiled to halide_buffer_t). In the…
B.Md
  • 107
  • 2
  • 10
0
votes
1 answer

Unexpected results using ImageParam inside a loop with the same input/output buffer

With the code below I noticed some unexpected differences for the same input. Some times the while loop execute different quantities of iterations, even using the exactly the same code and input data. I got the same problem scheduling for CPU and…
Marcelo
  • 33
  • 5
0
votes
1 answer

Executing Func over a specific domain in generator

I have this example generator that fills a region (0,0,100,100) with black: class MyGen : public Generator { public: Var x, y; Output output { "output", Int(32), 2 }; void generate() { output(x, y) = x + y; …
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

Vectorize for output buffers with mismatching width

I have generator that uses a .vectorize(x, 8) in its schedule. The issue that I face is that, if my output buffer width is not a power of 8, I'll get accesses outside the buffer! I can certainly clamp the input x, y to the size of the image, but I'm…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

Halide: Copying a block of memory to an overlapping location (same image)

I need to move a region from a texture to another location. If the two blocks don't overlap, there's not problem there. I know Halide is the right solution but I can't figure out how to wait for a read before writing to an overlapping pixel... I…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

Output bufferhas type int32 but elem_size of the buffer passed in is 1 instead of 4

I'm compiling a Func to a static library, and using it in a C program. I'm getting a message saying: Output buffer f20 has type int32 but elem_size of the buffer passed in is 1 instead of 4. I can't figure out what I'm doing wrong in this case.…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

errors with updating halide function in all pixel

I try to implement an optical flow algorithm in Halide. I have some problems with the update of u and v vectors. Here is my C++ version: for(int i= 0; i
R. Fomba
  • 79
  • 8
0
votes
2 answers

How to visualize Halide camera pipeline / generate HTML output of how Halide compiles?

I've tried adding the following line to the bottom of camera_pipe_generator.cpp to output how Halide compiles into a .html file, but I'm not sure what I'm doing wrong: processed.compile_to_lowered_stmt("camera_pipe_debugging_trial.html", {},…
0
votes
1 answer

Setting inputs in Func returned from function

I have a function that returns a Func and I'd like to set the input buffers that are defined as ImageParams. I can't seem to find a tutorial/test from the github repo that uses this sort of feature. I could use generators to compile in AOT and then…
Philippe Paré
  • 4,279
  • 5
  • 36
  • 56
0
votes
1 answer

Halide AOT for OpenCL works fine as static library but not as shared object

I try to compile the code below both to static library and to object file: Halide::Func f("f"); Halide::Var x("x"); f(x) = x; f.gpu_tile(x, 4); f.bound(x, 0, 16); Halide::Target target =…
0
votes
1 answer

Halide with OpenCL using const global * restrict arguments?

In OpenCL we get an efficient hardware path for input arguments when we specify them as const global * restrict as in (for a piece of handwritten OpenCL code): __kernel void oclConvolveGlobalMem(const global float* restrict input, …
Klamer Schutte
  • 1,063
  • 9
  • 18