-
Notifications
You must be signed in to change notification settings - Fork 203
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
Logical indexing per-dim #106
Comments
I made a suggestion issue in base for |
I tried an approach suggested in the issue above, but it's suboptimal in performance using LazyArrays, FillArrays
function filterByRow(x::CuArray, row::Int; thresh=0.0)
nrows, ncols = size(x)
col_idxs = 1:ncols #idx of every col
row_copy = Fill(true, 1, nrows) #trues of length nrows
rep_idx_2D = LazyArray(@~ col_idxs .* row_copy)' #lazy copy of col_idxs to every row
keep_cols = view(x, row, :) .> thresh #cols to keep
bool_idx = view(keep_cols,rep_idx_2D) #logical index on elements to keep
return reshape(x[bool_idx], nrows, :) #keep and reshape
end |
Maybe, I am misunderstanding something here, but that already works for regular arrays, right? I was actually surprised this kind of mixed logical indexing doesn't work with CuArrays, so I ended up having to move my array to the cpu for this. How hard would it be to add support for this? |
Is your feature request related to a problem? Please describe.
Related to JuliaGPU/CuArrays.jl#290, it would be great to be able to logically index per-dim, i.e. without having to allocate the full index
Describe the solution you'd like
Describe alternatives you've considered
This approach works but allocates the index
If there was such a thing as a
repeatview
, this could be efficient. i.e. aview
version ofrepeat
The text was updated successfully, but these errors were encountered: