summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/autodiff-data-flow-4.slang
blob: 08fabf9542797d075ac399e7eb27db51204bf577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//DIAGNOSTIC_TEST:SIMPLE:

float nonDiff(float x)
{
    return x;
}

[Differentiable]
float f(float x)
{
    return x * x;
}

[Differentiable]
float h(float x)
{
    float val = 0;

    // call to non-differentiable method 
    // (should error if the data-flow propagation works properly.)
    // 
    float y = nonDiff(x);

    // call to a differentiable method, using the
    // result of a non-differentiable call.
    // 
    val = f(y);

    return val;
}