diff options
| author | Yong He <yonghe@outlook.com> | 2023-11-03 14:40:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-03 14:40:18 -0700 |
| commit | 111de4d5527a07877edd971e8be335e067ff9a1b (patch) | |
| tree | 12b8b089141fa176a4d93eaa050beacdba34e216 /docs/user-guide | |
| parent | cc222702a8d7a1fccf8ad14b256570bcec1554ae (diff) | |
Update 07-autodiff.md
Diffstat (limited to 'docs/user-guide')
| -rw-r--r-- | docs/user-guide/07-autodiff.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/user-guide/07-autodiff.md b/docs/user-guide/07-autodiff.md index 1f6cb06af..0751d4296 100644 --- a/docs/user-guide/07-autodiff.md +++ b/docs/user-guide/07-autodiff.md @@ -585,6 +585,15 @@ float fwd_derivative(float a, DifferentialPair<float> x); void back_prop(float a, inout DifferentialPair<float> x, float d_y); ``` +By default, the implicit `this` parameter will be treated as differentiable if the enclosing type of the member method is differentiable. If you wish to exclude `this` parameter from differentiation, use `[NoDiffThis]` attribute on the method: +```csharp +struct MyDifferentiableType : IDifferentiable +{ + [NoDiffThis] // Make `this` parameter `no_diff`. + float compute(float x) { ... } +} +``` + ### Excluding Struct Members from Differentiation When using automatic `IDifferentiable` conformance synthesis for a `struct` type, Slang will by-default treat all struct members that have a differentiable type as differentiable, and thus include a corresponding field in the generated `Differential` type for the struct. |
