diff options
| author | Yong He <yonghe@outlook.com> | 2023-01-19 08:58:20 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-19 08:58:20 -0800 |
| commit | 6fae15cd1210d8b664243d640e70ca47dccf9752 (patch) | |
| tree | d3235149f587ed18147f7a0d916932e199dce888 /tests | |
| parent | 0586f3298fa7d554fa2682103eefba88740d6758 (diff) | |
Add diagnostic for calling non-bwd-diff func from bwd-diff func. (#2602)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-2.slang | 28 | ||||
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-2.slang.expected | 8 | ||||
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow.slang.expected | 2 |
3 files changed, 37 insertions, 1 deletions
diff --git a/tests/diagnostics/autodiff-data-flow-2.slang b/tests/diagnostics/autodiff-data-flow-2.slang new file mode 100644 index 000000000..aa923c5d6 --- /dev/null +++ b/tests/diagnostics/autodiff-data-flow-2.slang @@ -0,0 +1,28 @@ +//DIAGNOSTIC_TEST:SIMPLE: + +float nonDiff(float x) +{ + return x; +} + +[ForwardDifferentiable] +float f(float x) +{ + return x * x; +} + +[BackwardDifferentiable] +float g(float x) +{ + float val = f(x + 1); // Error: f must also be backward-differentiable + return val; +} + +[BackwardDifferentiable] +float h(float x) +{ + float val = 0; + // no diagnostic by clarifying intention. + val = no_diff(f(x + 1)); + return val; +} diff --git a/tests/diagnostics/autodiff-data-flow-2.slang.expected b/tests/diagnostics/autodiff-data-flow-2.slang.expected new file mode 100644 index 000000000..9026c0748 --- /dev/null +++ b/tests/diagnostics/autodiff-data-flow-2.slang.expected @@ -0,0 +1,8 @@ +result code = -1 +standard error = { +tests/diagnostics/autodiff-data-flow-2.slang(18): error 41020: derivative cannot be propagated through call to non-backward-differentiable function `f`, use 'no_diff' to clarify intention. + float val = f(x + 1); // Error: f must also be backward-differentiable + ^ +} +standard output = { +} diff --git a/tests/diagnostics/autodiff-data-flow.slang.expected b/tests/diagnostics/autodiff-data-flow.slang.expected index 869ce42b3..290ef974b 100644 --- a/tests/diagnostics/autodiff-data-flow.slang.expected +++ b/tests/diagnostics/autodiff-data-flow.slang.expected @@ -1,6 +1,6 @@ result code = -1 standard error = { -tests/diagnostics/autodiff-data-flow.slang(15): error 41020: derivative cannot be propagated through call to non-differentiable function `nonDiff`, use 'no_diff' to clarify intention. +tests/diagnostics/autodiff-data-flow.slang(15): error 41020: derivative cannot be propagated through call to non-forward-differentiable function `nonDiff`, use 'no_diff' to clarify intention. val = nonDiff(x * 2.0f); ^ tests/diagnostics/autodiff-data-flow.slang(22): error 41021: a differentiable function must have at least one differentiable output. |
