diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autodiff/differentiable-constructor.slang | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/autodiff/differentiable-constructor.slang b/tests/autodiff/differentiable-constructor.slang new file mode 100644 index 000000000..8528f3792 --- /dev/null +++ b/tests/autodiff/differentiable-constructor.slang @@ -0,0 +1,38 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +interface IFoo : IDifferentiable +{ + [Differentiable] + __init(); + + float compute(float y); +} + +struct Impl : IFoo +{ + float x; + [Differentiable] + __init() + { + x = 4.0; + } + + float compute(int id) { return outputBuffer[id] = detach(x);} +} + +float test<T : IFoo>(int id) +{ + T t; + return t.compute(id); +} + +[numthreads(1, 1, 1)] +void computeMain(uint id : SV_DispatchThreadID) +{ + // CHECK: 4.0 + test<Impl>(id); +} |
