Skip to content

Commit

Permalink
Merge pull request #2369 from Red-Portal/master
Browse files Browse the repository at this point in the history
Add back missing `rng_from_array(::CuArray)` method
  • Loading branch information
ToucheSir authored Jan 24, 2024
2 parents 590adf2 + 80cd5fa commit c2094d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions ext/FluxCUDAExt/FluxCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end
ChainRulesCore.@non_differentiable check_use_cuda()

include("functor.jl")
include("utils.jl")

function __init__()
Flux.CUDA_LOADED[] = true
Expand Down
2 changes: 1 addition & 1 deletion ext/FluxCUDAExt/utils.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rng_from_array(::CuArray) = CUDA.default_rng()
Flux.rng_from_array(::CuArray) = CUDA.default_rng()
4 changes: 4 additions & 0 deletions test/ext_cuda/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ end
@testset "ctc" begin
include("ctc.jl")
end
@testset "utils" begin
include("utils.jl")
end

6 changes: 6 additions & 0 deletions test/ext_cuda/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
@test y isa Wrapped{<:CuArray}
end
end

@testset "rng_from_array" begin
x = cu(randn(2,2))
rng = Flux.rng_from_array(x)
@test rng == CUDA.default_rng()
end

0 comments on commit c2094d8

Please sign in to comment.