Problem with permuting dimensions of multi dimensional arrays


#1

Hello,

I have a problem when I want to reshape and permute dimensions of an array of 2^16 elements that doesn’t appear with an array of 2^n elements with n < 16.

Does someone have an idea of the source of the problem?


#2

Could you please post the actual code (and quote it with PSA: how to quote code with backticks) instead of a screenshot? Currently your error can’t be searched and your code can’t be copy-pasted.


#3

Here it is :

function f(n)
    x = collect(1:(2^n));
    y = reshape(x, ntuple(w -> 2, n));
    z = permutedims(y, n:-1:1);
end

which error for any n > 15. I try it on my computer and my friend’s computer, both with Julia 0.6.


#4

I can confirm that this does not work on Julia 0.6.1. I tried it on 0.5.2 and it kept on working all of the way up to f(21), but I didn’t try any higher because it was taking up too much time.


#5

Please post the actual input and error message.


#6

A likely explanation is that 15 is the default value of MAX_TUPLETYPE_LEN in InferenceParams (inference.jl in Base). I don’t know which wizard to ask whether one can compile a method in a customized inference context.


#7

f(20) works on 0.7.0 …


#8

Here is the whole code with the error message.

n = 16
x = collect(1:(2^n));
y = reshape(x, ntuple(w -> 2, n));
z = permutedims(y, n:-1:1);

ERROR: MethodError: no method matching checkdims_perm(::Array{Int64,2}, ::Array{Int64,16}, ::StepRange{Int64,Int64})
Closest candidates are:
  checkdims_perm(::AbstractArray{TP,N}, ::AbstractArray{TB,N}, ::Any) where {TP, TB, N} at multidimensional.jl:1247
Stacktrace:
 [1] permutedims! at ./permuteddimsarray.jl:129 [inlined]
 [2] permutedims(::Array{Int64,16}, ::StepRange{Int64,Int64}) at ./multidimensional.jl:1243