ForwardDiff.jl
ForwardDiff.jl copied to clipboard
Bad compilation time with static arrays and intervals
The following should be a simple calculation, but uses 2GB (!) in the compilation process...:
julia> using ForwardDiff, StaticArrays, IntervalArithmetic
julia> f(x) = 2 .* x .* x
f (generic function with 1 method)
julia> X = @SVector [0..1 for i in 1:6];
julia> @time ForwardDiff.jacobian(f, X)
11.818110 seconds (67.27 M allocations: 2.401 GiB, 13.76% gc time, 100.00% compilation time)
6×6 SMatrix{6, 6, Interval{Float64}, 36} with indices SOneTo(6)×SOneTo(6):
[0, 4] [0, 0] [0, 0] [0, 0] [0, 0] [0, 0]
[0, 0] [0, 4] [0, 0] [0, 0] [0, 0] [0, 0]
[0, 0] [0, 0] [0, 4] [0, 0] [0, 0] [0, 0]
[0, 0] [0, 0] [0, 0] [0, 4] [0, 0] [0, 0]
[0, 0] [0, 0] [0, 0] [0, 0] [0, 4] [0, 0]
[0, 0] [0, 0] [0, 0] [0, 0] [0, 0] [0, 4]
but uses 2GB (!) in the compilation process...:
What would a reasonable number for Julia to use to compile this according to you?
You can try to lower the chunk size, which usually reduces compile time.
@KristofferC: That's fair; I guess a naive version should require a lot less space and time, but there is a lot of compilation complication due e.g. to tagging that is not actually required (I believe) for this calculation.