summaryrefslogtreecommitdiff
path: root/tests/autodiff-dstdlib/dstdlib-max.slang
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2025-02-20 23:31:05 -0800
committerGitHub <noreply@github.com>2025-02-20 23:31:05 -0800
commitca592d2791047be4df3cac44c18af99f003bd085 (patch)
tree9cbe6ca41ad95257d16bbcc01b0639505203916a /tests/autodiff-dstdlib/dstdlib-max.slang
parent4d286aab2ec23c081f23846f5dfdb30b1c05728b (diff)
Fix gradient behavior for min() and max() functions at boundaries. When input values are equal, the gradient is split evenly between both inputs. (#6411)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/autodiff-dstdlib/dstdlib-max.slang')
-rw-r--r--tests/autodiff-dstdlib/dstdlib-max.slang52
1 files changed, 0 insertions, 52 deletions
diff --git a/tests/autodiff-dstdlib/dstdlib-max.slang b/tests/autodiff-dstdlib/dstdlib-max.slang
deleted file mode 100644
index 026914c8c..000000000
--- a/tests/autodiff-dstdlib/dstdlib-max.slang
+++ /dev/null
@@ -1,52 +0,0 @@
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
-//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
-
-//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
-RWStructuredBuffer<float> outputBuffer;
-
-typedef DifferentialPair<float> dpfloat;
-typedef DifferentialPair<float2> dpfloat2;
-
-[BackwardDifferentiable]
-float diffMax(float x, float y)
-{
- return max(x, y);
-}
-
-[BackwardDifferentiable]
-float2 diffMax(float2 x, float2 y)
-{
- return max(x, y);
-}
-
-[numthreads(1, 1, 1)]
-void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
-{
- {
- dpfloat dpx = dpfloat(2.0, 1.0);
- dpfloat dpy = dpfloat(5.0, -2.0);
- dpfloat res = __fwd_diff(diffMax)(dpx, dpy);
- outputBuffer[0] = res.p; // Expect: 5.000000
- outputBuffer[1] = res.d; // Expect: -2.000000
- }
-
- {
- dpfloat2 dpx = dpfloat2(float2(-3.0, 4.0), float2(-1.0, -1.0));
- dpfloat2 dpy = dpfloat2(float2(1.0, 2.0), float2(2.0, 2.0));
- dpfloat2 res = __fwd_diff(diffMax)(dpx, dpy);
- outputBuffer[2] = res.p[0]; // Expect: 1.000000
- outputBuffer[3] = res.d[0]; // Expect: 2.000000
- outputBuffer[4] = res.p[1]; // Expect: 4.000000
- outputBuffer[5] = res.d[1]; // Expect: -1.000000
- }
-
- {
- dpfloat2 dpx = dpfloat2(float2(2.0, 3.0), float2(0.0, 0.0));
- dpfloat2 dpy = dpfloat2(float2(5.0, 1.0), float2(0.0, 0.0));
- __bwd_diff(diffMax)(dpx, dpy, float2(1.0, 2.0));
- outputBuffer[6] = dpx.d[0]; // Expect: 0.000000
- outputBuffer[7] = dpx.d[1]; // Expect: 2.000000
- outputBuffer[8] = dpy.d[0]; // Expect: 1.000000
- outputBuffer[9] = dpy.d[1]; // Expect: 0.000000
- }
-}