Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/host/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Base.getindex(ei::EachIndex, i::Int) = ei.indices[i]
Base.IndexStyle(::Type{<:EachIndex}) = Base.IndexLinear()

function Base.findfirst(f::Function, A::AnyGPUArray)
isempty(A) && return nothing
indices = EachIndex(A)
dummy_index = first(indices)

Expand Down
1 change: 1 addition & 0 deletions test/testsuite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using Test

using Adapt

test_result(a, b; kwargs...) = a == b
test_result(a::Number, b::Number; kwargs...) = ≈(a, b; kwargs...)
test_result(a::Missing, b::Missing; kwargs...) = true
test_result(a::Number, b::Missing; kwargs...) = false
Expand Down
4 changes: 4 additions & 0 deletions test/testsuite/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ end
let x = rand(Float32, 10, 10)
@test findfirst(>(0.5f0), x) == findfirst(>(0.5f0), AT(x))
end

# emtpy
@test compare(findfirst, AT, Bool[])
@test compare(x->findfirst(>(0.5f0), x), AT, Float32[])
end

@testset "findmax & findmin" begin
Expand Down
Loading