summaryrefslogtreecommitdiff
path: root/tests/autodiff/cuda-kernel-export.slang
blob: 0db4d8cea7b4bb75b0084ea5f79bcd728513f114 (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
//DISABLED_TEST:SIMPLE: -target cuda -line-directive-mode none

// Verify that we can output a cuda device function with [CudaDeviceExport].
// Disabled until we have FileCheck.

struct MixedType : IDifferentiable
{
    no_diff float noDiffField;
    float field;
}

[BackwardDifferentiable]
float f1(MixedType m)
{
    return 2.0 * m.field;
}

[BackwardDifferentiable]
float f(MixedType m)
{
    MixedType m1 = { m.noDiffField, m.field };
    return f1(m1);
}

[CudaDeviceExport]
void diffF(inout DifferentialPair<MixedType> m, float dout)
{
    __bwd_diff(f)(m, dout);
}