summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-09-21 14:00:48 -0700
committerGitHub <noreply@github.com>2023-09-21 14:00:48 -0700
commit5b2eb06816521cc0fcfe03258452560bd200002d (patch)
treedc06cc626ff0059dded3f4245f9309b3071ae94c /tests
parentaf8ce68e9fd7b6255b6e4e9e9524a285497116dc (diff)
Various slangpy fixes. (#3227)
* Make dynamic cast transparent through `IRAttributedType`. * Add [CUDAXxx] variant of attributes. * Support marshaling of vector types. * Wrap cuda kernels in `extern "C"` block. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/autodiff/modify-vector-param.slang35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/autodiff/modify-vector-param.slang b/tests/autodiff/modify-vector-param.slang
new file mode 100644
index 000000000..d6ddd7386
--- /dev/null
+++ b/tests/autodiff/modify-vector-param.slang
@@ -0,0 +1,35 @@
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+typedef float.Differential dfloat;
+
+struct Params
+{
+ float vv;
+}
+
+[Differentiable]
+float3 f(float3 x, uint2 v, Params p)
+{
+ v.x = 1 + int(p.vv);
+
+ x.y = x.x * x.x;
+ return x;
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ {
+ var dpa = diffPair(float3(4.0, 2.0, 3.0));
+ Params p;
+ p.vv = 0.0;
+ __bwd_diff(f)(dpa, uint2(1,2), p, float3(1.0,1.0,1.0));
+
+ // CHECK: 9.0
+ outputBuffer[0] = dpa.d.x; // Expect: 9.0
+ }
+}