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

Nested SubArray Scalar Indexing #490

Closed
btmit opened this issue Oct 13, 2020 · 4 comments
Closed

Nested SubArray Scalar Indexing #490

btmit opened this issue Oct 13, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@btmit
Copy link

btmit commented Oct 13, 2020

v2.0.0 fixed a number of issues with subarrays, but nested calls still seem to have issues. I'm wondering if there is a way to "flatten" the different calls to view/reshape. See the small example below. In my application the different calls to view are on opposite sides of a function boundary so they can't be combined.

using CUDA
CUDA.allowscalar(false)

a = CUDA.zeros(4,3,2)
b = view(a, :,:,1)
c = CartesianIndex.([(1,3), (2,1)])
c = view(b, c)

ERROR: scalar getindex is disallowed

@btmit btmit added the bug Something isn't working label Oct 13, 2020
@maleadt
Copy link
Member

maleadt commented Oct 14, 2020

Nested wrappers is JuliaGPU/Adapt.jl#21, so not supported.

We do support limited view nesting, but we rely on Base for that with a GPU version of DenseArray. And this view with Cartesian indices isn't a dense array. GPUArrays' copy methods are more generic, but those can only use Array because of #491.

@maleadt maleadt added enhancement New feature or request and removed bug Something isn't working labels Oct 14, 2020
@btmit
Copy link
Author

btmit commented Oct 14, 2020

Is there a workaround I could use to flatten this sort of thing? The following works, so it seems like there might be a way to reform the view from the parent on the second call?

using CUDA
CUDA.allowscalar(false)

a = CUDA.zeros(4,3,2)
c = CartesianIndex.([(1,3,1), (2,1,1)])
c = view(a, c)

@maleadt
Copy link
Member

maleadt commented Oct 14, 2020

Not that I know, we're just reusing Base's view machinery here, and it doesn't look like it understands what you're doing enough to flatten the indices automatically.

@maleadt
Copy link
Member

maleadt commented Oct 29, 2020

Works again after #498, now that we eagerly flatten some wrappers. But ultimately this remains Base not supporting these kinds of nested wrappers, and it just happens to work because of an optimization here, not because we fundamentally support this pattern.

@maleadt maleadt closed this as completed Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants