JuliaDiff / JuliaDiff/ChainRulesCore.jl
Documentation on default arguments
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 267
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
From slack. Point out that an rrule is basically a new dispatch. So if you have any default arguments, you will need to redefine them. For example
using Zygote, ChainRulesCore
function f(x, y=0.0; a=2)
return a * x + y
end
function ChainRulesCore.rrule(::typeof(f), x, y=0.0; a=2)
r = f(x, y; a)
function f_pb(Δr)
# implementation, which can use the `y`, and `a`
end
return r, f_pb
end
Can point out that the kwargs on the dispatch is useful to slurp up keyword arguments to pass to the f(...) in the primal but you would need to separate out any values with defaults, as you would implementing any other dispatch.
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
Start by locating the documentation covering rrule dispatches and default arguments. Explain that an rrule is a new dispatch, so default positional and keyword arguments must be redefined, while kwargs can collect keyword arguments for the primal call. Done means the documentation includes the Julia example and clearly describes separating defaulted values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100