[AutoDiff upstream] Add forward-mode differentiation. (#30878)

JVP functions are forward-mode derivative functions. They take original
arguments and return original results and a differential function. Differential
functions take derivatives wrt arguments and return derivatives wrt results.

`JVPEmitter` is a cloner that emits JVP and differential functions at the same
time. In JVP functions, function applications are replaced with JVP function
applications. In differential functions, function applications are replaced
with differential function applications.

In JVP functions, each basic block takes a differential struct containing callee
differentials. These structs are consumed by differential functions.
This commit is contained in:
Dan Zheng
2020-04-08 11:29:21 -07:00
committed by GitHub
parent b5570a1aa9
commit 2eb460de4d
9 changed files with 1957 additions and 31 deletions

View File

@@ -449,6 +449,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_enable_experimental_additive_arithmetic_derivation))
Opts.EnableExperimentalAdditiveArithmeticDerivedConformances = true;
Opts.EnableExperimentalForwardModeDifferentiation |=
Args.hasArg(OPT_enable_experimental_forward_mode_differentiation);
Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
if (Opts.DebuggerSupport)
Opts.EnableDollarIdentifiers = true;