Giter Site home page Giter Site logo

Comments (3)

denizyuret avatar denizyuret commented on May 17, 2024

You can implement this as x[1:3]. Do you need non-contiguous indices?

from knet.jl.

denizyuret avatar denizyuret commented on May 17, 2024

Currently only Integer, Range, or Colon indices are supported for KnetArray. To get the rest to work, we need to complete the missing getindex methods.

In Julia, a[[1,3,5]] calls:

getindex(A::AbstractArray, I...) at abstractarray.jl:751
_getindex(l::Base.LinearIndexing, A::AbstractArray, i::Union{AbstractArray,Colon,Real}) at multidimensional.jl:275
_unsafe_getindex(::Base.LinearIndexing, A::AbstractArray, I::Union{AbstractArray,Colon,Real}...) at multidimensional.jl:291
_unsafe_getindex!(dest::AbstractArray, src::AbstractArray, I::Union{AbstractArray,Colon,Real}...) at multidimensional.jl:340

and a[[true,false,true]] calls:

_unsafe_getindex(::Base.LinearFast, src::AbstractArray, I::AbstractArray{Bool,N<:Any}) at multidimensional.jl:321

These need to be ported to KnetArrays. We get them for free if we inherit from AbstractArray, but that has other problems such as inefficient operations getting called inadvertently on KnetArrays. However as a temporary workaround you can try modifying the type declaration of KnetArray in karray.jl to inherit from AbstractArray:

type KnetArray{T,N} <: AbstractArray

from knet.jl.

denizyuret avatar denizyuret commented on May 17, 2024

Implemented the following indexing options:

  • 1-D: Int, Colon, UnitRange, StepRange, Array{Int}, BitArray, CartesianIndex, Array{CartesianIndex} (1-D includes linear indexing of multidimensional arrays)
  • 2-D: (Colon,Union{Int,Colon,UnitRange,StepRange,Array{Int}}), (Union{Int,UnitRange,Colon}...) (in any order)
  • N-D: (Int...)
    The 1-D support is complete, 2-D and N-D are still missing a lot.

from knet.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.