Conversation
|
Is this expected? The speedup for This PR sounds really useful for tools like Optim on low-dimensional functions, both because of the potential differentiation speedup, and because returning the gradient as an |
Yes, this is expected. The main benefit of Note this extraction process is not unrolled like it is for |
|
Just added some special cases for Hessians as well: julia> x = rand(3, 3);
julia> sx = SArray{Tuple{3, 3}}(x);
julia> out = similar(x, 9, 9);
julia> cfg = ForwardDiff.HessianConfig(prod, x);
# naive old method
julia> @btime ForwardDiff.hessian(prod, $x);
37.159 μs (17 allocations: 17.11 KiB)
# almost non-allocating old method
julia> @btime ForwardDiff.hessian!($out, prod, $x, $cfg);
2.115 μs (2 allocations: 832 bytes)
# stack-allocated new method
julia> @btime ForwardDiff.hessian(prod, $sx);
1.220 μs (0 allocations: 0 bytes) |
|
Tests pass locally, and everything here is ready. However, I developed this against StaticArrays master, so this PR is now waiting on JuliaArrays/StaticArrays.jl#142. |
|
Argh, 32 bit Windows...AppVeyor was passing before this PR, and it seems like this PR doesn't touch the code that would cause that test to fail, so I'm not sure what's going on here. |
| @@ -1,6 +1,5 @@ | |||
| environment: | |||
| matrix: | |||
| - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" | |||
There was a problem hiding this comment.
Cutting the Gordian knot.
Adds StaticArrays as dependency, and uses it to support a low-dimensional, stack-allocated differentiation API.
Currently, I've only added support for gradients and Jacobians. EDIT: Added special cases for Hessians as well, see below.
I still need to add back in the tests I originally used in #213.Done.