Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

mcourteaux
Copy link
Contributor

@mcourteaux mcourteaux commented Jun 24, 2024

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:

  • slicing from a buffer reduces the dimensionality (this is obvious)
  • cropping from a sliced buffer inherits the "cropped_from" field from the sliced Buffer, which which has a higher dimensionality.

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
Copy link
Contributor Author

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

@abadams abadams merged commit a0e1dc0 into halide:main Jun 25, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants