Skip to content

Commit c9ed8d9

Browse files
committed
Remove nonstandard rand methods.
1 parent 46b3105 commit c9ed8d9

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/random.jl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ function global_rng(A::GPUArray)
6666
end
6767
end
6868

69-
function Random.rand!(A::GPUArray{T}) where T <: Number
70-
rng = global_rng(A)
69+
function Random.rand!(rng::RNG, A::GPUArray{T}) where T <: Number
7170
gpu_call(A, (rng.state, A,)) do state, randstates, a
7271
idx = linear_index(state)
7372
idx > length(a) && return
@@ -77,13 +76,4 @@ function Random.rand!(A::GPUArray{T}) where T <: Number
7776
A
7877
end
7978

80-
gpurand(::Type{X}, dims...) where {X<:GPUArray} = randn!(X(dims...))
81-
82-
# FIXME: the following definitions are not part of the Random stdlib API
83-
Random.rand(X::Type{<: GPUArray}, i::Integer...) = rand!(X{Float32}(i...))
84-
Random.rand(X::Type{<: GPUArray}, size::NTuple{N, Int}) where N = rand!(X{Float32}(size...))
85-
Random.rand(X::Type{<: GPUArray{T}}, i::Integer...) where {T} = rand!(X(i...))
86-
Random.rand(X::Type{<: GPUArray{T}}, size::NTuple{N, Int}) where {T,N} = rand!(X(size...))
87-
Random.rand(X::Type{<: GPUArray{T, N}}, size::NTuple{N, Integer}) where {T,N} = rand!(X(size...))
88-
Random.rand(X::Type{<: GPUArray{T, N}}, size::NTuple{N, Int}) where {T,N} = rand!(X(size...))
89-
Random.rand(X::Type{<: GPUArray}, ::Type{T}, size::Integer...) where {T} = rand!(similar(X, T, size))
79+
Random.rand!(A::GPUArray) = rand!(global_rng(A), A)

src/testsuite/random.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
function test_random(AT)
22
@testset "Random" begin
33
@testset "rand" begin # uniform
4-
for T in (Float32, Float64, Int64, Int32)
5-
@test length(rand(AT{T,1}, (4,))) == 4
6-
@test length(rand(AT{T}, (4,))) == 4
7-
@test length(rand(AT{T}, 4)) == 4
8-
@test eltype(rand(AT, 4)) == Float32
9-
@test length(rand(AT, T, 4)) == 4
10-
@test length(rand(AT{T,2}, (4,5))) == 20
11-
@test length(rand(AT, T, 4, 5)) == 20
12-
A = rand(AT{T,2}, (2,2))
4+
for T in (Float32, Float64, Int64, Int32), d in (2, (2,2))
5+
A = AT{T}(d)
136
B = copy(A)
14-
@test all(A .== B)
7+
rand!(A)
158
rand!(B)
169
@test !any(A .== B)
1710
end

0 commit comments

Comments
 (0)