Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rrule for map and expand the testing framework #56

Merged
merged 1 commit into from
Jun 18, 2019
Merged

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jun 16, 2019

This implements rrule(map, f, xs...) and expands rrule_test to allow non-differentiable arguments. For such cases, the user need only pass nothing as the argument's assumed sensitivity.

The rrule for map is admittedly a little bizarre looking. It was ported from Nabla and attempts to use the same logic but stuffed awkwardly into the ChainRules framework. rrule for map requires that the mapped function have an rrule defined for it.

src/rules/mapreduce.jl Outdated Show resolved Hide resolved
src/rules/mapreduce.jl Outdated Show resolved Hide resolved
@@ -50,23 +50,58 @@ function rrule_test(f, ȳ, (x, x̄)::Tuple{Any, Any}; rtol=1e-9, atol=1e-9, fdm
test_accumulation(Zero(), dx, ȳ, x̄_ad)
end

function _make_fdm_call(fdm, f, ȳ, xs, ignores)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually what this function does should be moved to FDM, but it took less time to write this than it would to figure out how to incorporate it into the FDM framework directly.

src/rules/mapreduce.jl Outdated Show resolved Hide resolved
This implements `rrule(map, f, xs...)` and expands `rrule_test` to allow
non-differentiable arguments. For such cases, the user need only pass
`nothing` as the argument's assumed sensitivity.
@ararslan
Copy link
Member Author

In the interest of time and getting more stuff moved over from Nabla, I'm going to go ahead with this since it passes tests and is (now) pretty straightforward, plus nothing yet depends on ChainRules. Please feel free to open an issue about anything added here.

@ararslan ararslan merged commit 74ef7a4 into master Jun 18, 2019
@ararslan ararslan deleted the aa/map branch June 18, 2019 20:03
@CarloLucibello CarloLucibello mentioned this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants