Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Statistics functions (var,std) slow #411

Closed
denizyuret opened this issue Sep 7, 2019 · 4 comments · Fixed by #612
Closed

Statistics functions (var,std) slow #411

denizyuret opened this issue Sep 7, 2019 · 4 comments · Fixed by #612

Comments

@denizyuret
Copy link

var/std seem to fall back on indexing the CuArray, instead of a vectorized implementation:

julia> var(c,dims=1)
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/J4c3Q/src/indexing.jl:16
1×4 CuArray{Float32,2}:
 0.0646661  0.167767  0.0156315  0.14948

This makes it slower than cpu:

julia> c1 = rand(1000,1000);
julia> c2 = CuArray(c1);
julia> @time std(c1,dims=1);
  0.001371 seconds (12 allocations: 16.250 KiB)
julia> @time std(c2,dims=1);
  7.945594 seconds (3.01 M allocations: 138.023 MiB, 0.39% gc time)
julia> @time CuArray(std(Array(c2),dims=1))
  0.003153 seconds (23 allocations: 7.661 MiB)
@kshyatt
Copy link
Contributor

kshyatt commented Oct 8, 2019

@rajuthegr8
Copy link

This in reference to FluxML/Flux.jl#981 var and std is defined in Statistics.jl. If I want to add functions specific to CuArray where should I add them in this package. @MikeInnes

@maleadt
Copy link
Member

maleadt commented Jan 3, 2020

A new statistics.jl top-level file would be a good place.

@CarloLucibello
Copy link

@an-awesome-guy any update on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants