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

Halide error loading png images using libpng in VS 2015 Express

When I tried to call load_image function in Halide, I got an error "error during init_io". Debugging shows the error is in load_png function. bool load_png(const std::string &filename, ImageType *im) { #ifdef HALIDE_NOPNG return false; #else //…
aristg
  • 62
  • 6
0
votes
1 answer

halide linker errors with boundary conditions

I've run into a problem trying to call boundary conditions in halide code. I'm using the binary build halide-mac-64-trunk... from the site. I've had no other problems calling other halide functions. Image input = load_image(argv[1]); bounded_luma =…
0
votes
2 answers

Why can we not specialize based on loop variable states?

Suppose we had the following: Var idx; Func out; out(idx) = select(idx == 0, VAL_1, select(idx == 1, VAL_2, VAL3)); It would be nice to be able to force Halide to use if/then/else constructs for this in the loop body, instead of selects. I was…
Sander Vocke
  • 125
  • 5
0
votes
1 answer

Is it possible to use an external library with Halide?

I'd like to loop over an image, applying a complex operation to each 8x8 patch. To give an example, say I need to compute the singular value decomposition (SVD) of each patch and store the 3rd singular value in an output image. Is it possible to use…
pariasm
  • 1
  • 1
0
votes
1 answer

When will compile_to_c with vector types be supported?

When will compile_to_c with vector types be supported? I've added calling Pipeline::compile_to_c() at conv_layer.cpp:93 line for getting C code generated by halide. std::vector empty_arg; // p is defined like "Pipeline…
junhee
  • 221
  • 1
  • 5
0
votes
2 answers

Multiple Target Static Library - Crash

I was experimenting with the multiple target feature ahead of time code generation - static library option. I wrote a generator and was able to generate static library and header files for multiple target features like…
0
votes
1 answer

How to name Multiple Outputs of a Function (Tuple)?

Say I have a Generator for generating Ahead of Time compiled function something like the following. Halide::Func build(){ Halide::Func func1("func1"), func2("func2"), func3("func3"); Halide::Func result("result"); func1(x,y) = input(x,y) *…
0
votes
1 answer

How to handle errors at runtime in halide?

In case of Ahead of Time compilation, How can I make Halide to throw exceptions which could be handled at a higher call stack? Say for example when an input image is accessed at an incorrect location.
0
votes
0 answers

Optimization using Halide

I'm using Halide to optimize a stencil computation, but the scheduling part is kind of a challenge! Here's my Halide code, and I am using AOT compilation: //Halide declarations: Param max_x, max_y, max_z; Param r; Var x("x"), y("y"),…
M_rr113
  • 29
  • 3
0
votes
2 answers

Is there a way to force Halide not to generate code which use vector instructions?

We have implemented few algorithms using Halide language which uses arctan like trigonometric functions. But for the instrumentation purposes we want to force Halide not to generated vector instructions. We are using visual c++ in windows and cl…
Krv Perera
  • 119
  • 2
  • 15
0
votes
1 answer

Weighted Sum Scheduling in Halide

I am implementing a Radial Basis Function in Halide, and while I have it running successfully it is quite slow. For each pixel I compute the distance, then take a weighted sum of this distance to produce the output. To loop over the weights I use an…
Kantthpel
  • 149
  • 10
0
votes
1 answer

Why does the last func in a series start with halide_copy_to_host, and how to remove it

I have a program that creates a gradient image. If I compile this for my GPU and look at the output of the compile_to_lowered_stmnt I see it starts with (after the produce statement) a halide_copy_to_host and then starts the outer loop. If I nest…
0
votes
2 answers

How to convert OpenCV Mat to Halide Image and back?

My goal is augment my pre-existing image processing pipeline (written in Halide) with OpenCV functions such as NL means denoising. OpenCV functions will not be capable of using Halide's scheduling functionality, so my plan is to realize each Halide…
Kantthpel
  • 149
  • 10
0
votes
1 answer

Programming Morphological Opening returns input

I'm programming morphological opening and it's returning the result that's the same as the input image. Am I misunderstanding the explanation of it? My code is: Var x, y; Func limit, erosion, dilation; ImageParam input(type_of(),…
Rok
  • 476
  • 1
  • 5
  • 12
0
votes
1 answer

Issues with Halide select statement

I'm trying to do some stencil computation using Halide. So assuming a basic 5 point 2D stencil, to evaluate some value at cell i,j I need the values of i-1,j i-2,j, i+1,j i+2,j. Now the way this works in C++ is that I have a for statement: for(int i…
B.Md
  • 107
  • 2
  • 10