diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2022-06-30 19:24:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-30 19:24:24 -0400 |
| commit | 77af111867eb72f26b460c5925be47aa22c71556 (patch) | |
| tree | b516734ccec92f01eaa07a7844b3862b3c5ab628 /tests/ir | |
| parent | 2c09275388d4c88ea26bf709132b8be4a9e342bc (diff) | |
Added `[__custom_jvp(func)]` attribute, and modified the derivative pass to only process referenced functions. (#2309)
* Added JVPTranscriber to handle differentiation of load, store, var, param and return instructions, as well as conversion of data and function types
* Changed class names to be more in line with convention. Added correct type checking for __jvp() and verified that simple calls with only loads and stores are processed correctly
* Added logic to differentiate basic arithmetic and literals inside IRConstruct and fixed the way parameters are differentiated
* Replaced some SLANG_UNEXPECTED macro uses with diagnostics instead
* Added work-list-based on-demand generation of derivative functions
* Fixed up a couple of TODOs
* Added attribute [__custom_jvp(f)] to assign a custom derivative function to a declaration
* Added a test for CustomJVPAttribute on a redeclaration of an imported function
* Moving arithmetic test to new folder
* Moving arithmetic test to new folder (2)
* Added missing test module
* Fixed a minor note
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/ir')
| -rw-r--r-- | tests/ir/derivative-op-ir-test.slang | 39 | ||||
| -rw-r--r-- | tests/ir/derivative-op-ir-test.slang.expected.txt | 5 |
2 files changed, 0 insertions, 44 deletions
diff --git a/tests/ir/derivative-op-ir-test.slang b/tests/ir/derivative-op-ir-test.slang deleted file mode 100644 index 7addccdc2..000000000 --- a/tests/ir/derivative-op-ir-test.slang +++ /dev/null @@ -1,39 +0,0 @@ -//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; - -__differentiate_jvp float f(float x) -{ - return x; -} - -__differentiate_jvp float g(float x) -{ - return x + x; -} - -__differentiate_jvp float h(float x, float y) -{ - float m = x + y; - float n = x - y; - return m * n + 2 * x * y; -} - - -[numthreads(1, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) -{ - { - float a = 2.0; - float b = 1.5; - float da = 1.0; - float db = 1.0; - - outputBuffer[0] = __jvp(f)(a, da); // Expect: 1 - outputBuffer[1] = __jvp(f)(a, 0.0); // Expect: 0 - outputBuffer[2] = __jvp(g)(a, da); // Expect: 2 - outputBuffer[3] = __jvp(h)(a, b, da, db); // Expect: 8 - } -} diff --git a/tests/ir/derivative-op-ir-test.slang.expected.txt b/tests/ir/derivative-op-ir-test.slang.expected.txt deleted file mode 100644 index 0545c08a1..000000000 --- a/tests/ir/derivative-op-ir-test.slang.expected.txt +++ /dev/null @@ -1,5 +0,0 @@ -type: float -1.0 -0.0 -2.0 -8.0
\ No newline at end of file |
