mirror of
https://github.com/apple/swift.git
synced 2026-11-24 07:03:51 +01:00
When the original function, JVP, and VJP are statically known, create a
specialized version of the callee with these components propagated into
its body. It allows SILCombiner to fold
`differentiable_function_extract` of `differentiable_function`. The
differentiable function parameter is removed from the specialized
function signature, and call sites are updated accordingly.
```
// caller:
%df = differentiable_function [parameters 0] [results 0] %f with_derivative {%jvp, %vjp}
%r = apply %callee(%x, %df)
// callee(%x, %df):
%v = differentiable_function_extract [vjp] %df
%r = apply %v(%x)
// -->
// caller:
%r = apply %specialized_callee(%x)
// specialized_callee(%x):
%df = differentiable_function [parameters 0] [results 0] %f with_derivative {%jvp, %vjp}
%v = differentiable_function_extract [vjp] %df
%r = apply %v(%x)
```