-
Notifications
You must be signed in to change notification settings - Fork 75
prevent get_backend
from overflowing the stack
#602
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
base: main
Are you sure you want to change the base?
prevent get_backend
from overflowing the stack
#602
Conversation
Your PR no longer requires formatting changes. Thank you for your contribution! |
Prevent the `get_backend` methods from overflowing the stack/recurring without bound. Hoping this doesn't cause inference issues due to deeper call stacks. Fixes JuliaGPU#588
9148e33
to
e86a332
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #602 +/- ##
==========================================
- Coverage 47.52% 0.00% -47.53%
==========================================
Files 22 21 -1
Lines 1715 1577 -138
==========================================
- Hits 815 0 -815
- Misses 900 1577 +677 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is how it looks now: julia> using KernelAbstractions
Precompiling KernelAbstractions...
37 dependencies successfully precompiled in 60 seconds. 29 already precompiled.
julia> struct UnknownAbstractVector <: AbstractVector{Float32} end
julia> get_backend(UnknownAbstractVector())
ERROR: ArgumentError: throwing to prevent a stack overflow, possibly a `get_backend` method is missing?
Stacktrace:
[1] (::KernelAbstractions.var"#t#1")()
@ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:514
[2] get_backend_recur(f::typeof(parent), x::UnknownAbstractVector)
@ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:517
[3] get_backend(A::UnknownAbstractVector)
@ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:523
[4] top-level scope
@ REPL[4]:1 |
# Should cover SubArray, ReshapedArray, ReinterpretArray, Hermitian, AbstractTriangular, etc.: | ||
get_backend(A::AbstractArray) = get_backend(parent(A)) | ||
get_backend(A::AbstractArray) = get_backend_recur(parent, A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_backend(A::AbstractArray) = get_backend_recur(parent, A) | |
function get_backend(A::AbstractArray) | |
P = parent(A) | |
if P isa typeof(A) | |
throw(ArgumentError("Implement `KernelAbstractions.get_backend(::$(typeof(A)))`")) | |
end | |
return get_backend(P) | |
end |
Perhaps this would do it?
Prevent the
get_backend
methods from overflowing the stack/recurring without bound.Hoping this doesn't cause inference issues due to deeper call stacks.
Fixes #588