Problem with permuting dimensions of multi dimensional arrays

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?

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.

1 Like

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.

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.

Please post the actual input and error message.

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.

f(20) works on 0.7.0 …

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
``````