diff options
| author | Yong He <yonghe@outlook.com> | 2023-03-01 12:59:51 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-01 12:59:51 -0800 |
| commit | 6c26aa1f7e3e28e3053dffe686baa8e0499c624d (patch) | |
| tree | 4c7268615f1b880866498f2dff0ab580932bfb75 /tests | |
| parent | 3c32dd951c5d69b5568929e0038e693553efca79 (diff) | |
Improve diagnostic on differentiablitiy check. (#2687)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-3.slang | 13 | ||||
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-3.slang.expected | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/tests/diagnostics/autodiff-data-flow-3.slang b/tests/diagnostics/autodiff-data-flow-3.slang index 0a8e3e58a..21dd9f76c 100644 --- a/tests/diagnostics/autodiff-data-flow-3.slang +++ b/tests/diagnostics/autodiff-data-flow-3.slang @@ -18,9 +18,22 @@ float g(float x) } [BackwardDifferentiable] +void diffOut(inout float x) +{ + x = 2; +} + +float noDiffFunc(float x) +{ + return 0.0; +} + +[BackwardDifferentiable] float h(float x) { NoDiffField obj; obj.fp.f = detach(x * x); // OK. + obj.fp.f = noDiffFunc(x); // OK. + diffOut(obj.fp.f); // Error. return obj.fp.f; } diff --git a/tests/diagnostics/autodiff-data-flow-3.slang.expected b/tests/diagnostics/autodiff-data-flow-3.slang.expected index 73381cf58..817b595a6 100644 --- a/tests/diagnostics/autodiff-data-flow-3.slang.expected +++ b/tests/diagnostics/autodiff-data-flow-3.slang.expected @@ -1,8 +1,11 @@ result code = -1 standard error = { -tests/diagnostics/autodiff-data-flow-3.slang(16): error 41024: derivative is lost during assignment to non-differentiable location. Use 'detach()' to clarify intention. +tests/diagnostics/autodiff-data-flow-3.slang(16): error 41024: derivative is lost during assignment to non-differentiable location, use 'detach()' to clarify intention. obj.fp.f = x * x; // Error, this location cannot hold derivative. ^ +tests/diagnostics/autodiff-data-flow-3.slang(37): error 41025: derivative is lost when passing a non-differentiable location to an `out` or `inout` parameter, consider passing a temporary variable instead. + diffOut(obj.fp.f); // Error. + ^ } standard output = { } |
