-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[OpenCL] Skip opencl memory operations on empty tensors #7672
[OpenCL] Skip opencl memory operations on empty tensors #7672
Conversation
Since this is not a opencl specific problem, ideally we should think about how to handle this case in all backends. For now I think we should have the same change for cuda, rocm, and vk as well. |
I don't think cuda has this issue, I this cudamalloc does this under the hood, as does standard C malloc. I agree, though, it looks like we need it for rocm and vulkan. |
Can the runtime attempt to free a buffer that was allocated that is of size 0? Could that trigger a segfault? |
Feasibly. I didn't see such an issue with opencl, but indeed memory freeing doesn't pass in size, so I can't do the same check: tvm/src/runtime/opencl/opencl_device_api.cc Lines 129 to 136 in e697f03
|
But it would be easy to check for null before freeing |
Maybe we can implement all book keeping stuff in |
It's messy, but we could write a default method that checks for these things and then calls a helper function. We then mark the default function as final and change ALL of the device classes to override the helper functions. |
Closing in favor of #7691 |
cc @masahi @tmoreau89