Skip to content

Commit

Permalink
build based on 2c2d2bd
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Dec 18, 2023
1 parent 8663d8a commit 435938a
Show file tree
Hide file tree
Showing 44 changed files with 18,096 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stable
2 changes: 1 addition & 1 deletion v1
1 change: 1 addition & 0 deletions v1.19
2 changes: 2 additions & 0 deletions v1.19.0/FAQ.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions v1.19.0/ad_author/call_back_into_ad.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Support calling back into ADs · ChainRules</title><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/indigo.css" rel="stylesheet" type="text/css"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../index.html"><img src="../assets/logo.svg" alt="ChainRules logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../index.html">ChainRules</a></span></div><form class="docs-search" action="../search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Introduction</a></li><li><span class="tocitem">How to use ChainRules as a rule author</span><ul><li><a class="tocitem" href="../rule_author/intro.html">Introduction</a></li><li><a class="tocitem" href="../rule_author/example.html">Pedagogical example</a></li><li><a class="tocitem" href="../rule_author/tangents.html">Tangent types</a></li><li><a class="tocitem" href="../rule_author/which_functions_need_rules.html">Which functions need rules?</a></li><li><a class="tocitem" href="../rule_author/rule_definition_tools.html">Rule definition tools</a></li><li><a class="tocitem" href="../rule_author/writing_good_rules.html">Writing good rules</a></li><li><a class="tocitem" href="../rule_author/testing.html">Testing your rules</a></li><li><input class="collapse-toggle" id="menuitem-2-8" type="checkbox"/><label class="tocitem" for="menuitem-2-8"><span class="docs-label">Superpowers</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../rule_author/superpowers/projectto.html"><code>ProjectTo</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/opt_out.html"><code>@opt_out</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/ruleconfig.html"><code>RuleConfig</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/gradient_accumulation.html">Gradient accumulation</a></li></ul></li><li><a class="tocitem" href="../rule_author/converting_zygoterules.html">Converting ZygoteRules.@adjoint to rrules</a></li><li><a class="tocitem" href="../rule_author/tips_for_packages.html">Tips for making your package work with AD</a></li><li><a class="tocitem" href="../rule_author/debug_mode.html">Debug mode</a></li></ul></li><li><span class="tocitem">How to support ChainRules rules as an AD package author</span><ul><li><a class="tocitem" href="use_in_ad_system.html">Usage in AD</a></li><li class="is-active"><a class="tocitem" href="call_back_into_ad.html">Support calling back into ADs</a></li><li><a class="tocitem" href="opt_out.html">Support opting out of rules</a></li></ul></li><li><span class="tocitem">The maths</span><ul><li><a class="tocitem" href="../maths/propagators.html">The propagators: pushforward and pullback</a></li><li><a class="tocitem" href="../maths/nondiff_points.html">Non-differentiable Points</a></li><li><a class="tocitem" href="../maths/complex.html">Complex numbers</a></li><li><a class="tocitem" href="../maths/arrays.html">Deriving array rules</a></li></ul></li><li><span class="tocitem">Design</span><ul><li><a class="tocitem" href="../design/changing_the_primal.html">Changing the Primal</a></li><li><a class="tocitem" href="../design/many_tangents.html">Many Tangent Types</a></li></ul></li><li><a class="tocitem" href="../videos.html">Videos</a></li><li><a class="tocitem" href="../FAQ.html">FAQ</a></li><li><a class="tocitem" href="../api.html">API</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">How to support ChainRules rules as an AD package author</a></li><li class="is-active"><a href="call_back_into_ad.html">Support calling back into ADs</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="call_back_into_ad.html">Support calling back into ADs</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JuliaDiff/ChainRulesCore.jl/blob/main/docs/src/ad_author/call_back_into_ad.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Declaring-support-for-calling-back-into-ADs"><a class="docs-heading-anchor" href="#Declaring-support-for-calling-back-into-ADs">Declaring support for calling back into ADs</a><a id="Declaring-support-for-calling-back-into-ADs-1"></a><a class="docs-heading-anchor-permalink" href="#Declaring-support-for-calling-back-into-ADs" title="Permalink"></a></h1><p>To declare support or lack of support for forward and reverse-mode, use the two pairs of complementary types. For reverse mode: <a href="../api.html#ChainRulesCore.HasReverseMode"><code>HasReverseMode</code></a>, <a href="../api.html#ChainRulesCore.NoReverseMode"><code>NoReverseMode</code></a>. For forwards mode: <a href="../api.html#ChainRulesCore.HasForwardsMode"><code>HasForwardsMode</code></a>, <a href="../api.html#ChainRulesCore.NoForwardsMode"><code>NoForwardsMode</code></a>. AD systems that support any calling back into AD should have one from each set.</p><p>If an AD <code>HasReverseMode</code>, then it must define <a href="../api.html#ChainRulesCore.rrule_via_ad"><code>rrule_via_ad</code></a> for that RuleConfig subtype. Similarly, if an AD <code>HasForwardsMode</code> then it must define <a href="../api.html#ChainRulesCore.frule_via_ad"><code>frule_via_ad</code></a> for that RuleConfig subtype.</p><p>For example:</p><pre><code class="language-julia hljs">struct MyReverseOnlyADRuleConfig &lt;: RuleConfig{Union{HasReverseMode, NoForwardsMode}} end

