Halide | a language for fast , portable data-parallel computation
kandi X-RAY | Halide Summary
kandi X-RAY | Halide Summary
a language for fast, portable data-parallel computation
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Halide
Halide Key Features
Halide Examples and Code Snippets
import halide as hl
import numpy as np;
x, y, c = hl.Var('x'), hl.Var('y'), hl.Var('c')
f = hl.Func('f')
f[x, y, c] = (x * 3) + (y * 12) + c
# This would be necessary for internally allocated buffers
# f.reorder_storage(x, c, y)
# These
Community Discussions
Trending Discussions on Halide
QUESTION
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 should have a specific input parameter, not available in the base class.
In normal C++ this is quite straightforward, but as Halide is a DSL that "generates code" before linking and compiling, things may get a little bit messy.
My current Halide implementation is all in a single file:
my_generators.cpp
...ANSWER
Answered 2021-Nov-22 at 19:09You could turn the base class into a template:
QUESTION
How to classify compound computationally using RDkit or other libraries? For example, how to tell if a compound is a halide, Amine or Alcohol? Does RDkit have build in functions for this kind of task?
...ANSWER
Answered 2021-Oct-28 at 08:47There's no straightforward way to do that but there are some hacks you can do to classify the compounds. There's a module in rdkit that can provide you the number of fragments especially when it's a function group. Check it out here. As an example, let's say you want to find the number of aliphatic -OH
groups in your molecule. You can simply call the following function to do that
QUESTION
I am currently trying out Halide, playing around with calculating the maximum/minimum over all channels of an image. I would like to achieve this for a arbitrary images, where the amount of channels is only known at runtime.
I successfully got the following solution:
...ANSWER
Answered 2021-Aug-18 at 18:16Here's a way using the maximum
and minimum
helpers:
QUESTION
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 calculate the chroma image first. This is the difference between the maximum and minimum channel value for a given pixel. I tried to find something similar in the documentation, but I was not able to. How would I do this in Halide?
In C++ it would be something like:
...ANSWER
Answered 2021-Aug-09 at 01:31Here's an example Halide program for converting from RGB to HSL:
QUESTION
I want to get a 4 channel image instead of 3 while loading it in Halide, however load_image() gives only 3 channel images. How can I solve it?
...ANSWER
Answered 2021-Aug-09 at 16:43Halide's load_image
function simply loads an image file off the disk. If it's RGB, it will have three channels, if it's RGBA, it will have four channels. This is working as intended.
If you want to add a channel to your image during a pipeline, then you can write:
QUESTION
I am trying to implement an image processing algorithm for a gamut mapping filter for Hardware using Vivado HLS. I have created a synthesizable version from a Halide code. But it is taking way too long for an image of (256x512) it was taking around 135 seconds which shouldn't be the case. I have used some optimizing techniques like pipelining the innermost loop, By pipelining, I have set the target(initiation interval) of II=1 for the innermost loop but the acheived II is 6. From the warnings thrown by the compiler, I have understood that it is because of accessing of the weights like ctrl_pts & weights, From the tutorials, I have seen, using array partitioning and array reshaping would help with the faster accessing of the weights. I have shared the code I have used to synthesize below:
...ANSWER
Answered 2021-Mar-15 at 16:09There are some steps you can do to optimize your design, but bear in mind that if you really need a floating square root operation, that will most likely have a huge latency penalty (unless properly pipelined, of course).
Your code might have a typo in the second inner loop: the index should be j
right?
First off: ctrl_pts is read multiple time from the main memory (I assume). Since it's reused 256x512 times, it would be better to store it into a local buffer on the FPGA (like a BRAM, but it can be inferred), like so:
QUESTION
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 channels of each image are stacked by scanline.
(Sorry if the layout still isn't clear enough, I can try to clarify). Using the python bindings, I always get ValueError: ndarray is not contiguous when trying to pass in my numpy array with .strides set.
I've tried changing the numpy array to use contiguous strides (without changing the memory layout) just to get it into Halide, then setting .set_stride in halide, but no luck. I'm just wanting to make sure I'm not trying to do something that can't/shouldn't be done.
I think this is similar to the line-by-line layout mentioned at https://halide-lang.org/tutorials/tutorial_lesson_16_rgb_generate.html, except more dimensions in C since the images are "stacked" along channel (to produce a W, H, C*image_count tensor)
Any advice would be much appreciated.
Thanks!
...ANSWER
Answered 2021-Feb-03 at 20:39This is more of a numpy question than a Halide one. The following Halide code illustrates use of an array in the shape you are looking for (I think):
QUESTION
My list contains of sentences. There are sentences that can be repeated and there are sentences that are inside some other sentences. For example:
- 'Heterocyclic compounds'
- 'Heterocyclic compounds having oxygen'
Number 1 is inside number 2 so I need to keep only unique one that is number 2.
Part of my list:
...ANSWER
Answered 2020-Oct-26 at 18:04You can make 2 nested loops on the list and for each string you compare with the other, you keep track of longest one the save the results per string. It might not be an optimal solution if you have large data
Code
QUESTION
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 keep passing the output image back into the pipeline for a number of steps until some condition on the image is met. How do I do this Halide? The only other way I could think of doing it was having an external C++ method that can invoke the pipeline in a loop. I was hoping if this is possible natively in Halide.
The code looks something like this. I want to consume output as input in a loop until some condition is met.
...ANSWER
Answered 2020-Oct-16 at 18:09You can run the pipeline a static number of times, by unrolling it into a larger pipeline. If what you are computing is expressible as a single stage, you can run it a dynamic but unconditional number of times by using an RDom
to iterate over successive applications. However, you can not express any loops with a dynamic termination condition (what you might think of as a while
loop). That you have to do in the calling C++ code.
You've hit on quite an insightful question. This is a conscious constraint of the language: it's the difference between loop bounds being decidable, and becoming Turing complete. Future version of the language may extend this in targeted ways, but it's currently quite fundamental to how the compiler can infer all the bounds in your program.
QUESTION
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:
...ANSWER
Answered 2020-Aug-15 at 04:42There are a number of ways to do this. You can do it perhaps most directly using a select
on x%2==0
and y%2==0
. Something like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Halide
No Installation instructions are available at this moment for Halide.Refer to component home page for details.
Support
If you have any questions vist the community on GitHub, Stack Overflow.
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page