# Statistics functions on GPU?

**URL:** https://discourse.julialang.org/t/statistics-functions-on-gpu/42245
**Category:** GPU
**Tags:** statistics
**Created:** [June 29, 2020, 12:42pm UTC](https://discourse.julialang.org/t/statistics-functions-on-gpu/42245 "2020-06-29T12:42:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ogoid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ogoid/32/30218_2.png) [@ogoid](https://discourse.julialang.org/u/ogoid)
#### Post date: [June 29, 2020, 12:42pm UTC](https://discourse.julialang.org/t/statistics-functions-on-gpu/42245/1 "2020-06-29T12:42:48Z")

</div>

Are there available any GPU implementations of the Statistics functions (cor, cov etc.)? Many of the functions on the Statistics module throw the “scalar getindex is disallowed” warning/error. Eg:

```julia
julia> Statistics.cor(CuArrays.rand(100,10))
ERROR: scalar getindex is disallowed
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] assertscalar(::String) at /home/user/.julia/packages/GPUArrays/JqOUg/src/host/indexing.jl:41
 [3] getindex at /home/user/.julia/packages/GPUArrays/JqOUg/src/host/indexing.jl:96 [inlined]
 [4] _getindex at ./abstractarray.jl:1003 [inlined]
 [5] getindex at ./abstractarray.jl:980 [inlined]
 [6] (::Statistics.var"#43#44"{CuArray{Float32,2,Nothing}})(::Int64) at ./none:0
 [7] iterate at ./generator.jl:47 [inlined]
 [8] collect(::Base.Generator{UnitRange{Int64},Statistics.var"#43#44"{CuArray{Float32,2,Nothing}}}) at ./array.jl:665
 [9] corzm(::CuArray{Float32,2,Nothing}, ::Int64) at /opt/julia/share/julia/stdlib/v1.4/Statistics/src/Statistics.jl:627
 [10] corm(::CuArray{Float32,2,Nothing}, ::CuArray{Float32,2,Nothing}, ::Int64) at /opt/julia/share/julia/stdlib/v1.4/Statistics/src/Statistics.jl:639
 [11] cor(::CuArray{Float32,2,Nothing}; dims::Int64) at /opt/julia/share/julia/stdlib/v1.4/Statistics/src/Statistics.jl:679
 [12] cor(::CuArray{Float32,2,Nothing}) at /opt/julia/share/julia/stdlib/v1.4/Statistics/src/Statistics.jl:679
 [13] top-level scope at none:0

```

Perhaps a GPU friendly version of them should do batching computations on matrices/list of vectors?

Did nobody had any need of them yet or am I missing something obvious?

---

<div class="post-metadata">

### Author: ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)
#### Post date: [July 1, 2020, 8:12am UTC](https://discourse.julialang.org/t/statistics-functions-on-gpu/42245/2 "2020-07-01T08:12:43Z")

</div>

There’s some functions implemented, [https://github.com/JuliaGPU/CUDA.jl/blob/master/src/statistics.jl](https://github.com/JuliaGPU/CUDA.jl/blob/master/src/statistics.jl), but not many yet. PRs appreciated 🙂
