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

[WIP] more general indexing for KnetArray #229

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarloLucibello
Copy link
Collaborator

Add general getindex and setindex! fallbacks to deal with cases like these, currently giving errors:

julia> a=KnetArray(rand(3,3,2));

julia> a[1:2,:,1]
ERROR: MethodError: no method matching getindex(::Knet.KnetArray{Float64,3}, ::UnitRange{Int64}, ::Colon, ::Int64)
Stacktrace:
 [1] macro expansion at ./REPL.jl:97 [inlined]
 [2] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

julia> a[1:2,1:2,1]
ERROR: MethodError: no method matching getindex(::Knet.KnetArray{Float64,3}, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Int64)
Stacktrace:
 [1] macro expansion at ./REPL.jl:97 [inlined]
 [2] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

It uses some machinery from Base to fallback to indexing with a vector of linear indexes.
Most credits go to @carlobaldassi

Still, have to test properly and to drop scalar dimensions in reshape.

@denizyuret
Copy link
Owner

Let's performance check these implementations before releasing them. At least let's make sure that they are faster than a copy-to-cpu, index, copy-to-gpu round-trip solution.

@CarloLucibello
Copy link
Collaborator Author

Let's performance check these implementations before releasing them. At least let's make sure that they are faster than a copy-to-cpu, index, copy-to-gpu round-trip solution.

will do

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

Successfully merging this pull request may close these issues.

None yet

2 participants