swift
f8c773b8 - [AutoDiff] make diff_wit_fns instead of fn_refs (#28451)

Commit
5 years ago
[AutoDiff] make diff_wit_fns instead of fn_refs (#28451) # Main change The differentiation transform now looks up differentiability witnesses and creates `differentiable_witness_function` instructions (derivative function references) instead of looking up `[differentiable]` attributes and creating `function_ref` instructions. Differentiability witnesses are now used end-to-end, from SILGen to IRGen. - Runtime performance impact: none with `differentiability_witness_function` devirtualization, enabled with `-O`. (TF-994) - Compile-time performance impact: slight regressions, to be investigated. (TF-1013) # Related changes Some fixes were required to make the main change work properly. - `LinkEntity::SecondaryPointer` is now set to `nullptr` for the `DifferentiabilityWitness` case. Otherwise, the default wild pointer value messes up equality comparisons. - Handle `differentiable_witness_function` rewriting in LoadableByAddress. - This requires support for `differentiable_witness_function` with explicit lowered type, similar to `differentiable_function_extract`. - Do not canonicalize differentiability witness generic signatures. Otherwise, `τ` generic parameter types are printed in diagnostics, breaking some tests. - As a matter of principle, canonicalization is also unnecessary; only users that require canonical signatures should canonicalize. - Temporarily disable test/AutoDiff/differentiable_sil_attr_roundtrip.swift. - Round-trip SIL tests for external `@differentiable` functions are broken. - TF-988 tracks fixing this issue. - Move derivative lookup logic to SILOptimizer/Utils/DerivativeLookup.{h,cpp}. - Organizing code in separate files is incremental compilation and hiding private helper functions. - TF-993 tracks further organization of the Differentiation.cpp mega-file. # Next steps TF-866 is the master issue for retroactive derivative registration. - Remove `SILDifferentiableAttr`. (TF-898) - `SILDifferentiableAttr` is still used in the differentiation transform for: - Initial triggering of differentiation. - Middle-man for differentiability witness anonicalization. - `SILDifferentiableAttr` can be removed after these uses are rewritten. - Lift same-file-only derivative registration limitation. (TF-1021) - Simplify `@derivative` attribute type-checking and SILGen. (TF-835) - SILGen `@derivative` attributes directly to differentiability witnesses.
Author
marcrasi
Committer
Parents
Loading