yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jarcherNVEnable CUDA testing for batch 2 (#8147)3618f7a4c

master
935 B36 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type -g0
2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-cuda -compute -shaderobj -output-using-type -g0
3
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
5RWStructuredBuffer<float> outputBuffer;
6
7void foo_bwd(float a, inout DifferentialPair<float> dpx)
8{
9    outputBuffer[2] = 2.f;
10}
11
12[Differentiable, BackwardDerivative(foo_bwd)]
13void foo(no_diff float a, float x)
14{ }
15
16[Differentiable]
17float outerFunc(no_diff float a, float x)
18{
19    foo(a, x);
20    return 1.f;
21}
22
23[numthreads(1, 1, 1)]
24[shader("compute")]
25void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
26{
27    float a = 10.0;
28    DifferentialPair<float> dpx = DifferentialPair<float>(4.f, 1.f);
29    bwd_diff(outerFunc)(a, dpx, 1.0);
30    
31    // CHECK: type: float
32    // CHECK: 0.0
33    // CHECK: 0.0
34    // CHECK: 2.0
35    // CHECK: 0.0
36}