Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with named CuArrays #98

Open
mcabbott opened this issue Feb 21, 2020 · 2 comments
Open

Problems with named CuArrays #98

mcabbott opened this issue Feb 21, 2020 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mcabbott
Copy link
Collaborator

First, a broadcasting problem between named & un-named:

julia> using CuArrays, NamedDims

julia> cu(rand(2)) .+ NamedDimsArray(cu(rand(2)), :x)
ERROR: MethodError: Base.Broadcast.BroadcastStyle(::NamedDims.NamedDimsStyle{Base.Broadcast.ArrayStyle{CuArray}}, ::Base.Broadcast.ArrayStyle{CuArray}) is ambiguous. Candidates:
  Base.Broadcast.BroadcastStyle(a::A, b::B) where {M, N, A<:Base.Broadcast.AbstractArrayStyle{M}, B<:Base.Broadcast.AbstractArrayStyle{N}} in Base.Broadcast at broadcast.jl:141
  Base.Broadcast.BroadcastStyle(::NamedDims.NamedDimsStyle{A}, b::B) where {A, B} in NamedDims at /Users/me/.julia/packages/NamedDims/Qg6if/src/broadcasting.jl:28
  Base.Broadcast.BroadcastStyle(::Base.Broadcast.BroadcastStyle, ::Base.Broadcast.BroadcastStyle) in Base.Broadcast at broadcast.jl:130
Possible fix, define
  Base.Broadcast.BroadcastStyle(::A<:NamedDims.NamedDimsStyle{A}, ::B<:Base.Broadcast.AbstractArrayStyle)

Second, less importantly, printing does not behave very well:

julia> CuArrays.allowscalar(true)

julia> NamedDimsArray(cu(rand(3)), :z)
3-element NamedDimsArray{(:z,),Float32,1,CuArray{Float32,1,Nothing}}:
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/1wgPO/src/indexing.jl:16
 0.33744907
 0.35837933
 0.47025323

julia> CuArrays.allowscalar(false)

julia> NamedDimsArray(cu(rand(3)), :z)
3-element NamedDimsArray{(:z,),Float32,1,CuArray{Float32,1,Nothing}}:
Error showing value of type NamedDimsArray{(:z,),Float32,1,CuArray{Float32,1,Nothing}}:
ERROR: scalar getindex is disallowed
@nickrobinson251
Copy link
Contributor

Can you try setting ArrayStyle{CuArray} (or even just ArrayStyle?) as per TrackedStyle

Base.BroadcastStyle(::NamedDimsStyle{A}, b::Tracker.TrackedStyle) where {A} = NamedDimsStyle(A(), b)
Base.BroadcastStyle(a::Tracker.TrackedStyle, ::NamedDimsStyle{B}) where {B} = NamedDimsStyle(a, B())
?

@mcabbott
Copy link
Collaborator Author

Will take a look... but right now my desktop is self-isolating in its office.

@nickrobinson251 nickrobinson251 added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants