mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Explicitly use minimal type expansion for autodiff-related types (e.g. parameters and pullback result types) (#77831)
As autodiff happens on function types it is not in general possible to determine the real expansion context of the function being differentiated. Use of minimal context is a conservative approach that should work even when libraty evolution mode is enabled. Fixes #55179
This commit is contained in:
committed by
GitHub
parent
e131682e19
commit
216111172e
@@ -215,12 +215,17 @@ private:
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
/// Get the type lowering for the given AST type.
|
||||
///
|
||||
/// Explicitly use minimal type expansion context: in general, differentiation
|
||||
/// happens on function types, so it cannot know if the original function is
|
||||
/// resilient or not.
|
||||
const Lowering::TypeLowering &getTypeLowering(Type type) {
|
||||
auto pbGenSig =
|
||||
getPullback().getLoweredFunctionType()->getSubstGenericSignature();
|
||||
Lowering::AbstractionPattern pattern(pbGenSig,
|
||||
type->getReducedType(pbGenSig));
|
||||
return getPullback().getTypeLowering(pattern, type);
|
||||
return getContext().getTypeConverter().getTypeLowering(
|
||||
pattern, type, TypeExpansionContext::minimal());
|
||||
}
|
||||
|
||||
/// Remap any archetypes into the current function's context.
|
||||
|
||||
Reference in New Issue
Block a user