@@ -878,7 +878,7 @@ class ADContext {
878
878
// / Saved for deletion during cleanup.
879
879
SmallVector<SILFunction *, 32 > generatedFunctions;
880
880
881
- // / List of associated function references, generated via
881
+ // / List of derivative function references, generated via
882
882
// / `emitDerivativeFunctionReference`.
883
883
// / Saved for deletion during cleanup.
884
884
SmallVector<SILValue, 32 > generatedDerivativeFunctionReferences;
@@ -1131,7 +1131,7 @@ class ADContext {
1131
1131
DifferentiationInvoker invoker);
1132
1132
1133
1133
// / Process the given `differentiable_function` instruction, filling in
1134
- // / missing associated functions if necessary.
1134
+ // / missing derivative functions if necessary.
1135
1135
bool processDifferentiableFunctionInst (DifferentiableFunctionInst *dfi);
1136
1136
1137
1137
// / Fold `differentiable_function_extract` users of the given
@@ -1145,27 +1145,27 @@ class ADContext {
1145
1145
// / purposes.
1146
1146
void foldDifferentiableFunctionExtraction (DifferentiableFunctionInst *source);
1147
1147
1148
- // / Get or create an associated function index subset thunk from
1149
- // / `actualIndices` to `desiredIndices` for the given associated function
1148
+ // / Get or create an derivative function index subset thunk from
1149
+ // / `actualIndices` to `desiredIndices` for the given derivative function
1150
1150
// / value and original function operand.
1151
1151
// / Calls `getOrCreateSubsetParametersThunkForLinearMap` to thunk the linear
1152
- // / map returned by the associated function.
1152
+ // / map returned by the derivative function.
1153
1153
std::pair<SILFunction *, SubstitutionMap>
1154
1154
getOrCreateSubsetParametersThunkForDerivativeFunction (
1155
1155
SILValue origFnOperand, SILValue assocFn,
1156
1156
AutoDiffDerivativeFunctionKind kind, SILAutoDiffIndices desiredIndices,
1157
1157
SILAutoDiffIndices actualIndices);
1158
1158
1159
- // / Get or create an associated function index subset thunk from
1160
- // / `actualIndices` to `desiredIndices` for the given associated function
1159
+ // / Get or create an derivative function index subset thunk from
1160
+ // / `actualIndices` to `desiredIndices` for the given derivative function
1161
1161
// / value and original function operand.
1162
1162
SILFunction *getOrCreateSubsetParametersThunkForLinearMap (
1163
1163
SILFunction *assocFn, CanSILFunctionType linearMapType,
1164
1164
CanSILFunctionType targetType, AutoDiffDerivativeFunctionKind kind,
1165
1165
SILAutoDiffIndices desiredIndices, SILAutoDiffIndices actualIndices);
1166
1166
1167
1167
public:
1168
- // / Declare an external reference to an associated function of `original`,
1168
+ // / Declare an external reference to an derivative function of `original`,
1169
1169
// / given a `[differentiable]` attribute of `original` and the associated
1170
1170
// / function kind.
1171
1171
SILFunction *
@@ -1705,7 +1705,7 @@ void LinearMapInfo::generateDifferentiationDataStructures(
1705
1705
auto *loopAnalysis = context.getPassManager ().getAnalysis <SILLoopAnalysis>();
1706
1706
auto *loopInfo = loopAnalysis->get (original);
1707
1707
1708
- // Get the associated function generic signature.
1708
+ // Get the derivative function generic signature.
1709
1709
CanGenericSignature assocFnGenSig = nullptr ;
1710
1710
if (auto *assocFnGenEnv = assocFn->getGenericEnvironment ())
1711
1711
assocFnGenSig =
@@ -2530,9 +2530,9 @@ static SubstitutionMap getSubstitutionMap(
2530
2530
return substMap;
2531
2531
}
2532
2532
2533
- // / Emits a reference to an associated function of `original`, differentiated
2533
+ // / Emits a reference to an derivative function of `original`, differentiated
2534
2534
// / with respect to a superset of `desiredIndices`. Returns the `SILValue` for
2535
- // / the associated function and the actual indices that the associated function
2535
+ // / the derivative function and the actual indices that the derivative function
2536
2536
// / is with respect to.
2537
2537
// /
2538
2538
// / Returns `None` on failure, signifying that a diagnostic has been emitted.
@@ -2554,15 +2554,15 @@ emitDerivativeFunctionReference(
2554
2554
2555
2555
// If `original` is itself an `DifferentiableFunctionExtractInst` whose kind matches
2556
2556
// the given kind and desired differentiation parameter indices, simply
2557
- // extract the associated function of its function operand, retain the
2558
- // associated function, and return it.
2557
+ // extract the derivative function of its function operand, retain the
2558
+ // derivative function, and return it.
2559
2559
if (auto *inst = original->getDefiningInstruction ())
2560
2560
if (auto *dfei = dyn_cast<DifferentiableFunctionExtractInst>(inst))
2561
2561
if (dfei->getExtractee () == DifferentiableFunctionExtractee::Original)
2562
2562
functionSource = dfei->getFunctionOperand ();
2563
2563
2564
2564
// If `functionSource` is a `@differentiable` function, just extract the
2565
- // associated function.
2565
+ // derivative function.
2566
2566
if (auto diffableFnType =
2567
2567
functionSource->getType ().castTo <SILFunctionType>()) {
2568
2568
if (diffableFnType->isDifferentiable ()) {
@@ -2711,7 +2711,7 @@ emitDerivativeFunctionReference(
2711
2711
diag::autodiff_member_subset_indices_not_differentiable);
2712
2712
return None;
2713
2713
}
2714
- // Emit a `witness_method` instruction for the associated function.
2714
+ // Emit a `witness_method` instruction for the derivative function.
2715
2715
auto originalType = witnessMethod->getType ().castTo <SILFunctionType>();
2716
2716
auto assocType = originalType->getAutoDiffDerivativeFunctionType (
2717
2717
minimalIndices.parameters , minimalIndices.source ,
@@ -2758,7 +2758,7 @@ emitDerivativeFunctionReference(
2758
2758
diag::autodiff_member_subset_indices_not_differentiable);
2759
2759
return None;
2760
2760
}
2761
- // Emit a `class_method` instruction for the associated function.
2761
+ // Emit a `class_method` instruction for the derivative function.
2762
2762
auto originalType = classMethodInst->getType ().castTo <SILFunctionType>();
2763
2763
auto assocType = originalType->getAutoDiffDerivativeFunctionType (
2764
2764
minimalIndices.parameters , minimalIndices.source ,
@@ -7980,7 +7980,7 @@ bool ADContext::processDifferentiableAttribute(
7980
7980
attr->setJVPName (jvpName);
7981
7981
}
7982
7982
7983
- // If differentiation is triggered by `[differentiable]`, associated function
7983
+ // If differentiation is triggered by `[differentiable]`, derivative function
7984
7984
// should share linkage of original function.
7985
7985
auto isAssocFnExported =
7986
7986
invoker.getKind () ==
@@ -8334,7 +8334,7 @@ ADContext::getOrCreateSubsetParametersThunkForDerivativeFunction(
8334
8334
AutoDiffDerivativeFunctionKind kind, SILAutoDiffIndices desiredIndices,
8335
8335
SILAutoDiffIndices actualIndices) {
8336
8336
LLVM_DEBUG (getADDebugStream ()
8337
- << " Getting a subset parameters thunk for associated function "
8337
+ << " Getting a subset parameters thunk for derivative function "
8338
8338
<< assocFn << " of the original function " << origFnOperand
8339
8339
<< " from " << actualIndices << " to " << desiredIndices << ' \n ' );
8340
8340
@@ -8441,7 +8441,7 @@ ADContext::getOrCreateSubsetParametersThunkForDerivativeFunction(
8441
8441
loc, classOperand, assocMethodInst->getMember (),
8442
8442
thunk->mapTypeIntoContext (assocMethodInst->getType ()));
8443
8443
}
8444
- assert (assocRef && " Expected associated function to be resolved" );
8444
+ assert (assocRef && " Expected derivative function to be resolved" );
8445
8445
8446
8446
assocSubstMap = assocSubstMap.subst (thunk->getForwardingSubstitutionMap ());
8447
8447
assocFnType = assocRef->getType ().castTo <SILFunctionType>();
@@ -8592,7 +8592,7 @@ SILValue ADContext::promoteToDifferentiableFunction(
8592
8592
getGeneratedDerivativeFunctionReferences ().push_back (assocFn);
8593
8593
8594
8594
// If desired indices are a subset of actual indices, create a "subset
8595
- // indices thunk" and destroy the emitted associated function reference.
8595
+ // indices thunk" and destroy the emitted derivative function reference.
8596
8596
// - For JVPs: the thunked JVP returns a differential taking fewer
8597
8597
// parameters (using `.zero` for the dropped parameters).
8598
8598
// - For VJPs: the thunked VJP returns a pullback that drops the unused
@@ -8606,7 +8606,7 @@ SILValue ADContext::promoteToDifferentiableFunction(
8606
8606
getASTContext (), actualIndices.parameters ->getCapacity ());
8607
8607
if (actualIndices.source != desiredIndices.source ||
8608
8608
!actualIndices.parameters ->equals (extendedDesiredIndices)) {
8609
- // Destroy the already emitted associated function reference because it
8609
+ // Destroy the already emitted derivative function reference because it
8610
8610
// is no longer used.
8611
8611
builder.emitDestroyValueOperation (loc, assocFn);
8612
8612
// Check if underlying original function reference has been partially
@@ -8661,7 +8661,7 @@ SILValue ADContext::promoteToDifferentiableFunction(
8661
8661
8662
8662
assocFns.push_back (assocFn);
8663
8663
}
8664
- // Deallocate temporary buffers used for creating associated functions.
8664
+ // Deallocate temporary buffers used for creating derivative functions.
8665
8665
for (auto *buf : reversed (newBuffersToDealloc))
8666
8666
builder.createDeallocStack (loc, buf);
8667
8667
@@ -8701,7 +8701,7 @@ void ADContext::foldDifferentiableFunctionExtraction(
8701
8701
dfei->eraseFromParent ();
8702
8702
continue ;
8703
8703
}
8704
- // Fold associated function extractors.
8704
+ // Fold derivative function extractors.
8705
8705
auto assocFnValue =
8706
8706
source->getDerivativeFunction (dfei->getDerivativeFunctionKind ());
8707
8707
dfei->replaceAllUsesWith (assocFnValue);
0 commit comments