Skip to content

[WIP] more general indexing for KnetArray#229

Open
CarloLucibello wants to merge 2 commits intodenizyuret:masterfrom
CarloLucibello:indx
Open

[WIP] more general indexing for KnetArray#229
CarloLucibello wants to merge 2 commits intodenizyuret:masterfrom
CarloLucibello:indx

Conversation

@CarloLucibello
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants