Throw errors on allocation failures #5166
Draft
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.
I figure this one might be controversial, and I'm open to suggestions on how to change this.
When I first made my ncnn_vulkan fork, I noticed that when memory allocation or inference failures would happen, they would just silently fail and log to the console. This made any kind of error handling on the python side impossible, as there was no error being thrown to catch and check for. There was also a specific one of these that certain users only ran into sometimes, and I needed a way to specifically handle that case.
So, my solution was to throw errors in the places that I needed to catch those errors. I have ported those here.
However, I don't know if there was maybe a different way I could have accomplished that same goal, and throwing errors in these places I'm sure could cause unexpected behavior in dependent projects. So, I figured I'd open this one as a draft in hopes that we can reach an agreement on what to do here.
For an example of how I'm using this, look here
(and yes, these get automatically bubbled-up to the python bindings)