Skip to content

Commit 8830b0f

Browse files
committed
DArray: Fix passing eltype to randn
1 parent e38fcca commit 8830b0f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Diff for: src/array/alloc.jl

+5-11
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,23 @@ function stage(ctx, a::AllocateArray)
3131
end
3232

3333
function Base.rand(p::Blocks, eltype::Type, dims)
34-
s = rand(UInt)
35-
f = function (idx, x...)
36-
rand(MersenneTwister(s+idx), x...)
37-
end
3834
d = ArrayDomain(map(x->1:x, dims))
39-
a = AllocateArray(eltype, f, d, partition(p, d), p)
35+
a = AllocateArray(eltype, (_, x...) -> rand(x...), d, partition(p, d), p)
4036
return _to_darray(a)
4137
end
4238

4339
Base.rand(p::Blocks, t::Type, dims::Integer...) = rand(p, t, dims)
4440
Base.rand(p::Blocks, dims::Integer...) = rand(p, Float64, dims)
4541
Base.rand(p::Blocks, dims::Tuple) = rand(p, Float64, dims)
4642

47-
function Base.randn(p::Blocks, dims)
48-
s = rand(UInt)
49-
f = function (idx, x...)
50-
randn(MersenneTwister(s+idx), x...)
51-
end
43+
function Base.randn(p::Blocks, eltype::Type, dims)
5244
d = ArrayDomain(map(x->1:x, dims))
53-
a = AllocateArray(Float64, f, d, partition(p, d), p)
45+
a = AllocateArray(Float64, (_, x...) -> randn(x...), d, partition(p, d), p)
5446
return _to_darray(a)
5547
end
48+
Base.randn(p::Blocks, t::Type, dims::Integer...) = randn(p, t, dims)
5649
Base.randn(p::Blocks, dims::Integer...) = randn(p, dims)
50+
Base.randn(p::Blocks, dims::Tuple) = randn(p, Float64, dims)
5751

5852
function Base.ones(p::Blocks, eltype::Type, dims)
5953
d = ArrayDomain(map(x->1:x, dims))

0 commit comments

Comments
 (0)