Skip to content

Metal.rand with Int8 and Int16 are only generating positive numbers #526

@christiangnrd

Description

@christiangnrd

On main branch. Noticed while working on JuliaGPU/Metal.jl#321. Will still be relevant once JuliaGPU/Metal.jl#321 is merged as the MPSMatrixRandom generation is not always used. Unsigned integers and 32/64 bit variants seem unaffected.

Histograms:
Int8metalrng

Int16metalrng

Code:

using Metal, Plots, Random, Statistics

N=100000;

T = Int16;
a = rand(T, N);

ma = Metal.rand(T,N)

meana = mean(a)
meanma = mean(ma)

hist = plot()
histogram!(a;label="Array{$T}: $(mean(a))",α=0.2)
histogram!(hist, collect(ma);label="MtlArray{$T}: $(meanma)",α=0.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions