Skip to content

Commit

Permalink
Fix tests\autodiff\reverse-while-loop-3.slang test (shader-slang#4886)
Browse files Browse the repository at this point in the history
* Fix `tests\autodiff\reverse-while-loop-3.slang` test

Fixes: shader-slang#4876

Fix `tests\autodiff\reverse-while-loop-3.slang` test to have correct listed output values

* set default to 1 (different val)

---------

Co-authored-by: Yong He <yonghe@outlook.com>
  • Loading branch information
ArielG-NV and csyonghe authored Aug 21, 2024
1 parent bcb5391 commit 03e1e17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 12 additions & 7 deletions tests/autodiff/reverse-while-loop-3.slang
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -output-using-type -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
//TEST_INPUT:ubuffer(data=[1], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;

// This test isn't actually testing the output, but rather that the compiler doesn't crash upon
// encountering a specific loop pattern. ('Data' is non-differentiable here, so the expected output is 0)s
// encountering a specific loop pattern. ('Data' is non-differentiable here, so the expected output is 0)
//

typedef DifferentialPair<float> dpfloat;
Expand All @@ -21,6 +21,10 @@ struct P

struct Data
{
__init(float dataIn)
{
this.t = dataIn;
}
float t;
};

Expand All @@ -32,7 +36,7 @@ void updateData(Data data)
[BackwardDifferentiable]
float test_simple_while(float y, uint n)
{
Data d = { y };
Data d = Data(y);
P p;
p.terminated = false;
int i = n;
Expand Down Expand Up @@ -61,6 +65,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
dpfloat dpa = dpfloat(1.0, 0.0);

__bwd_diff(test_simple_while)(dpa, 2, 1.0f);
outputBuffer[0] = dpa.d; // Expect: 8.0
outputBuffer[0] = dpa.d;
//BUF: 0
}
}
6 changes: 0 additions & 6 deletions tests/autodiff/reverse-while-loop-3.slang.expected.txt

This file was deleted.

0 comments on commit 03e1e17

Please sign in to comment.