From 6fae15cd1210d8b664243d640e70ca47dccf9752 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 19 Jan 2023 08:58:20 -0800 Subject: Add diagnostic for calling non-bwd-diff func from bwd-diff func. (#2602) --- tests/diagnostics/autodiff-data-flow-2.slang | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/diagnostics/autodiff-data-flow-2.slang (limited to 'tests/diagnostics/autodiff-data-flow-2.slang') 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; +} -- cgit v1.2.3