[AutoDiff] Diagnose unsupported coroutine differentiation. #28921
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Coroutines are functions that can yield values and suspend/resume execution.
SIL has dedicated coroutine types. Coroutines are applied via
begin_apply
.The
read
andmodify
accessors are coroutines.Coroutine differentiation requires extra support, so it should be diagnosed
for now.
Differentiation transform:
ApplyInst
toFullApplySite
.bool isArrayLiteralIntrinsic(FullApplySite)
void forEachApplyDirectResult(FullApplySite, llvm::function_ref<...>)
apply
: direct result is theapply
result, unless theapply
resulthas tuple-type and a single
destructure_tuple
user. Then, direct resultsare the
destructure_tuple
results.begin_apply
: direct results are thebegin_apply
results.try_apply
: direct results are successor blocks' arguments.bool LinearMapInfo::shouldDifferentiateApplySite(FullApplySite)
ApplyInst
toFullApplySite
.FullApplySite
through direct/indirect results andinout
arguments.FullApplySite
through arguments.begin_apply
instructions with active arguments and results inPullbackEmitter::visitBeginApplyInst
.Sema:
@differentiable
attribute onread
andmodify
coroutines.Resolves TF-1081.
TF-1080 tracks coroutine differentiation support.
TF-1083 tracks throwing function differentiation support.
Example: