summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-02 14:54:22 -0700
committerGitHub <noreply@github.com>2023-11-02 14:54:22 -0700
commit911a4401b08f6199e18b32349c236c186a2dd128 (patch)
tree75cd31ceb7a1c134f41cc8c44a08cd9123c27613 /tests
parent72e95f2c62b39ef1ddb6c169a9452a3b4fcb22a5 (diff)
Fix crash when writing to `no_diff` out parameter. (#3308)
* Fix crash when writing to `no_diff` out parameter. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/autodiff/no-diff-out.slang30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/autodiff/no-diff-out.slang b/tests/autodiff/no-diff-out.slang
new file mode 100644
index 000000000..c8085a05f
--- /dev/null
+++ b/tests/autodiff/no-diff-out.slang
@@ -0,0 +1,30 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+typedef DifferentialPair<float> dpfloat;
+
+[Differentiable]
+float test(float x, no_diff out float y)
+{
+ if (x == 1.0)
+ y = 0.0;
+ return x * x;
+}
+
+[Differentiable]
+float caller(float x, no_diff out float y)
+{
+ return test(x, y);
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ var p = diffPair(3.0, 0.0);
+ bwd_diff(caller)(p, 1.0);
+ outputBuffer[dispatchThreadID.x] = p.d;
+ // CHECK: 6.0
+}