JuliaDiff / JuliaDiff/DiffResults.jl
confused about interface
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 37
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the package does two things:
-
support an interface for retrieving values with derivatives; as the former are calculated anyway
-
allow preallocated buffers for results.
In my own benchmarks, I find the allocation cost dwarfed by the actual calculations. It can also lead to bugs, eg if the MutableDiffResult is accidentally reused. With the introduction of StaticArrays (https://github.com/JuliaDiff/DiffBase.jl/commit/1f15e9c3347be65e0e8fc4309a13507e4d24cdac) the interface became even more complicated, because they don't share structure, yet use an interface which pretends to modify its arguments.
Also, the relevant subtype of DiffResult is determined by the input type. It is conceivable that a function could take a StaticVector yet return a Vector.
Perhaps it would be better to use an interface which just takes an abstract type which tells a single evaluator function (eg in ForwardDiff.jl) what the user wants calculated, and returns that, eg
resulttype = DiffResult(; value = true, jacobian = true) # type information saves these
value_and_deriv = ForwardDiff.evaluate(resulttype, f, x) # result based in 1st argument
I came across this when writing a simple wrapper that just takes a function, and returns a function which returns value & derivative (short source here), and found it very complicated to support everything.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reviewing the current DiffResults API and the examples in the issue, including DiffResult, ForwardDiff.evaluate, StaticArrays, and the DiffWrappers.jl wrapper; done requires a decided interface direction and an agreed scope for changing the package.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100