diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-14 09:31:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-14 09:31:51 -0700 |
| commit | e291f60c6b083eaa74aed5307a6e9461274c1642 (patch) | |
| tree | bde9b45a9e09ebbe173fae1821237b258a9ff800 /docs | |
| parent | a911ca6e06ce41e403b80fe6054162393491c8ac (diff) | |
Support `fwd_diff(bwd_diff(f))`. (#2697)
* Support `fwd_diff(bwd_diff(f))`.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user-guide/07-autodiff.md | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/docs/user-guide/07-autodiff.md b/docs/user-guide/07-autodiff.md index aed6ad65e..6f2bdc447 100644 --- a/docs/user-guide/07-autodiff.md +++ b/docs/user-guide/07-autodiff.md @@ -613,7 +613,7 @@ However, the `no_diff` keyword is not required in a call if a non-differentiable ## Higher Order Differentiation -Slang supports generating higher order forward derivative functions. It is allowed to use `__fwd_diff` operator inside a forward differentiable function, or to nest `__fwd_diff` operators. For example, `__fwd_diff(__fwd_diff(sin))` will have the following signature: +Slang supports generating higher order forward and backward derivative propagation functions. It is allowed to use `__fwd_diff` and `__bwd_diff` operators inside a forward or backward differentiable function, or to nest `__fwd_diff` and `__bwd_diff` operators. For example, `__fwd_diff(__fwd_diff(sin))` will have the following signature: ```csharp DifferentialPair<DifferentialPair<float>> sin_diff2(DifferentialPair<DifferentialPair<float>> x); @@ -621,9 +621,7 @@ DifferentialPair<DifferentialPair<float>> sin_diff2(DifferentialPair<Differentia The input parameter `x` contains four fields: `x.p.p`, `x.p.d,`, `x.d.p`, `x.d.d`, where `x.p.p` specifies the orgiginal input value, both `x.p.d` and `x.d.p` store the first order derivative if `x`, and `x.d.d` stores the second order derivative of `x`. Calling `__fwd_diff(__fwd_diff(sin))` with `diffPair(diffPair(pi/2, 1.0), DiffPair(1.0, 0.0))` will result `{ { 1.0, 0.0 }, { 0.0, -1.0 } }`. -Currently, Slang only supports nesting of the `__fwd_diff` operator. The `__bwd_diff` operator cannot be nested. Using `__bwd_diff` operator in a forward derivative or backward propagation function is now allowed and will result in compile-time error. - -User defined higher-order derivative functions can be specified by using `[ForwardDerivative]` attribute on the derivative function, or by using `[ForwardDerivativeOf]` attribute on the higher-order derivative function. +User defined higher-order derivative functions can be specified by using `[ForwardDerivative]` or `[BackwardDerivative]` attribute on the derivative function, or by using `[ForwardDerivativeOf]` or `[BackwardDerivativeOf]` attribute on the higher-order derivative function. ## Interactions with Generics and Interfaces |
