Skip to content

Commit bd948e7

Browse files
author
Documenter.jl
committed
build based on bbc39fd
1 parent a542fa3 commit bd948e7

16 files changed

Lines changed: 123 additions & 120 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"documenter":{"julia_version":"1.12.1","generation_timestamp":"2025-11-14T14:07:26","documenter_version":"1.16.0"}}
1+
{"documenter":{"julia_version":"1.12.1","generation_timestamp":"2025-11-15T23:02:42","documenter_version":"1.16.0"}}

DifferentiationInterface/dev/api/index.html

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

DifferentiationInterface/dev/dev/contributing/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

DifferentiationInterface/dev/dev/internals/index.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

DifferentiationInterface/dev/dev/math/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

DifferentiationInterface/dev/explanation/advanced/index.html

Lines changed: 2 additions & 3 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!DOCTYPE html>
2+
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Arguments · DifferentiationInterface.jl</title><meta name="title" content="Arguments · DifferentiationInterface.jl"/><meta property="og:title" content="Arguments · DifferentiationInterface.jl"/><meta property="twitter:title" content="Arguments · DifferentiationInterface.jl"/><meta name="description" content="Documentation for DifferentiationInterface.jl."/><meta property="og:description" content="Documentation for DifferentiationInterface.jl."/><meta property="twitter:description" content="Documentation for DifferentiationInterface.jl."/><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/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><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/favicon.ico" rel="icon" type="image/x-icon"/></head><body><div id="documenter"><nav class="docs-sidebar"><a class="docs-logo" href="../../"><img src="../../assets/logo.svg" alt="DifferentiationInterface.jl logo"/></a><div class="docs-package-name"><span class="docs-autofit"><a href="../../">DifferentiationInterface.jl</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="../../">Home</a></li><li><span class="tocitem">Tutorials</span><ul><li><a class="tocitem" href="../../tutorials/basic/">Basic tutorial</a></li><li><a class="tocitem" href="../../tutorials/advanced/">Advanced tutorial</a></li></ul></li><li><a class="tocitem" href="../../api/">API</a></li><li><span class="tocitem">Explanation</span><ul><li class="is-active"><a class="tocitem" href>Arguments</a><ul class="internal"><li><a class="tocitem" href="#General-guidelines"><span>General guidelines</span></a></li><li><a class="tocitem" href="#Contexts"><span>Contexts</span></a></li></ul></li><li><a class="tocitem" href="../operators/">Operators</a></li><li><a class="tocitem" href="../backends/">Backends</a></li><li><a class="tocitem" href="../advanced/">Advanced features</a></li></ul></li><li><span class="tocitem">FAQ</span><ul><li><a class="tocitem" href="../../faq/limitations/">Limitations</a></li><li><a class="tocitem" href="../../faq/differentiability/">Differentiability</a></li></ul></li><li><span class="tocitem">Development</span><ul><li><a class="tocitem" href="../../dev/internals/">Internals</a></li><li><a class="tocitem" href="../../dev/math/">Mathematical model</a></li><li><a class="tocitem" href="../../dev/contributing/">Contributing</a></li></ul></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">Explanation</a></li><li class="is-active"><a href>Arguments</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Arguments</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/JuliaDiff/DifferentiationInterface.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/DifferentiationInterface.jl/blob/main/DifferentiationInterface/docs/src/explanation/arguments.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="Arguments"><a class="docs-heading-anchor" href="#Arguments">Arguments</a><a id="Arguments-1"></a><a class="docs-heading-anchor-permalink" href="#Arguments" title="Permalink"></a></h1><h2 id="General-guidelines"><a class="docs-heading-anchor" href="#General-guidelines">General guidelines</a><a id="General-guidelines-1"></a><a class="docs-heading-anchor-permalink" href="#General-guidelines" title="Permalink"></a></h2><h3 id="Function-form"><a class="docs-heading-anchor" href="#Function-form">Function form</a><a id="Function-form-1"></a><a class="docs-heading-anchor-permalink" href="#Function-form" title="Permalink"></a></h3><p>DifferentiationInterface only computes derivatives for functions with one of two specific forms:</p><pre><code class="language-julia hljs">y = f(x, contexts...) # out of place, returns `y`
3+
f!(y, x, contexts...) # in place, returns `nothing`</code></pre><p>In this notation:</p><ul><li><code>f</code> (or <code>f!</code>) is the differentiated function</li><li><code>y</code> is the output</li><li><code>x</code> is the input, the only &quot;active&quot; argument, which always comes first</li><li><code>contexts</code> may contain additional, inactive arguments</li></ul><p>The quantities returned by the various <a href="../operators/#Operators">operators</a> always correspond to (partial) derivatives of <code>y</code> with respect to <code>x</code>.</p><h3 id="Assumptions"><a class="docs-heading-anchor" href="#Assumptions">Assumptions</a><a id="Assumptions-1"></a><a class="docs-heading-anchor-permalink" href="#Assumptions" title="Permalink"></a></h3><p>The package makes one central assumption on the behavior and implementation of <code>f</code> (or <code>f!</code>):</p><div class="admonition is-danger" id="Mutation-rule-dbc96e17017da004"><header class="admonition-header">Mutation rule<a class="admonition-anchor" href="#Mutation-rule-dbc96e17017da004" title="Permalink"></a></header><div class="admonition-body"><p>Either an argument&#39;s provided value matters, or it can be mutated during the function call, but never both.</p></div></div><p>This rule is declined as follows:</p><ul><li>The provided value of <code>x</code> matters because we evaluate and differentiate <code>f</code> at point <code>x</code>. Therefore, <code>x</code> cannot be mutated by the function.</li><li>For in-place functions <code>f!</code>, the output <code>y</code> is meant to be overwritten. Hence, its provided (initial) value cannot matter, and it must be entirely overwritten.</li></ul><div class="admonition is-warning" id="Warning-f4cb7f914517bcb6"><header class="admonition-header">Warning<a class="admonition-anchor" href="#Warning-f4cb7f914517bcb6" title="Permalink"></a></header><div class="admonition-body"><p>Whether or not the function object itself can be mutated is a tricky question, and support for this varies between backends. When in doubt, try to avoid mutating functions and pass contexts instead. In any case, DifferentiationInterface will assume that the recursive components (fields, subfields, etc.) of <code>f</code> or <code>f!</code> individually satisfy the same mutation rule: whenever the initial value matters, no mutation is allowed.</p></div></div><h2 id="Contexts"><a class="docs-heading-anchor" href="#Contexts">Contexts</a><a id="Contexts-1"></a><a class="docs-heading-anchor-permalink" href="#Contexts" title="Permalink"></a></h2><h3 id="Motivation"><a class="docs-heading-anchor" href="#Motivation">Motivation</a><a id="Motivation-1"></a><a class="docs-heading-anchor-permalink" href="#Motivation" title="Permalink"></a></h3><p>As stated, there can be only one active argument, which we call <code>x</code>. However, version 0.6 of the package introduced the possibility of additional &quot;context&quot; arguments, whose derivatives we don&#39;t need to compute. Contexts can be useful if you have a function <code>y = f(x, a, b, c, ...)</code> or <code>f!(y, x, a, b, c, ...)</code> and you only want the derivative of <code>y</code> with respect to <code>x</code>. Another option would be creating a closure, but that is sometimes undesirable for performance reasons.</p><p>Every context argument must be wrapped in a subtype of <a href="../../api/#DifferentiationInterface.Context"><code>Context</code></a> and come after the active argument <code>x</code>.</p><h3 id="Context-types"><a class="docs-heading-anchor" href="#Context-types">Context types</a><a id="Context-types-1"></a><a class="docs-heading-anchor-permalink" href="#Context-types" title="Permalink"></a></h3><p>There are three kinds of context: <a href="../../api/#DifferentiationInterface.Constant"><code>Constant</code></a>, <a href="../../api/#DifferentiationInterface.Cache"><code>Cache</code></a> and the hybrid <a href="../../api/#DifferentiationInterface.ConstantOrCache"><code>ConstantOrCache</code></a>. Those are also classified based on the mutation rule:</p><ul><li><a href="../../api/#DifferentiationInterface.Constant"><code>Constant</code></a> contexts wrap data that influences the output of the function. Hence they cannot be mutated.</li><li><a href="../../api/#DifferentiationInterface.Cache"><code>Cache</code></a> contexts correspond to scratch spaces that can be mutated at will. Hence their provided value is arbitrary.</li><li><a href="../../api/#DifferentiationInterface.ConstantOrCache"><code>ConstantOrCache</code></a> is a hybrid, whose recursive components (fields, subfields, etc.) must individually satisfy the assumptions of either <code>Constant</code> or <code>Cache</code>.</li></ul><p>Semantically, both of these calls compute the partial gradient of <code>f(x, c)</code> with respect to <code>x</code>, but they consider <code>c</code> differently:</p><pre><code class="language-julia hljs">gradient(f, backend, x, Constant(c))
4+
gradient(f, backend, x, Cache(c))</code></pre><p>In the first call, <code>c</code> must be kept unchanged throughout the function evaluation. In the second call, <code>c</code> may be mutated with values computed during the function.</p><div class="admonition is-warning" id="Warning-fc74fed0eb988d54"><header class="admonition-header">Warning<a class="admonition-anchor" href="#Warning-fc74fed0eb988d54" title="Permalink"></a></header><div class="admonition-body"><p>Not every backend supports every type of context. See the documentation on <a href="../backends/#Backends">backends</a> for more details.</p></div></div></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../../api/">« API</a><a class="docs-footer-nextpage" href="../operators/">Operators »</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="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.0 on <span class="colophon-date" title="Saturday 15 November 2025 23:02">Saturday 15 November 2025</span>. Using Julia version 1.12.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>

DifferentiationInterface/dev/explanation/backends/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

DifferentiationInterface/dev/explanation/operators/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)