From f6cbb81e1c0080518185294ee94705f5e93aa849 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:49:19 -0800 Subject: Fix DCE for calls to functions that have associations (#6272) * Fix DCE for calls to functions that have associations * Update slang-ir-util.cpp * Update slang-ir-util.cpp --- tests/autodiff/custom-diff-empty-func.slang | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/autodiff/custom-diff-empty-func.slang (limited to 'tests') diff --git a/tests/autodiff/custom-diff-empty-func.slang b/tests/autodiff/custom-diff-empty-func.slang new file mode 100644 index 000000000..c566d9e19 --- /dev/null +++ b/tests/autodiff/custom-diff-empty-func.slang @@ -0,0 +1,35 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type -g0 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +void foo_bwd(float a, inout DifferentialPair dpx) +{ + outputBuffer[2] = 2.f; +} + +[Differentiable, BackwardDerivative(foo_bwd)] +void foo(no_diff float a, float x) +{ } + +[Differentiable] +float outerFunc(no_diff float a, float x) +{ + foo(a, x); + return 1.f; +} + +[numthreads(1, 1, 1)] +[shader("compute")] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + float a = 10.0; + DifferentialPair dpx = DifferentialPair(4.f, 1.f); + bwd_diff(outerFunc)(a, dpx, 1.0); + + // CHECK: type: float + // CHECK: 0.0 + // CHECK: 0.0 + // CHECK: 2.0 + // CHECK: 0.0 +} \ No newline at end of file -- cgit v1.2.3