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

Knet can't convert arrays with more than 15 dimensions #176

Closed
ilkerkesen opened this issue Oct 20, 2017 · 3 comments
Closed

Knet can't convert arrays with more than 15 dimensions #176

ilkerkesen opened this issue Oct 20, 2017 · 3 comments
Assignees
Labels

Comments

@ilkerkesen
Copy link
Collaborator

ilkerkesen commented Oct 20, 2017

Knet with 3150e5d, AutoGrad with 6c93428. Knet cannot convert arrays which have more than 15 dimensions. Example code snippet,

julia> a2 = rand(Float32, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1); k2 = KnetArray(a2);
ERROR: MethodError: Cannot `convert` an object of type NTuple{14,Int64} to an object of type Tuple{}
This may have arisen from a call to the constructor Tuple{}(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] convert(::Type{Tuple{Int64}}, ::NTuple{15,Int64}) at ./essentials.jl:135 (repeats 2 times)
 [2] Type at /KUFS/scratch/ikesen16/.julia/newnode/v0.6/Knet/src/karray.jl:83 [inlined]
 [3] Type at /KUFS/scratch/ikesen16/.julia/newnode/v0.6/Knet/src/karray.jl:104 [inlined]
 [4] Type at /KUFS/scratch/ikesen16/.julia/newnode/v0.6/Knet/src/karray.jl:114 [inlined]
 [5] convert(::Type{Knet.KnetArray{Float32,16}}, ::Array{Float32,16}) at /KUFS/scratch/ikesen16/.julia/newnode/v0.6/Knet/src/karray.jl:141
 [6] Knet.KnetArray(::Array{Float32,16}) at ./sysimg.jl:24

However, we can perform the following,

julia> a3 = rand(Float32, map(x->2, 1:15)...); k3 = KnetArray(a3);

julia> k3 = reshape(k3, 1, size(k3)...);

julia> k3 = reshape(k3, 1, size(k3)..., 1);

julia> ndims(k3)
18

It's a very edge case, though.

@denizyuret
Copy link
Owner

This seems to effect only julia6, works with julia4 and julia5. I also cannot replicate it using the intermediate steps (karray.jl:114, 104, 83). Seems like a Julia bug, keeping it open for now. Not critical for next release.

@denizyuret denizyuret self-assigned this Oct 20, 2017
@ChrisRackauckas
Copy link
Contributor

This is because there is currently a hard limit on inference for recursion. Splatting only infers for tuples up to size 16.

Xref: JuliaLang/julia#22370 JuliaLang/julia#22545

@denizyuret
Copy link
Owner

This seems to be resolved in latest Julia, closing.

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

No branches or pull requests

3 participants