summaryrefslogtreecommitdiff
path: root/tests/autodiff
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-04-27 02:27:28 -0400
committerGitHub <noreply@github.com>2024-04-26 23:27:28 -0700
commit2b87c00c671b156b8e5926f8967003bf12c65aa7 (patch)
treec993872a1b9a568ea4c963b2c710c12f496cc559 /tests/autodiff
parente91bd3b0bdc50f66bfd302ff079c65fba5126474 (diff)
Fix invoke resolution when dealing with overloded type expressions (#4043)
Diffstat (limited to 'tests/autodiff')
-rw-r--r--tests/autodiff/differential-type-constructor.slang25
-rw-r--r--tests/autodiff/differential-type-constructor.slang.expected.txt6
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/autodiff/differential-type-constructor.slang b/tests/autodiff/differential-type-constructor.slang
new file mode 100644
index 000000000..9afff878d
--- /dev/null
+++ b/tests/autodiff/differential-type-constructor.slang
@@ -0,0 +1,25 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
+
+struct MyStruct: IDifferentiable
+{
+ float a;
+ int b;
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ {
+ var dp = diffPair(MyStruct(), MyStruct.Differential());
+
+ outputBuffer[0] = dp.d.a;
+
+ var dp2 = diffPair<MyStruct>(MyStruct(), MyStruct.Differential(1.f));
+
+ outputBuffer[1] = dp2.d.a;
+ }
+} \ No newline at end of file
diff --git a/tests/autodiff/differential-type-constructor.slang.expected.txt b/tests/autodiff/differential-type-constructor.slang.expected.txt
new file mode 100644
index 000000000..d9eca87b2
--- /dev/null
+++ b/tests/autodiff/differential-type-constructor.slang.expected.txt
@@ -0,0 +1,6 @@
+type: float
+0.000000
+1.000000
+0.000000
+0.000000
+0.000000