diff options
| author | Yong He <yonghe@outlook.com> | 2022-11-23 16:02:56 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 16:02:56 -0800 |
| commit | 4ad0470025da4e808c46023f9a2525febcf973a2 (patch) | |
| tree | 8fcb1c84121ddf40c50ca58b5de867da0da435ee /tests/autodiff/bool-return-val.slang | |
| parent | 97cb4851eed7a43f10196971b08d3d311386ce9f (diff) | |
Fix issues around dynamic generic function and autodiff. (#2528)
* Fix issues around dynamic generic function and autodiff.
* Fix return type issue.
* Fix type unification for generic `inout` parameter.
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/autodiff/bool-return-val.slang')
| -rw-r--r-- | tests/autodiff/bool-return-val.slang | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/autodiff/bool-return-val.slang b/tests/autodiff/bool-return-val.slang new file mode 100644 index 000000000..a43495dd9 --- /dev/null +++ b/tests/autodiff/bool-return-val.slang @@ -0,0 +1,28 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +struct NonDiff +{ + float a; +} + +[ForwardDifferentiable] +bool myFunc(NonDiff fIn, inout float x) +{ + x = pow(x, fIn.a); + return x > 100.f; +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + float a = 10.0; + NonDiff fIn = { a }; + DifferentialPair<float> dpx = DifferentialPair<float>(4.f, 1.f); + bool res = __fwd_diff(myFunc)(fIn, dpx); + + outputBuffer[0] = res?1:0; +}
\ No newline at end of file |
