From fc9cba5307d166f7fda3f7e2c8b5bed7b06fef54 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Mar 2023 22:17:34 -0700 Subject: Add `[CudaDeviceExport]` to allow exporting CUDA device functions. (#2708) * Add `[CudaDeviceExport]` to allow exporting CUDA device functions. * Fix. --------- Co-authored-by: Yong He --- tests/autodiff/cuda-kernel-export.slang | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/autodiff/cuda-kernel-export.slang (limited to 'tests') diff --git a/tests/autodiff/cuda-kernel-export.slang b/tests/autodiff/cuda-kernel-export.slang new file mode 100644 index 000000000..0db4d8cea --- /dev/null +++ b/tests/autodiff/cuda-kernel-export.slang @@ -0,0 +1,29 @@ +//DISABLED_TEST:SIMPLE: -target cuda -line-directive-mode none + +// Verify that we can output a cuda device function with [CudaDeviceExport]. +// Disabled until we have FileCheck. + +struct MixedType : IDifferentiable +{ + no_diff float noDiffField; + float field; +} + +[BackwardDifferentiable] +float f1(MixedType m) +{ + return 2.0 * m.field; +} + +[BackwardDifferentiable] +float f(MixedType m) +{ + MixedType m1 = { m.noDiffField, m.field }; + return f1(m1); +} + +[CudaDeviceExport] +void diffF(inout DifferentialPair m, float dout) +{ + __bwd_diff(f)(m, dout); +} -- cgit v1.2.3