summaryrefslogtreecommitdiffstats
path: root/docs/user-guide
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-03 14:40:18 -0700
committerGitHub <noreply@github.com>2023-11-03 14:40:18 -0700
commit111de4d5527a07877edd971e8be335e067ff9a1b (patch)
tree12b8b089141fa176a4d93eaa050beacdba34e216 /docs/user-guide
parentcc222702a8d7a1fccf8ad14b256570bcec1554ae (diff)
Update 07-autodiff.md
Diffstat (limited to 'docs/user-guide')
-rw-r--r--docs/user-guide/07-autodiff.md9
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.