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
1
vote
1 answer

Is there a Halide::BoundaryConditions to mimic OpenCV default border type?

The documentation says this is similar to GL_MIRRORED_REPEAT. I tried to research this, but it doesn't seem as specific as the OpenCV border types. BORDER_REFLECT_101 as gfedcb|abcdefgh|gfedcba, this is the default. BORDER_REFLECT as…
artless noise
  • 21,212
  • 6
  • 68
  • 105
1
vote
1 answer

Issues setting stride in Halide python bindings (Error: Constraint violated: brighten.stride.0 (1) == 3 (3))

I'm trying to use a C memory layout (RGBRGBRGBRGB) instead of planar from an AOT compiled halide function (build and run with the python bindings.) Following the C++ tutorial here, I set the stride and bounds, but I still get: Error: Constraint…
Ryan
  • 956
  • 7
  • 8
1
vote
1 answer

Halide non-contiguous memory layout

Is it possible to use non-c/fortran ordering in Halide? (where given dimensions x, y, c, x varies the fastest, then c varies the 2nd fastest (strides in numpy at least would be: .strides = (W*C, 1, W) Our memory layout is a stack of images where the…
Ryan
  • 956
  • 7
  • 8
1
vote
1 answer

Sum of array in Halide

I've started learning Halide. Suppose I wanted to calculate the sum of elements in an array. Why is the following code snippet failing? constexpr int N = 10; ImageParam array(Float(32), 1); Var x; Func fsum("sum"); RDom i(1, N); fsum(x) =…
wojas
  • 127
  • 5
1
vote
1 answer

When trying to build Halide on Linux system with llvm-10.0 on release/10.x and master branches, facing the below issue

[ 53%] Linking CXX executable test_function_dag /bin/ld: ../../libHalide.so.10.0.0: undefined reference to `typeinfo for llvm::SectionMemoryManager' collect2: error: ld returned 1 exit status make[2]: ***…
harry
  • 970
  • 6
  • 25
1
vote
1 answer

How to solve Halide Constraint violation problem (in Python)

Can anyone help? I've implemented a halide aot function in python to compute a histogram of a grayscale image... I create a numpy array to hold the histogram like so: histo = np.empty((1, 2048), dtype=np.uint64) In this case, I have: histo.shape:…
user992113
  • 163
  • 1
  • 9
1
vote
1 answer

how do I dispatch the functions that generated by halide (tutorial lesson 15)?

The tutorial generates 3 functions with different target and pack into a single static library along with halide runtime. The question is, how do I call it ? To my understanding, I should check the cpu feature before calling the functions. What is…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
1
vote
1 answer

How do I switch auto-scheduler of "lesson 21: Auto-Scheduler" to Adam2019 or Li2018

I believe that the auto-scheduler adopted in lesson_21_auto_scheduler_generate.cpp is a classical Mullapudi2016 algorithm. How do I switch this auto-scheduler to Adam2019 or Li2018 for this lesson ? Is Adam2019 still in experimental stage…
prgbenz
  • 1,129
  • 4
  • 13
  • 27
1
vote
1 answer

Speed up compilation and bench-marking of schedules

I am making a program that is bench-marking a lot of generated schedules for a particular algorithm. But that is taking a lot of time, for the most part due to the compilation of each schedule. And I was wondering If there are any ways to speed up…
Tkbdsl3cbB
  • 13
  • 3
1
vote
1 answer

The visibility of halide_library in subdirectory using CMake building system

It seems that the Halide library created using: halide_library(xxx SRCS xxx_generator.cpp) in CMakeLists.txt in a subdirectory is invisible to its parent or parallel-directories. For example, I have a Halide project using CMake like this: ├── A │ …
Jiang
  • 149
  • 6
1
vote
1 answer

Cannot find -lHalide when compiling a toy program

I've been trying to install and use Halide. I installed Halide by doing the following: I cloned the Halide repo then executed the following commands from the root of the repository. mkdir build cd build cmake .. sudo make install After the…
Harsh Parekh
  • 33
  • 1
  • 8
1
vote
1 answer

How to debug Halide's print_when() only when environment variable is set?

I'd like to set an environment variable when running my code, e.g. DEBUG=TRUE ./run_my_halide_program, and only see the output of Halide's print_when() statements when said variable is set. However, print_when() seems to only take Halide::Expr's,…
1
vote
2 answers

How to operate on a neighborhood or patch of surrounding pixels?

This question is for the Halide language. Say for a particular (x, y), I want to operate on a KxK patch around (x, y). E.g. sum them, square them, etc., to get the obtain the new value for (x, y). Most of the Halide examples I've found "hard-code"…
1
vote
1 answer

how to schedule a pipeline with different auto scheduler?

I want to test how the different auto schedulers work. I know there are 3 different auto schedulers: "Mullapudi2016" (the default auto scheduler), "Adams2019", and "Li2018". "Adams2019" is located in apps/autoscheduler…
WJ SHI
  • 13
  • 2
1
vote
1 answer

Is Halide math performed in "float" (32-bit)?

I am writing Halide code and I have declared a Buffer< double> input as the input to my Halide function. However, I am not sure if that makes any sense since Halide tutorial#1 says // Halide does type inference for you. Var objects represent //…