-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use with multiple wrappers #21
Comments
This method definition gets around the problem, not sure if it's a hack though function CuArray(x::Base.ReshapedArray{<:Any, <:Any, <:Adjoint})
xp = CuArray(x.parent)
ra = Base.ReshapedArray(xp,x.dims, x.mi)
CuArray(ra)
end |
maleadt
changed the title
cu(reshaped{Adjoint}) hits scalar getindex
Adapt.jl approach breaks down with multiple wrappers
Nov 22, 2019
Another instance from slack, where a Reshape of a Transpose doesn't broadcast properly. Workaround:
IIUC we might need something like JuliaLang/julia#31563 to deal with this in a more profound way? |
Could something like this make sense? Can be extended with other known wrappers const Wrapper = Union{Base.ReshapedArray, LinearAlgebra.Transpose, LinearAlgebra.Adjoint}
function CuArray(x::Base.ReshapedArray{<:Any, <:Any, <:Wrapper})
xp = CuArray(x.parent)
ra = Base.ReshapedArray(xp,x.dims, x.mi)
CuArray(ra)
end
function CuArray(x::LinearAlgebra.Transpose{<:Any, <:Wrapper})
xp = CuArray(x.parent)
ra = Base.Transpose(xp)
CuArray(ra)
end
function CuArray(x::LinearAlgebra.Adjoint{<:Any, <:Wrapper})
xp = CuArray(x.parent)
ra = Base.Adjoint(xp)
CuArray(ra)
end |
maleadt
changed the title
Adapt.jl approach breaks down with multiple wrappers
Use with multiple wrappers
Jan 30, 2020
3 tasks
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Details on Julia:
I hit this error all the time while backpropagating using Tracker, not sure which adjoint definition causes this error though.
Both the adjoint and the reshape are required for the error to appear, either one of them by themselves works alright.
The text was updated successfully, but these errors were encountered: