yum-mirror/slang

Making it easier to work with shaders

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

venkataram-nvReport AD checkpoint contexts (#5058)b808aa4df

master
1.2 KiB45 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
4//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain -line-directive-mode none
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
7RWStructuredBuffer<float> outputBuffer;
8
9typedef DifferentialPair<float> dpfloat;
10typedef float.Differential dfloat;
11
12[BackwardDifferentiable]
13[PreferRecompute]
14float g(float x)
15{
16    return log(x);
17}
18
19[BackwardDifferentiable]
20float f(int p, float x)
21{
22    float y = 1.0;
23    // Test that phi parameter can be restored.
24    if (p == 0)
25        y = g(x);
26    return y * y;
27}
28
29// Check that there are no calls to primal_g in bwd_f.
30
31// CHECK: void s_bwd_prop_f_{{[0-9]+}}
32// CHECK: {{[_a-zA-Z0-9]+}} = s_primal_ctx_g_{{[0-9]+}}
33// CHECK: return
34
35
36[numthreads(1, 1, 1)]
37void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
38{
39    dpfloat dpa = dpfloat(2.0, 0.0);
40
41    __bwd_diff(f)(0, dpa, 1.0f);
42    outputBuffer[0] = dpa.d; // Expect: 1
43}
44
45//CHK-NOT: note