[AutoDiff] Enable differentiation of generic functions. (#22023)
- Relax differentiability diagnostic for generic functions.
- Previously, an error was emitted when attempting to differentiate any
generic function. Now, diagnose only functions with indirect
differentiation parameters/result.
- Propagate differentiation associated function generic signature throughout
differentiation pass.
- Change `PrimalGenCloner` to inherit `TypeSubstCloner`.
- Make primal value structs inherit primal function's generic parameters
and signature.
- Calculate correct substitution map for `PrimalGenCloner::visitApplyInst`.
Emit diagnostic when apply instruction's associated function (e.g. VJP)
has generic requirements unmet by the primal generic environment.
- Remap types in `AdjointEmitter`.
- Remove manual `@differentiable` attribute where clause conformance
requirement checks.
- `GenericSignatureBuilder` already performs checks so manual checks are
unnecessary.