Skip to content

Commit

Permalink
Slightly faster rand! on CPU arrays with MPS rng
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Apr 10, 2024
1 parent 2bd3eb3 commit 84911a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mps/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ function Random.rand!(rng::RNG, A::AbstractArray{T,N}) where {T <: Union{Uniform
isempty(A) && return A
B = MtlArray{T,N,Shared}(undef, size(A))
rand!(rng, B)
copyto!(A, B)
copyto!(A, unsafe_wrap(Array{T},B))
return A
end
function Random.randn!(rng::RNG, A::AbstractArray{T,N}) where {T <: Float32, N}
isempty(A) && return A
B = MtlArray{T,N,Shared}(undef, size(A))
randn!(rng, B)
copyto!(A, B)
copyto!(A, unsafe_wrap(Array{T},B))
return A
end

Expand Down

0 comments on commit 84911a9

Please sign in to comment.