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: How to avoid unwanted assertions

During development of a pipeline in Halide, I want to avoid unnecessary checks on buffer layouts. I know I can turn off the majority of assertions using the 'no_asserts' target feature. However, I generated the following simple code: #define…
PJM Aarts
  • 5
  • 3
0
votes
1 answer

How to do a forward followed by inverse FFT in Halide

I am currently trying to do a forward followed by a reverse fft, however it doesn't seem to be working. The FFT I am using is the one found in fft.cpp (Halide/apps/fft). My goal currently is just trying to save a 16x16 tile of an image. This 16x16…
0
votes
1 answer

How to generate the plugin of "Li2018" in Halide on windows and exploit "load_plugin" in other project?

reccently, I want to test how does the autoscheduler "Li2018" work on GPU. Firstly, I need to load the plugin of this autoscheduler into my project with function "load_plugin("gradient_autoscheduler")" like the example:…
WJ SHI
  • 13
  • 2
0
votes
1 answer

Halide: How to avoid unwanted execution overhead in Halide LUT index

The calculation of input value to LUT index is constant over multiple calls, therefore I calculate the contents of 'indexToLut' upfront. However, this also means that the checks on the values in that buffer cannot be done here. The LUT itself has…
PJM Aarts
  • 5
  • 3
0
votes
1 answer

Is it possible to create an ImageParam with a predefined size for a Halide pipeline?

Currently, I am trying to cross compile a Halide pipeline. The arguments for the pipeline were initially ImageParam ifm(type_of(), 4, "ifm"); ImageParam kernel(type_of(), 4, "kernel"); ImageParam bias(type_of(), 1,…
Arnab Mitra
  • 127
  • 1
  • 6
0
votes
0 answers

How to convert type of Input to common data type(such as int) in halide::generator?

I am a new guy trying Halide programming. I met an issue when porting some Halide code into Android via Halide::Generator. Below is my code: #include "Halide.h" using namespace Halide; using namespace Halide::ConciseCasts; using namespace std; Func…
walter
  • 11
  • 2
0
votes
1 answer

How Halide applies Interval analysis?

Can someone explain where and how Halide applies interval analysis internally? Does Halide use interval analysis on an array-based data dependence test?
0
votes
1 answer

How to transpose an Image buffer in Halide?

I want to transpose a Halide::Buffer.Is there a way to do it? I have tried transpose() in Halide. But it shows error. Halide::Func B; Halide::Var x, y, c; B(x, y, c)= 0.0f; B(0,0,c)= 1.0f; B(1,0,c)= 0.0f; B(2,0,c)= 0.0f; …
0
votes
2 answers

How to pass an image in a Halide::Runtime::Buffer in Halide aot compilation?

So in the Halide aot example https://halide-lang.org/tutorials/tutorial_lesson_10_aot_compilation_run.html, there's this line: Halide::Runtime::Buffer input(640, 480), output(640, 480); My question is, how does one load an image into the…
zengod
  • 1,114
  • 13
  • 26
0
votes
0 answers

Halide Func Constructor

I am reading source code of Halide, and the constructor of Func looks wierd, anyone knows what does these underlines mean? Thanks. template HALIDE_NO_USER_CODE_INLINE explicit…
D.pz
  • 161
  • 7
0
votes
1 answer

How to get the function to be computed differently for different values of x?

Func support("support"); Expr left_x = clamp(x, 0, left_buffer.width() / 4); RDom scan_left(0, left_buffer.width() / 4, 0, left_buffer.height()); scan_left.where(scan_left.x != left_x && scan_left.y != y); support(x, y) =…
zengod
  • 1,114
  • 13
  • 26
0
votes
1 answer

How to generate position independent code in Halide with ahead of time compilation

I'm trying out halide and want to build a small shared library on top of it. But the code generated by Halide's AOT compilation seems not being position independent. How do I link the objects generated by Halide into my shared library? [Update]…
jiamingy
  • 56
  • 6
0
votes
1 answer

Is is possible to generate an (.ll) file from halide code?

Is is possible to generate an (.ll) file from halide code ? Only way I found to do that was through HL_DEBUG_CODEGEN=2 but that generates alot of architecture related code. In other words, is there anyway to get llvm code for a specific image…
M.A.
  • 31
  • 6
0
votes
1 answer

Can Halide be used with SOC Platforms?

I'm trying to use Halide with Texas Instrument's TDA2x platform which is a SoC with DSP and other vision processors in it. I basically want to run code generated by Halide in the DSP of TDA2x. TDA2x supports TI's cl6x compiler. How can I generate…
M.A.
  • 31
  • 6
0
votes
1 answer

How to define generic reductions using any binary Operator example OR or AND, custom function?

I believe Halide currently supports sum,minimum,maximum and product which work with RDom. I would like to write a function which does reductions over custom binary operations For Eg. 'AND (&&)', 'OR (||)', '(&)', '(|)' etc. How can I do this in…