Skip to content
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

findall is not working with an empty vector of bool #2553

Closed
amontoison opened this issue Nov 13, 2024 · 0 comments · Fixed by #2554
Closed

findall is not working with an empty vector of bool #2553

amontoison opened this issue Nov 13, 2024 · 0 comments · Fixed by #2554
Labels
bug Something isn't working

Comments

@amontoison
Copy link
Member

amontoison commented Nov 13, 2024

ERROR: LoadError: BoundsError: attempt to access 0-element CuArray{Int64, 1, CUDA.DeviceMemory} at index [0]
Stacktrace:
  [1] throw_boundserror(A::CuArray{Int64, 1, CUDA.DeviceMemory}, I::Tuple{Int64})
    @ Base ./abstractarray.jl:737
  [2] checkbounds
    @ ./abstractarray.jl:702 [inlined]
  [3] getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:49 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:210 [inlined]
  [5] findall(bools::SubArray{Bool, 1, CuArray{Bool, 1, CUDA.DeviceMemory}, Tuple{CuArray{…}}, false})
    @ CUDA ~/git/CUDA.jl/src/indexing.jl:30

The culprit is this line:

n = @allowscalar indices[end]

We can easily fix it with:

n = isempty(indices) ? 0 : @allowscalar indices[end]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant