halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.78k stars 1.07k forks source link

Fix device slices for Buffer with fixed dimensionality in template. #8313

Closed mcourteaux closed 1 week ago

mcourteaux commented 1 week ago

The device-slicing logic was broken on the C++ level, due to the fact that the buffer device-refcount for crops and slices assumes it was cropped/sliced from a buffer with an equal number of dimensions. This is incorrect for both cropping AND slicing:

This was never tested for in the tests as they were all done with variable number of dimensions (i.e., AnyDims). Thus, I added a test that does a device slice on a Buffer<int, 3>.

The solution is to store that "cropped_from" Buffer as a generic Buffer<T, AnyDims>.

mcourteaux commented 1 week ago

Had a minor misunderstanding about the mechanism of InClassDimStorage. Should be good now, I believe.