Skip to content

Commit ecedfe4

Browse files
committed
[AutoDiff] Propagate '@nondiff' from AST function types to SIL function types.
This is to unblock `@differentiable` functions with `@nondiff` parameters. Once `SILDifferentiableFunctionType` in swiftlang#23482 lands, `@nondiff` should be nuked from SIL.
1 parent bbe43ed commit ecedfe4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/SIL/SILFunctionType.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,8 @@ class DestructureInputs {
832832
auto flags = params[i].getParameterFlags();
833833

834834
visit(flags.getValueOwnership(), /*forSelf=*/false,
835-
eltPattern, ty, silRepresentation);
835+
// SWIFT_ENABLE_TENSORFLOW
836+
eltPattern, ty, silRepresentation, flags.isNonDifferentiable());
836837
}
837838

838839
// Process the self parameter. Note that we implicitly drop self
@@ -853,7 +854,9 @@ class DestructureInputs {
853854

854855
void visit(ValueOwnership ownership, bool forSelf,
855856
AbstractionPattern origType, CanType substType,
856-
SILFunctionTypeRepresentation rep) {
857+
// SWIFT_ENABLE_TENSORFLOW
858+
SILFunctionTypeRepresentation rep,
859+
bool isNonDifferentiable = false) {
857860
assert(!isa<InOutType>(substType));
858861

859862
// Tuples get handled specially, in some cases:
@@ -902,7 +905,10 @@ class DestructureInputs {
902905
}
903906
auto loweredType = substTL.getLoweredType().getASTType();
904907

905-
Inputs.push_back(SILParameterInfo(loweredType, convention));
908+
// SWIFT_ENABLE_TENSORFLOW
909+
Inputs.push_back(SILParameterInfo(loweredType, convention)
910+
.getWithDifferentiability(
911+
SILParameterDifferentiability::NotDifferentiable));
906912

907913
maybeAddForeignParameters();
908914
}

0 commit comments

Comments
 (0)