@@ -3234,27 +3234,22 @@ class VJPEmitter final
3234
3234
}
3235
3235
// This instruction is active. Determine the appropriate differentiation
3236
3236
// strategy, and use it.
3237
+ // Find the corresponding getter.
3238
+ auto *getterDecl = sei->getField ()->getGetter ();
3239
+ assert (getterDecl);
3240
+ auto *getterFn = getModule ().lookUpFunction (
3241
+ SILDeclRef (getterDecl, SILDeclRef::Kind::Func));
3237
3242
auto *structDecl = sei->getStructDecl ();
3238
- if (structDecl-> getEffectiveAccess () <= AccessLevel::Internal ||
3243
+ if (!getterFn ||
3239
3244
structDecl->getAttrs ().hasAttribute <FieldwiseDifferentiableAttr>()) {
3240
3245
strategies[sei] = StructExtractDifferentiationStrategy::Fieldwise;
3241
3246
SILClonerWithScopes::visitStructExtractInst (sei);
3242
3247
return ;
3243
3248
}
3244
3249
// The FieldwiseProductSpace strategy is not appropriate, so use the Getter
3245
3250
// strategy.
3251
+ assert (getterFn);
3246
3252
strategies[sei] = StructExtractDifferentiationStrategy::Getter;
3247
- // Find the corresponding getter and its VJP.
3248
- auto *getterDecl = sei->getField ()->getGetter ();
3249
- assert (getterDecl);
3250
- auto *getterFn = getModule ().lookUpFunction (
3251
- SILDeclRef (getterDecl, SILDeclRef::Kind::Func));
3252
- if (!getterFn) {
3253
- context.emitNondifferentiabilityError (
3254
- sei, invoker, diag::autodiff_property_not_differentiable);
3255
- errorOccurred = true ;
3256
- return ;
3257
- }
3258
3253
SILAutoDiffIndices indices (/* source*/ 0 ,
3259
3254
AutoDiffIndexSubset::getDefault (getASTContext (), 1 , true ));
3260
3255
auto *attr = context.lookUpDifferentiableAttr (getterFn, indices);
@@ -3304,27 +3299,22 @@ class VJPEmitter final
3304
3299
}
3305
3300
// This instruction is active. Determine the appropriate differentiation
3306
3301
// strategy, and use it.
3302
+ // Find the corresponding getter.
3303
+ auto *getterDecl = seai->getField ()->getGetter ();
3304
+ assert (getterDecl);
3305
+ auto *getterFn = getModule ().lookUpFunction (
3306
+ SILDeclRef (getterDecl, SILDeclRef::Kind::Func));
3307
3307
auto *structDecl = seai->getStructDecl ();
3308
- if (structDecl-> getEffectiveAccess () <= AccessLevel::Internal ||
3308
+ if (!getterFn ||
3309
3309
structDecl->getAttrs ().hasAttribute <FieldwiseDifferentiableAttr>()) {
3310
3310
strategies[seai] = StructExtractDifferentiationStrategy::Fieldwise;
3311
3311
SILClonerWithScopes::visitStructElementAddrInst (seai);
3312
3312
return ;
3313
3313
}
3314
3314
// The FieldwiseProductSpace strategy is not appropriate, so use the Getter
3315
3315
// strategy.
3316
+ assert (getterFn);
3316
3317
strategies[seai] = StructExtractDifferentiationStrategy::Getter;
3317
- // Find the corresponding getter and its VJP.
3318
- auto *getterDecl = seai->getField ()->getGetter ();
3319
- assert (getterDecl);
3320
- auto *getterFn = getModule ().lookUpFunction (
3321
- SILDeclRef (getterDecl, SILDeclRef::Kind::Func));
3322
- if (!getterFn) {
3323
- context.emitNondifferentiabilityError (
3324
- seai, invoker, diag::autodiff_property_not_differentiable);
3325
- errorOccurred = true ;
3326
- return ;
3327
- }
3328
3318
SILAutoDiffIndices indices (/* source*/ 0 ,
3329
3319
AutoDiffIndexSubset::getDefault (getASTContext (), 1 , true ));
3330
3320
auto *attr = context.lookUpDifferentiableAttr (getterFn, indices);
0 commit comments