Skip to content

Broadcasting on nested ReshapedArrays and Adjoints falls back to DefaultArrayStyle #244

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

Closed
tanhevg opened this issue Feb 19, 2020 · 1 comment
Labels

Comments

@tanhevg
Copy link

tanhevg commented Feb 19, 2020

MWE:

using CuArrays

x = cu(rand(5))
xx = reshape(x', 5)
typeof(xx) # ok: Base.ReshapedArray{Float32,1,LinearAlgebra.Adjoint{Float32,CuArray{Float32,1,Nothing}},Tuple{}}
typeof(-xx) # WTF: Array{Float32,1}

This is because the code that defines broadcast styles in GPUArrays.broadcast.jl only defines them for adapted types for the nested level of 1.

I guess one possible workaround would be

broadcastable(x::Base.ReshapedArray) = broadcastable(x.parent)
# etc etc for LinearAlgebra.Adjoint and others

I am not sure, however, if this would break other things, and whether it should sit within JuliaGPU or in Base

@maleadt
Copy link
Member

maleadt commented Feb 20, 2020

We don't support nested wrappers, JuliaGPU/Adapt.jl#21, doing so would require an ever increasing number of method definitions while we really need something structural (e.g., JuliaLang/julia#31563).

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

No branches or pull requests

2 participants