my projec used the buffer both in GPU and CPU.
code are similar like this:
xxx = HalideBuffer_n(width, heght, 1); // buffer in CPU
xxx.device_malloc(device); // buffer in GPU
PS: using HalideBuffer_n = Halide::Runtime::Buffer<uint8_t, 3>
i can use
xxx.device_free();
to free the buffer in GPU. but which API can i choose to free the buffer in CPU?
i have used such as free or deallocate, but it seems dont work.
A Halide::Buffer is a shared pointer to the underlying allocation. xxx.deallocate() drops the reference to it. If this is the only copy of that HalideBuffer_n object then it will free the underlying memory too. If it's not freeing it means that another copy of that HalideBuffer_n object exists somewhere.