yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Harsh Aggarwal (NVIDIA)Enable CUDA Test Enablement - Batch 1: Autodiff Tests (1-16) (#8139)c3df36043

master
919 B44 linesraw
1//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly
2//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cuda -output-using-type
3
4//CHECK: 1.0 
5
6//TEST_INPUT: type_conformance Sensor:ISensor = 1;
7
8[anyValueSize(16)]
9interface ISensor
10{
11    [Differentiable]
12    float4 splat(float4 point);
13}
14
15struct Sensor : ISensor
16{
17    [Differentiable]
18    float4 splat(float4 point)
19    {
20        return point;
21    }
22}
23
24[Differentiable]
25float4 splat(ISensor* obj, float4 point)
26{
27    return obj->splat(point);
28}
29
30//TEST_INPUT: set s = ubuffer(data=[0 0 1 0 0 0 0 0])
31uniform ISensor *s;
32
33//TEST_INPUT: set outBuffer = out ubuffer(data=[0 0 0 0], stride=4)
34RWStructuredBuffer<float4> outBuffer;
35
36[shader("compute"), numthreads(1, 1, 1)]
37void computeMain(
38    uint3 id : SV_DispatchThreadID
39)
40{
41    DifferentialPair<float4> dp;
42    bwd_diff(splat)(s, dp, float4(1.0f));
43    outBuffer[id.x] = dp.d;
44}