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

How to visualize halide schedule?

How to visualize halide schedule like this video? HalideTraceViz with viz.sh in halide repository seems to visualize that. But camera_pipe.avi generated by viz.sh just shows nothing but black about 10 seconds. This is the log while playing the .avi…
junhee
  • 221
  • 1
  • 5
2
votes
1 answer

Difficulties implementing the Hysteresis step of Canny Algorithm in Halide without define_extern func

The problem is that when a pixel marked as weak-edge (between the two thresholds) changes to strong-edge (accepted, as described here) it is required to apply the same logic to your connected neighbors recursively (tracking the edges). In an…
Marcelo
  • 33
  • 5
2
votes
1 answer

Halide vs. OpenVX

Halide and OpenVX seem to have similar goals. Can someone comment on where they differ and where they both stand with respect to adoption in the community today?
Lolo
  • 3,935
  • 5
  • 40
  • 50
2
votes
2 answers

Can generators be used for JIT during development?

What is the best strategy for development in HALIDE? The end usage will be Ahead of time compiled using generators. Is there a way to invoke the functions defined in generator for JIT? Thanks
2
votes
2 answers

Initializing Halide Buffer in C++

I'm trying to initialize Halide Buffer with a C++ 1D array. Given some other posts online, this is what I've got so far: Image in(Buffer(type_of(), size_x, 0, 0, 0, NULL, in_ptr)); Where in_ptr is a pointer to my C++ array. When I…
B.Md
  • 107
  • 2
  • 10
2
votes
1 answer

Halide with GPU (OpenGL) as Target - benchmarking and using HalideRuntimeOpenGL.h

I am new to Halide. I have been playing around with the tutorials to get a feel for the language. Now, I am writing a small demo app to run from command line on OSX. My goal is to perform a pixel-by-pixel operation on an image, schedule it on the…
user5597458
  • 45
  • 1
  • 9
2
votes
1 answer

"Simple" Halide program gives stack overflow when compiled

Here's the code. I'm using Halide on VS2013, Win64 trunk of Aug 5, 2015. When I execute diag.compile_to_lowered_stmt("diag.html", {}, HTML), I get a stack overflow inside halide.dll. Image orig_uint = Tools::load_image("../foo.ppm"); Var…
Walt Donovan
  • 357
  • 1
  • 10
1
vote
1 answer

Halide scheduling issue with compute_with

I'm a beginner in Halide and tried to use the compute_with() directive but got an error. I've reduced the program to minimal size: #include "Halide.h" namespace { using namespace Halide; Var x("x"), y("y"), c("c"); class Harris : public…
1
vote
0 answers

Use Halide mirror_image symmetrically

I want to make to extend an input image symmetrically so that if the output image is 20 pixels wider and taller than the input then all 4 sides would have be extended by 10 pixels and the image would be mirrored. I have tried using the mirror_image…
1
vote
1 answer

Do you need to free the buffer pointer passed to Halide

If I create a Halide::Buffer by constructing it with a pointer from an STB_Image function call like so: inline Halide::Buffer LoadFromFile(const char* filename) { int w, h, d; unsigned char* image_data = stbi_load(filename, &w, &h,…
1
vote
1 answer

how to realize a 3-level cached with Halide

I hope to use halide to simulate a three-level cache architecture for cpu. and the memory size is divided by each top layer. such as (256*256) -> 16 * (16*256) -> 16 * 4 * (4*256) -> 16 * (16*256) -> (256*256) I use this cpp function to run Func…
Cery
  • 203
  • 5
  • 14
1
vote
1 answer

Different expressions for different outputs in Halide

I'm new to Halide so also kinda didn't know how to ask the question. Let me explain. Let's assume I have a simple code for Halide's generator like this: class Blur : public Generator{ public: Input> in_func{"in_func", 2}; …
Shirakumo
  • 182
  • 1
  • 1
  • 10
1
vote
0 answers

Halide Error: Input buffer b0 is accessed at -1, which is before the min (0) in dimension 0 - sobel edge detector

I'm trying to develop a sobel edge detector using Halide. Because I need to compute the 3x3 square around each pixel, I'm trying to realize the function over a smaller rectangle (and avoid the outer border). Here's what I came up with so…
1
vote
1 answer

How to derive a class that is already derived from Halide::Generator?

I would like to create a basic inheritance structure based on Halide::Generator in Halide/C++, so as to avoid duplicated code. The idea is to have an abstract base generator class that owns a pure virtual function. Moreover, each derived class…
tuscasp
  • 49
  • 5
1
vote
1 answer

How to calculate chroma image in Halide?

I am currently evaluating if Halide is a good choice for my programmes. As a short Hello Halide example, I wanted to convert an rgb image to hsl space. However, when trying, I got stuck at the first stage. In order to convert to hsl, I would need to…
jan.sende
  • 750
  • 6
  • 23
1 2
3
16 17