Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhangNV committed Jan 3, 2025
1 parent f45cd07 commit 61a613d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/bugs/gh-5776.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cuda -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -metal -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -wgpu -output-using-type
//
struct WrappedBuffer<T : IDifferentiable>
{
StructuredBuffer<T> buffer;
int shape;

T get(int idx) { return buffer[idx]; }
}

struct GradInBuffer<T : IDifferentiable>
{
WrappedBuffer<T.Differential> grad_in;
}

struct CallData
{
WrappedBuffer<float[1]> grad_in;
}


//TEST_INPUT: set call_data.grad_in.buffer = ubuffer(data=[1.0 2.0], stride=4);
ParameterBlock<CallData> call_data;


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


[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain()
{

float[1] data1 = call_data.grad_in.buffer[0];
float[1] data2 = call_data.grad_in.get(1);
outputBuffer[0] = data1[0];
outputBuffer[1] = data2[0];
}
3 changes: 3 additions & 0 deletions tests/bugs/gh-5776.slang.expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type: float
1.000000
2.000000

0 comments on commit 61a613d

Please sign in to comment.