diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autodiff/differential-type-constructor.slang | 25 | ||||
| -rw-r--r-- | tests/autodiff/differential-type-constructor.slang.expected.txt | 6 |
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 |
