I have a project I’m wanting to use ForwardDiff.jl on. I have a few question:
Chunk Size
- If I’m reading correctly, ForwardDiff.jl evaluates partial derivatives on chunks of the input vector. What if computations depend on the whole input vector? A trivial example:
function f(x)
output = 0.0
if sum(x) > 5.0
for i = 1:length(x)
output += sin(x[i])
end
else
for i = 1:length(x)
output += cos(x[i])
end
end
end
- According to the docs, “each differentiation of a chunk requires […] additional memory proportional to the square of the chunk’s size.” Does this mean if it’s chunked into 10 64-bit elements, the memory allocated is
(10*10)^2*64
bits or(10*64)^2
bits?
External C-Calls: I understand why these aren’t permitted for calculations, but are they permitted for non-calculation purposes (e.g. producing index ordering for a permuted vector)?
Types: What exactly has to be typed to accept Real
? Just everything the input vector “touches” or absolutely everything within the function?
Skipping Operations: I have an iterative solver within my objective function. I see no reason why I’d need to track all differentiations within this. Is there a way to skip this section of the objective function?