-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Documenter.jl
committed
Feb 23, 2024
1 parent
e0419f9
commit 6fde90d
Showing
47 changed files
with
2,610 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"documenter":{"julia_version":"1.6.7","generation_timestamp":"2024-02-23T05:43:52","documenter_version":"1.2.1"}} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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><meta name="title" content="Support calling back into ADs · ChainRules"/><meta property="og:title" content="Support calling back into ADs · ChainRules"/><meta property="twitter:title" content="Support calling back into ADs · ChainRules"/><meta name="description" content="Documentation for ChainRules."/><meta property="og:description" content="Documentation for ChainRules."/><meta property="twitter:description" content="Documentation for ChainRules."/><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.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/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="../search_index.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><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><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><li><a class="tocitem" href="../rule_author/superpowers/mutation_support.html">Mutation Support (experimental)</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"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><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-navbar-link" href="https://github.com/JuliaDiff/ChainRulesCore.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/JuliaDiff/ChainRulesCore.jl/blob/main/docs/src/ad_author/call_back_into_ad.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></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 <: 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><option value="auto">Automatic (OS)</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.2.1 on <span class="colophon-date" title="Friday 23 February 2024 05:43">Friday 23 February 2024</span>. Using Julia version 1.6.7.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
Oops, something went wrong.