Fix device slices for Buffer with fixed dimensionality in template. #8313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aBuffer<int, 3>
.The solution is to store that "cropped_from" Buffer as a generic
Buffer<T, AnyDims>
.