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

Adapt SubArray indices #16

Open
maleadt opened this issue Jun 28, 2019 · 1 comment
Open

Adapt SubArray indices #16

maleadt opened this issue Jun 28, 2019 · 1 comment
Labels

Comments

@maleadt
Copy link
Member

maleadt commented Jun 28, 2019

julia> view(CuArray([1]), CuArray([1]))
1-element view(::CuArray{Int64,1}, [1]) with eltype Int64:
 1

julia> parentindices(ans)
([1],)

julia> typeof(ans)
Tuple{CuArray{Int64,1}}

The indices needs an adapt as well:

Adapt.adapt_structure(to, A::SubArray{<:Any,<:Any,AT}) where {AT} = SubArray(adapt(to, parent(A)), adapt.(Ref(to), parentindices(A)))

Reported by @ali-ramadhan

@maleadt maleadt added the bug label Jun 28, 2019
@maleadt
Copy link
Member Author

maleadt commented Jul 12, 2019

This is actually a little more complex, because the view constructor does bounds checking:

julia> view(CuArray([1]), CuArray([1]))
ERROR: scalar getindex is disallowed

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

1 participant