I’m getting a weird error:
ERROR: ArgumentError: invalid index: VectorizationBase.MM{4, 1, Int64}<1, 2, 3, 4> of type VectorizationBase.MM{4, 1, Int64}
This is a way to reproduce it:
using BenchmarkTools
using ComponentArrays
using UnPack
using LoopVectorization
const szK=5
θ = ComponentArray(
α0 = rand(2, 2, 5),
α = rand(3),
αh = rand(2, 2),
αga = rand(2, 46)
)
data = ComponentArray(
ww = rand(2, 9, 2, 2, 5, 44),
P_1 = rand(5, 44),
ē = rand(5, 44)
)
@views function Uk(g, a, e, k, t; data=data, θ=θ)
# params
@unpack α0, α = θ
# data
@unpack ww, P_1, ē = data
w = ww[g, a, e, 1, k, t]
α0[g, e, k] + α[1] * w + α[2] * (e - ē[k, t])^2 + α[3] * P_1[k, t]
end
@views function α̃0(g, a, e, t; data=data, θ=θ)
@unpack αh, αga = θ
αh[1, g] + αh[2, g] * t + αga[g, a]
end
function U0(g, a, e, t; data=data, θ=θ)
α̃0(g, a, e, t; data=data, θ=θ)
end
function Probk(g, a, e, k, t; data=data, θ=θ)
u00 = U0(g, a, e, t; data=data, θ=θ)
uk = ( k == 6 ? u00 : Uk(g, a, e, k, t; data=data, θ=θ) )
hlp(g, a, e, kk, t) = Uk(g, a, e, kk, t; data=data, θ=θ)
s = zero(eltype(θ))
@turbo for kk=1:szK
s += exp(hlp(g, a, e, kk, t) - uk)
end
inv(s + exp(u00 - uk))
end
Call Probk(1, 5, 2, 2, 1; data=data, θ=θ)
to see the error.