Allow graceful failover when one tunable panics #74
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.
Catches panics that occur during the benchmarking phase of autotuning and gracefully falls back to the next algorithm in line.
This allows selecting algorithms based on things like memory constraints (without adding
Result
types all through the memory allocation chain) or even things like potentially unsupported GPU features. Note that this only catches panics during benchmarking, not during regular execution. If an algorithm fails at that point it will still give error feedback to the user.If all tunables panic, propagates the first panic.
One thing worth mentioning is that while it will gracefully continue to the next algorithm, it will not necessarily continue quietly. The error message still gets printed to the console, which could confuse users. Unfortunately I don't think that can be prevented due to how panic is implemented, the print gets output before unwind gets to the benchmark code where the unwind is caught. This can be prevented with a custom panic hook, but that would affect all panics everywhere, which is a bit too intrusive.
Testing
All existing tuners work as expected with all tests passing, and the fallback works for
im2col
convolution when called with parameters that cause an out of memory error.