JuMP documentation suggest to use splatting for user-defined functions with vector inputs. For medium size data this works pretty well but for large scale vectors I encounter a memory issue:
julia> f(x...) = sum(x[i] for i in 1:length(x))
julia> y = randn(1_000_000);
julia> f(y...)
ERROR: ReadOnlyMemoryError()
Stacktrace:
[1] f(::Float64, ::Vararg{Float64,N} where N) at ./REPL[18]:1
[2] top-level scope at REPL[20]:1
Hi @edljk, unfortunately I don’t see an easy workaround for this. JuMP’s user-defined functions were designed for functions with a moderate number of arguments. We’d need substantial changes to JuMP’s AD code to support vector arguments that are too large for splatting.