function ChainRulesCore.rrule_via_ad(::MyReverseOnlyADRuleConfig, f, args...)
...
return y, pullback
end</code></pre><p>Note that it is not actually required that the same AD is used for forward and reverse. For example <a href="https://github.com/invenia/Nabla.jl/">Nabla.jl</a> is a reverse mode AD. It might declare that it <code>HasForwardsMode</code>, and then define a wrapper around <a href="https://github.com/JuliaDiff/ForwardDiff.jl">ForwardDiff.jl</a> in order to provide that capacity.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="use_in_ad_system.html">« Usage in AD</a><a class="docs-footer-nextpage" href="opt_out.html">Support opting out of rules »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.22 on <span class="colophon-date" title="Monday 18 December 2023 03:01">Monday 18 December 2023</span>. Using Julia version 1.6.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
7 changes: 7 additions & 0 deletions v1.19.0/ad_author/opt_out.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Support opting out of rules · ChainRules</title><script data-outdated-warner src="../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL=".."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../assets/documenter.js"></script><script src="../siteinfo.js"></script><script src="../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../assets/themeswap.js"></script><link href="../assets/indigo.css" rel="stylesheet" type="text/css"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../index.html"><img src="../assets/logo.svg" alt="ChainRules logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../index.html">ChainRules</a></span></div><form class="docs-search" action="../search.html"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li><a class="tocitem" href="../index.html">Introduction</a></li><li><span class="tocitem">How to use ChainRules as a rule author</span><ul><li><a class="tocitem" href="../rule_author/intro.html">Introduction</a></li><li><a class="tocitem" href="../rule_author/example.html">Pedagogical example</a></li><li><a class="tocitem" href="../rule_author/tangents.html">Tangent types</a></li><li><a class="tocitem" href="../rule_author/which_functions_need_rules.html">Which functions need rules?</a></li><li><a class="tocitem" href="../rule_author/rule_definition_tools.html">Rule definition tools</a></li><li><a class="tocitem" href="../rule_author/writing_good_rules.html">Writing good rules</a></li><li><a class="tocitem" href="../rule_author/testing.html">Testing your rules</a></li><li><input class="collapse-toggle" id="menuitem-2-8" type="checkbox"/><label class="tocitem" for="menuitem-2-8"><span class="docs-label">Superpowers</span><i class="docs-chevron"></i></label><ul class="collapsed"><li><a class="tocitem" href="../rule_author/superpowers/projectto.html"><code>ProjectTo</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/opt_out.html"><code>@opt_out</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/ruleconfig.html"><code>RuleConfig</code></a></li><li><a class="tocitem" href="../rule_author/superpowers/gradient_accumulation.html">Gradient accumulation</a></li></ul></li><li><a class="tocitem" href="../rule_author/converting_zygoterules.html">Converting ZygoteRules.@adjoint to rrules</a></li><li><a class="tocitem" href="../rule_author/tips_for_packages.html">Tips for making your package work with AD</a></li><li><a class="tocitem" href="../rule_author/debug_mode.html">Debug mode</a></li></ul></li><li><span class="tocitem">How to support ChainRules rules as an AD package author</span><ul><li><a class="tocitem" href="use_in_ad_system.html">Usage in AD</a></li><li><a class="tocitem" href="call_back_into_ad.html">Support calling back into ADs</a></li><li class="is-active"><a class="tocitem" href="opt_out.html">Support opting out of rules</a></li></ul></li><li><span class="tocitem">The maths</span><ul><li><a class="tocitem" href="../maths/propagators.html">The propagators: pushforward and pullback</a></li><li><a class="tocitem" href="../maths/nondiff_points.html">Non-differentiable Points</a></li><li><a class="tocitem" href="../maths/complex.html">Complex numbers</a></li><li><a class="tocitem" href="../maths/arrays.html">Deriving array rules</a></li></ul></li><li><span class="tocitem">Design</span><ul><li><a class="tocitem" href="../design/changing_the_primal.html">Changing the Primal</a></li><li><a class="tocitem" href="../design/many_tangents.html">Many Tangent Types</a></li></ul></li><li><a class="tocitem" href="../videos.html">Videos</a></li><li><a class="tocitem" href="../FAQ.html">FAQ</a></li><li><a class="tocitem" href="../api.html">API</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">How to support ChainRules rules as an AD package author</a></li><li class="is-active"><a href="opt_out.html">Support opting out of rules</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href="opt_out.html">Support opting out of rules</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/JuliaDiff/ChainRulesCore.jl/blob/main/docs/src/ad_author/opt_out.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="Support-opting-out-of-rules"><a class="docs-heading-anchor" href="#Support-opting-out-of-rules">Support opting out of rules</a><a id="Support-opting-out-of-rules-1"></a><a class="docs-heading-anchor-permalink" href="#Support-opting-out-of-rules" title="Permalink"></a></h1><p>We provide two ways to know that a rule has been opted out of.</p><h3 id="rrule-/-frule-returns-nothing"><a class="docs-heading-anchor" href="#rrule-/-frule-returns-nothing"><code>rrule</code> / <code>frule</code> returns <code>nothing</code></a><a id="rrule-/-frule-returns-nothing-1"></a><a class="docs-heading-anchor-permalink" href="#rrule-/-frule-returns-nothing" title="Permalink"></a></h3><p><code>@opt_out</code> defines a <code>frule</code> or <code>rrule</code> matching the signature that returns <code>nothing</code>.</p><p>If you are in a position to generate code, in response to values returned by function calls then you can do something like:</p><pre><code class="language- hljs">res = rrule(f, xs)
if res === nothing
y, pullback = perform_ad_via_decomposition(r, xs) # do AD without hitting the rrule
else
y, pullback = res
end</code></pre><p>The Julia compiler will specialize based on inferring the return type of <code>rrule</code>, and so can remove that branch.</p><h3 id="no_rrule-/-no_frule-has-a-method"><a class="docs-heading-anchor" href="#no_rrule-/-no_frule-has-a-method"><code>no_rrule</code> / <code>no_frule</code> has a method</a><a id="no_rrule-/-no_frule-has-a-method-1"></a><a class="docs-heading-anchor-permalink" href="#no_rrule-/-no_frule-has-a-method" title="Permalink"></a></h3><p><code>@opt_out</code> also defines a method for <a href="../api.html#ChainRulesCore.no_frule"><code>ChainRulesCore.no_frule</code></a> or <a href="../api.html#ChainRulesCore.no_rrule"><code>ChainRulesCore.no_rrule</code></a>. The body of this method doesn&#39;t matter, what matters is that it is a method-table. A simple thing you can do with this is not support opting out. To do this, filter all methods from the <code>rrule</code>/<code>frule</code> method table that also occur in the <code>no_frule</code>/<code>no_rrule</code> table. This will thus avoid ever hitting an <code>rrule</code>/<code>frule</code> that returns <code>nothing</code> (and thus prevents your library from erroring). This is easily done, though it does mean ignoring the user&#39;s stated desire to opt out of the rule.</p><p>More complex you can use this to generate code that triggers your AD. If for a given signature there is a more specific method in the <code>no_rrule</code>/<code>no_frule</code> method-table, than the one that would be hit from the <code>rrule</code>/<code>frule</code> table (Excluding the one that exactly matches which will return <code>nothing</code>) then you know that the rule should not be used. You can, likely by looking at the primal method table, workout which method you would have it if the rule had not been defined, and then <code>invoke</code> it.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="call_back_into_ad.html">« Support calling back into ADs</a><a class="docs-footer-nextpage" href="../maths/propagators.html">The propagators: pushforward and pullback »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.22 on <span class="colophon-date" title="Monday 18 December 2023 03:01">Monday 18 December 2023</span>. Using Julia version 1.6.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 435938a

Please sign in to comment.