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

How do I keep passing the output of a Halide pipeline back into the pipeline until some condition is met?

I have a Halide pipeline which takes in an image, and applies some filters to it. It works fine for a single pass. I pass in an image, and I get the processed image as the output. What I would like to do is implement multiple passes i.e., I want to…
postmalloc
  • 90
  • 1
  • 8
0
votes
1 answer

Halide JIT vs Generator Differences

While playing around with Halide, I see that totally different pseudocodes are created for a same pipline when using JIT and a generated function approaches. It looks like I'm missing something and so I'd very appreciate and hint. Here is what I…
lyblue
  • 1
0
votes
1 answer

Is there a way to specifiy a Halide computation that operates on quartets of pixels?

In Halide, is there a way to split up an input image into 2x2 quartets of pixels and implement a unique computation in each pixel of the quartet? For example, I want to implement the following computations for each pixel in the quartet: Upper left:…
rohitsan
  • 1,001
  • 8
  • 31
0
votes
1 answer

How to build a windows static library for lesson15 under windows platform?

I have successful built the LLVM and Halide with Visual studio 2019 on windows platform. I then tried to make some no_runtime objs and a halide_runtime obj and link them together. ./lesson_15_generate \ -g my_first_generator \ -f…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
0
votes
1 answer

How do I use declare a halide Func with float16_t?

let say I want to perform a running horizontal average on x-axis of an image. Func g; g(x,y) = (img(x-1,y) + img(x,y) + img(x+1,y))/3.f; h(x,y) = cast(g(x,y) + 0.5f); Using float32 for g(x,y) seems to be overkill but I do care about…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
0
votes
1 answer

Halide process average of color image

I am starting to learn Halide. What I want to do is apply a filter based on the average value of an RGB image. Essentially, I am trimming the highlights and the lows for further processing. I need the average across all channels as it would not be…
jllangston
  • 127
  • 1
  • 5
0
votes
1 answer

How to debug Halide internal error with CodeGen_LLVM

I have problems finding the source of an error message reported by JIT-compiled pipeline with halide. The log message is: Internal Error at Halide-release_2019_08_27/halide/src/CodeGen_LLVM.cpp:2815 triggered by user code at : Condition failed:…
Resq
  • 161
  • 1
  • 8
0
votes
1 answer

Buffer Argument is NULL

I am new to Halide and was given a image processing Pipeline. I am trying to understand this pipe line by printing values. Following the tutorial from https://halide-lang.org/tutorials/tutorial_lesson_04_debugging_2.html, I tried to print the…
0
votes
1 answer

how to free a CPU buffer defined in halide

my projec used the buffer both in GPU and CPU. code are similar like this: xxx = HalideBuffer_n(width, heght, 1); // buffer in CPU xxx.device_malloc(device); // buffer in GPU PS: using HalideBuffer_n = Halide::Runtime::Buffer i can use…
BirdQAQ
  • 3
  • 1
0
votes
1 answer

How does Func.realize in Halide works?

I can understand the explanation in tutorial 6, which is: // Func gradient("gradient"); // Var x("x"), y("y"); // gradient(x, y) = x + y; // gradient.realize(8, 8); // // This does three things internally: // 1) Generates code than can evaluate…
Lin.Chen
  • 73
  • 4
0
votes
2 answers

Not able to save image in png format while using Halide

I tried running the following program on a Windows machine using Visual Studio: #include #include "halide_image_io.h" #include "png.h" using namespace Halide; using namespace Halide::Tools; int main(int argc, char** argv) { …
user6461722
0
votes
1 answer

Halide: Var declaration format

When declaring a Var inside a Halite generator class, why does one need to use curly braces like Var x{"x"} if it is outside the function of generate(), while if it is inside the function of generate(), one can use either curly braces or…
Jiang
  • 149
  • 6
0
votes
1 answer

Halide: Cannot print in Generator - "!function_takes_user_context(op->name)"

When I try to print() an expression within a generator, I cannot build: Internal Error at /home/halidenightly/build_bot/worker/linux-64-gcc53-800/halide/src/CodeGen_OpenCL_Dev.cpp:229 triggered by user code at : Condition failed:…
0
votes
1 answer

Halide index error when using AutoScheduler and GPU Schedule, but not default CPU schedule

I am using a Generator to create a static library for my Halide module. I am comparing the default schedule, AutoScheduler, and a GPU schedule that uses simple tiling. I have two inputs of the same size ("source" and "reference") and one…
0
votes
1 answer

CommandLine error in autoscheduler "Li2018" Halide

I want to test the autoscheduler "Li2018" on Ubuntu16.04. I exploit dlopen to load the libgradient_autoscheduler.so to my pipeline (the plugin of autoscheduler Li2018) and build it, but when I ran the executable file, an error has occured:…