You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Making two slices from a buffer with the same dimension and index should point to the same buffer and should be interchangeable. Passing the first slice to a halide func and using the second slice to copy to host should copy the result of the halide func execution to the host.
Actual
Copying the original buffer, as well as the second slice are not marked dirty. Only the first slice is marked dirty after running the pipeline. Is this documented behavior?
main.cpp
Halide::Runtime::Buffer<uint32_t, 3> buf(std::vector{8, 8, 2});
buf.fill(0);
buf.set_host_dirty();
buf.copy_to_device(halide_opencl_device_interface());
auto slice = buf.sliced(2, 0);
consumer(slice);
printf(">> Copying the parent buffer (%s) to host\n", buf.device_dirty() ? "dirty" : "notdirty");
buf.copy_to_host();
print(buf);
auto newslice = buf.sliced(2, 0);
printf(">> Making a new slice (%s)\n", newslice.device_dirty() ? "dirty" : "notdirty");
newslice.copy_to_host();
print(newslice);
printf(">> Using existing slice (%s)\n", slice.device_dirty() ? "dirty" : "notdirty");
slice.copy_to_host();
print(slice);
auto sliceagain = buf.sliced(2, 0);
printf(">> Making a new slice again (%s)\n", sliceagain.device_dirty() ? "dirty" : "notdirty");
sliceagain.copy_to_host();
print(sliceagain);
copy_to_host() will only copy the buffer back if it is marked as device_dirty. Unfortunately, dirty-bits are not automatically synchronized between slices/crops of other buffers and the original. While this is currently normal behavior, it is somewhat error-prone for new users. It's currently still your responsibility to correctly mark sliced buffers as dirty, or the parent buffer as dirty, depending on your use case.
Related for an in-depth discussion and me struggling to debug something related: #8395.
Expected
Making two slices from a buffer with the same dimension and index should point to the same buffer and should be interchangeable. Passing the first slice to a halide func and using the second slice to copy to host should copy the result of the halide func execution to the host.
Actual
Copying the original buffer, as well as the second slice are not marked dirty. Only the first slice is marked dirty after running the pipeline. Is this documented behavior?
main.cpp
main.py
Verbose debug output
The text was updated successfully, but these errors were encountered: