summaryrefslogtreecommitdiffstats
path: root/docs/user-guide
diff options
context:
space:
mode:
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.