swift
740b63ed - [AutoDiff] Introduce 'linear_function' and 'linear_function_extract' instructions. (#27637)

Commit
6 years ago
[AutoDiff] Introduce 'linear_function' and 'linear_function_extract' instructions. (#27637) Introduce `linear_function` and `linear_function_extract` instructions, which are used for creating and destructing `@differentiable(linear)` functions. ### `linear_function` instruction Bundles a function with its transpose function into a `@differentiable(linear)` function. ``` sil-instruction ::= 'linear_function' sil-linear-function-parameter-indices? sil-value ':' sil-type sil-linear-function-transpose-function-clause? sil-linear-function-parameter-indices ::= '[' 'parameters' [0-9]+ (' ' [0-9]+)* ']' sil-linear-transpose-function-clause ::= with_transpose sil-value ':' sil-type ``` ### `linear_function_extract` instruction Extracts the original function or a transpose function from the given ``@differentiable(linear)`` function. It must be provided with an extractee: ``[original]`` or ``[transpose]``. ``` sil-instruction ::= 'linear_function_extract' sil-linear-function-extractee sil-value ':' sil-type sil-linear-function-extractee ::= '[' sil-linear-function-extractee ']' sil-linear-function-extractee-name ::= 'original' | 'transpose' linear_function_extract [original] %0 : $@differentiable(linear) (T) -> T linear_function_extract [transpose] %0 : $@differentiable(linear) (T) -> T ``` Resolves [TF-907](https://bugs.swift.org/browse/TF-907).
Author
Parents
Loading