Commit Graph

4 Commits

Author SHA1 Message Date
Richard Wei
ffe6064101 Mangle derivative functions and linear maps.
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen.
- `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature.

A mangled differentiation function name includes:
- The original function.
- The differentiation function kind.
- The parameter indices for differentiation.
- The result indices for differentiation.
- The derivative generic signature.
2021-01-07 02:21:10 -08:00
Michael Gottesman
25ebb5d763 [autodiff] When asserts are enabled, verify all autodiff compiler generated functions.
This ensures that any invalid SIL generated by these cloners is caught
immediately at the source when asserts are enabled improving productivity.
2020-11-29 23:44:31 -08:00
Dan Zheng
8f8639b071 [AutoDiff] NFC: Reimplement JVPCloner using pimpl pattern.
`JVPCloner.h` is now tiny: `JVPCloner` exposes only a `bool run()` entry point.

All of the implementation is moved to `JVPCloner::Implementation` in
`JVPCloner.cpp`. Methods can be defined directly in `JVPCloner.cpp` without
separate declarations.
2020-07-10 14:19:22 -07:00
Dan Zheng
ec5da7427b [AutoDiff] NFC: garden differentiation transform. (#32770)
Rename "emitters" to "cloners", for consistency:
- `JVPEmitter` -> `JVPCloner`
- `VJPEmitter` -> `VJPCloner`
- `PullbackEmitter` -> `PullbackCloner`

Improve `PullbackCloner` documentation.
- Document previously undocumented methods.
- Update outdated documentation.
  - For adjoint value accumulation helpers: rename "buffer access" occurrences to
    "address". Pullback generation no logner uses buffer accesses (`begin_apply`).
2020-07-08 19:26:36 -07:00