diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-07-21 16:28:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-21 13:28:22 -0700 |
| commit | b40b711f54748145ed1340f2a3aa626dcb42b699 (patch) | |
| tree | 5c63286c13d55c79b4f21f899e8e338393049f8f /tests/diagnostics | |
| parent | 32043a48b6503fe3e493082c33eac02865503031 (diff) | |
Fix data-flow analysis not propagating diff property through differentiable calls (#3010)
* Add test for nodiff diagnostic for non-diff call propagated through diff call
* Add logic to disambiguate calls to differentiable and non-differentiable methods
* Add expected results for test
* Simplify test
* Update slang-ir-check-differentiability.cpp
* Added comments for TreatAsDifferentiableExpr flavors
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/diagnostics')
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-4.slang | 30 | ||||
| -rw-r--r-- | tests/diagnostics/autodiff-data-flow-4.slang.expected | 8 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/diagnostics/autodiff-data-flow-4.slang b/tests/diagnostics/autodiff-data-flow-4.slang new file mode 100644 index 000000000..08fabf954 --- /dev/null +++ b/tests/diagnostics/autodiff-data-flow-4.slang @@ -0,0 +1,30 @@ +//DIAGNOSTIC_TEST:SIMPLE: + +float nonDiff(float x) +{ + return x; +} + +[Differentiable] +float f(float x) +{ + return x * x; +} + +[Differentiable] +float h(float x) +{ + float val = 0; + + // call to non-differentiable method + // (should error if the data-flow propagation works properly.) + // + float y = nonDiff(x); + + // call to a differentiable method, using the + // result of a non-differentiable call. + // + val = f(y); + + return val; +} diff --git a/tests/diagnostics/autodiff-data-flow-4.slang.expected b/tests/diagnostics/autodiff-data-flow-4.slang.expected new file mode 100644 index 000000000..69f5d8707 --- /dev/null +++ b/tests/diagnostics/autodiff-data-flow-4.slang.expected @@ -0,0 +1,8 @@ +result code = -1 +standard error = { +tests/diagnostics/autodiff-data-flow-4.slang(29): error 41020: derivative cannot be propagated through call to non-backward-differentiable function `nonDiff`, use 'no_diff' to clarify intention. + float y = nonDiff(x); + ^ +} +standard output = { +} |
