Skip to content

Commit 6ec8020

Browse files
committed
Replace slang lexer with hlsl
1 parent ac86b2f commit 6ec8020

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/autodiff-tips-custom-diffs.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Opaque functions are those where the internal operations are not visible or acce
1919

2020
For these functions, since the autodiff system cannot "see" inside to compute the derivative, providing a custom derivative allows you to still incorporate them into your differentiable computations.
2121

22-
```slang
22+
<!-- There is no "slang" lexer, so "hlsl" will be used here instead -->
23+
```hlsl
2324
[BackwardDerivative(externalFunction_bwd)]
2425
float externalFunction(float x)
2526
{
@@ -46,7 +47,8 @@ This example shows one option to handle an opaque function that calls an externa
4647

4748
Functions whose output depends on values retrieved from memory based on an input (e.g., accessing an RWStructuredBuffer on the GPU, or reading from a raw pointer CPU-side) introduce side-effects that automatic differentiation struggles to handle. This can include things like race conditions or ambiguous derivative write-back locations. Additionally, the lookup index itself is non-continuous. Therefore, custom derivatives are often necessary to accurately represent "change" at these points, potentially involving subgradients or specific approximations.
4849

49-
```slang
50+
<!-- There is no "slang" lexer, so "hlsl" will be used here instead -->
51+
```hlsl
5052
RWStructuredBuffer<float> myBuffer;
5153
RWStructuredBuffer<Atomic<float>> gradientBuffer; // Global buffer for gradients
5254
@@ -74,7 +76,8 @@ Numerical stability refers to how well a computation preserves accuracy when fac
7476

7577
By defining a custom derivative, you can implement more robust numerical methods that mitigate these issues, ensuring that your derivatives are well-behaved and do not lead to computational errors or poor training performance. This might involve re-parameterizations or specialized derivative formulas.
7678

77-
```slang
79+
<!-- There is no "slang" lexer, so "hlsl" will be used here instead -->
80+
```hlsl
7881
[BackwardDerivative(safeDivide_bwd)]
7982
float safeDivide(float numerator, float denominator)
8083
{

0 commit comments

Comments
 (0)