2 1 0</code></pre><p>Likewise, you could write a version of <code>vector_hessian</code> which supports functions of the form <code>f!(y, x)</code>, or perhaps an in-place Jacobian with <code>ForwardDiff.jacobian!</code>.</p><h2 id="Custom-tags-and-tag-checking"><a class="docs-heading-anchor" href="#Custom-tags-and-tag-checking">Custom tags and tag checking</a><a id="Custom-tags-and-tag-checking-1"></a><a class="docs-heading-anchor-permalink" href="#Custom-tags-and-tag-checking" title="Permalink"></a></h2><p>The <code>Dual</code> type includes a "tag" parameter indicating the particular function call to which it belongs. This is to avoid a problem known as <a href="https://github.com/JuliaDiff/ForwardDiff.jl/issues/83"><em>perturbation confusion</em></a> which can arise when there are nested differentiation calls. Tags are automatically generated as part of the appropriate config object, and the tag is checked when the config is used as part of a differentiation call (<code>derivative</code>, <code>gradient</code>, etc.): an <code>InvalidTagException</code> will be thrown if the incorrect config object is used.</p><p>This checking can sometimes be inconvenient, and there are certain cases where you may want to disable this checking.</p><div class="admonition is-warning" id="Warning-3eb05abadd191f82"><header class="admonition-header">Warning<a class="admonition-anchor" href="#Warning-3eb05abadd191f82" title="Permalink"></a></header><div class="admonition-body"><p>Disabling tag checking should only be done with caution, especially if the code itself could be used inside another differentiation call.</p></div></div><ol><li><p>(preferred) Provide an extra <code>Val{false}()</code> argument to the differentiation function, e.g.</p><pre><code class="language-julia hljs">cfg = ForwardDiff.GradientConfig(g, x)
0 commit comments