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: (1, 2048)
histo.strides: (16384, 8)
But when I invoke the function I get:
Error: Constraint violated: histogram_pan.stride.0 (2048) == 1 (1)
The aot function is defined as:
b = hl.Var("b")
x = hl.Var("x")
input_image = hl.ImageParam(hl.UInt(16), 2)
histogram = hl.Func("histogram_pan")
histogram[b, x] = hl.u64(0)
r = hl.RDom([(0, input_image.dim(0).extent()), (0, input_image.dim(1).extent())])
histogram[0, hl.clamp(input_image[r.x, r.y], 0, 2047)] += hl.u64(1)
histogram.vectorize(x, 8)
histogram.compile_to({hl.Output.object : 'histogram_pan.o',
hl.Output.python_extension : 'histogram_pan.py.cpp'},
[input_image], 'histogram_pan')```
EDIT: Some additional info:
Someone asked: "what does the error say if you swap the dimensions of the numpy array? -> np.empty((2048, 1) ...)"
When I swap the dimensions as suggested, I have:
histo.shape: (2048, 1)
histo.strides: (8, 8)
and, I get the error:
ValueError: Invalid buffer: length 16384, but computed length 16384