yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
41e7e565e
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj 4//TEST:SIMPLE(filecheck=CHK):-target hlsl -stage compute -entry computeMain -report-checkpoint-intermediates 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<float> outputBuffer; 8 9typedef DifferentialPair<float> dpfloat; 10typedef float.Differential dfloat; 11 12//CHK-DAG: note: checkpointing context of 20 bytes associated with function: 'test_loop_with_continue' 13[BackwardDifferentiable] 14float test_loop_with_continue(float y) 15{ 16 //CHK-DAG: note: 20 bytes (FixedArray<float, 5> ) used to checkpoint the following item: 17 float t = y; 18 19 for (int i = 0; i < 3; i++) 20 { 21 if (t > 4.0) 22 continue; 23 24 t = t * t; 25 } 26 27 return t; 28} 29 30[numthreads(1, 1, 1)] 31void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 32{ 33 { 34 dpfloat dpa = dpfloat(2.0, 0.0); 35 36 __bwd_diff(test_loop_with_continue)(dpa, 1.0f); 37 outputBuffer[0] = dpa.d; // Expect: 32.0 38 } 39 40 { 41 dpfloat dpa = dpfloat(0.4, 0.0); 42 43 __bwd_diff(test_loop_with_continue)(dpa, 1.0f); 44 outputBuffer[1] = dpa.d; // Expect: 0.0131072 45 } 46} 47 48//CHK-NOT: note