diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-03 16:44:33 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-03 16:44:33 -0800 |
| commit | 228e71dab7dfa18ece979f4099ec0c7d1e37e5ff (patch) | |
| tree | ff357f4aaed2dab25ae9e3665a97a7f3e6be32ef /tests/autodiff-dstdlib | |
| parent | ee49a62083d28353812185fd0f0c04fb50ca6be0 (diff) | |
Overhaul `transposeParameterBlock` to support `inout` params. (#2621)
* Overhaul `transposeParameterBlock` to support `inout` params.
* Small bug fixes.
* Bug fix on differentiable intrinsic specialization.
* Fixes.
* Run autodiff tests on CPU.
* Clean up.
* More bug fixes.,
* Add test coverage on inout param.
* Fix language server hinting for transcribed mutable params.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/autodiff-dstdlib')
| -rw-r--r-- | tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang | 15 | ||||
| -rw-r--r-- | tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang.expected.txt | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang b/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang index ce282eb77..379e2c3ef 100644 --- a/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang +++ b/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang @@ -1,7 +1,8 @@ //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj -//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer<float> outputBuffer; typedef DifferentialPair<float> dpfloat; @@ -14,6 +15,12 @@ float diffExp(float x) return exp(x); } +[BackwardDifferentiable] +float diffSin(float x) +{ + return sin(x); +} + [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { @@ -30,4 +37,10 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) outputBuffer[2] = dpx.p; // Expect: 0.000000 outputBuffer[3] = dpx.d; // Expect: 1.000000 } + + { + dpfloat dpx = dpfloat(float.getPi(), 1.0); + __bwd_diff(diffSin)(dpx, 1.0); + outputBuffer[4] = dpx.d; // Expect: -1.000000 + } } diff --git a/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang.expected.txt b/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang.expected.txt index 49e34b0bf..a4b804cb8 100644 --- a/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang.expected.txt +++ b/tests/autodiff-dstdlib/dstdlib-elementary-bwd.slang.expected.txt @@ -2,4 +2,5 @@ type: float 2.000000 7.389056 0.000000 -1.000000
\ No newline at end of file +1.000000 +-1.00000
\ No newline at end of file |
