kandi X-RAY | Halide Summary
kandi X-RAY | Halide Summary
a language for fast, portable data-parallel computation
Top functions reviewed by kandi - BETA
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
Trending Discussions on Halide
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:
ANSWERAnswered 2021-Nov-22 at 19:09
You could turn the base class into a template:
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?...
ANSWERAnswered 2021-Oct-28 at 08:47
There'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
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:...
ANSWERAnswered 2021-Aug-18 at 18:16
Here's a way using the
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:...
ANSWERAnswered 2021-Aug-09 at 01:31
Here's an example Halide program for converting from RGB to HSL:
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?...
ANSWERAnswered 2021-Aug-09 at 16:43
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:
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:...
ANSWERAnswered 2021-Mar-15 at 16:09
There 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
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:
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.
ANSWERAnswered 2021-Feb-03 at 20:39
This 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):
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:...
ANSWERAnswered 2020-Oct-26 at 18:04
You 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
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....
ANSWERAnswered 2020-Oct-16 at 18:09
You 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.
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:...
ANSWERAnswered 2020-Aug-15 at 04:42
There are a number of ways to do this. You can do it perhaps most directly using a
y%2==0. Something like:
No vulnerabilities reported
Reuse Trending Solutions
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page