diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2022-12-12 17:33:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-12 14:33:44 -0800 |
| commit | 9d048351d283f8df2a68aca52b3573dcbb8cdb9b (patch) | |
| tree | 71b869fd3d460193a1dccc77b9c0b6e3511ab53b /tests/autodiff/reverse-nested-calls.slang | |
| parent | c2dc1a86ed2f5e160749fe9f99b70db6c3e4d7a6 (diff) | |
Added support for nested calls (#2562)
* Added initial support for nested calls
* removed comments
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/autodiff/reverse-nested-calls.slang')
| -rw-r--r-- | tests/autodiff/reverse-nested-calls.slang | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/autodiff/reverse-nested-calls.slang b/tests/autodiff/reverse-nested-calls.slang new file mode 100644 index 000000000..2b55efd60 --- /dev/null +++ b/tests/autodiff/reverse-nested-calls.slang @@ -0,0 +1,29 @@ +//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 g(float y) +{ + return 4.0f * y; +} + +[BackwardDifferentiable] +float f(float x) +{ + return 3.0f * g(2.0f * x); +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + dpfloat dpa = dpfloat(1.0, 0.0); + + __bwd_diff(f)(dpa, 1.0f); + outputBuffer[0] = dpa.d; // Expect: 24.0 +} |
