diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-15 17:18:00 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-15 17:18:00 -0800 |
| commit | 86675155eb79532039ba79655ed14a76998e9f85 (patch) | |
| tree | e6749018fb853d0f1d228631dafeebf3fd4df4df /tests | |
| parent | 266dc667485b38e16877cb9868873619e1b263e9 (diff) | |
Treat user defined backward derivative function as non differentiable. (#2650)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autodiff/backward-diff-check.slang | 27 | ||||
| -rw-r--r-- | tests/autodiff/backward-diff-check.slang.expected.txt | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/autodiff/backward-diff-check.slang b/tests/autodiff/backward-diff-check.slang new file mode 100644 index 000000000..2718f31f1 --- /dev/null +++ b/tests/autodiff/backward-diff-check.slang @@ -0,0 +1,27 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +typedef DifferentialPair<float> dpfloat; +typedef float.Differential dfloat; + +[BackwardDifferentiable] +float test() +{ + return 2.0f; +} + +float noDiffFunc(float x) { return x; } +[BackwardDerivativeOf(test)] +void d_test(float dOut) +{ + outputBuffer[0] = noDiffFunc(dOut); +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + __bwd_diff(test)(3.0f); +} diff --git a/tests/autodiff/backward-diff-check.slang.expected.txt b/tests/autodiff/backward-diff-check.slang.expected.txt new file mode 100644 index 000000000..72bbdbbcd --- /dev/null +++ b/tests/autodiff/backward-diff-check.slang.expected.txt @@ -0,0 +1,6 @@ +type: float +3.000000 +0.000000 +0.000000 +0.000000 +0.000000 |
