-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff] Enhance performance of custom derivatives lookup #76951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tagging @asl |
In swiftlang#58965, lookup for custom derivatives in non-primary source files was introduced. It required triggering delayed members parsing of nominal types in a file if the file was compiled with differential programming enabled. This patch introduces `CustomDerivativesRequest` to address the issue. We only parse delayed members if tokens `@` and `derivative` appear together inside skipped nominal type body (similar to how member operators are handled). Resolves swiftlang#60102
@swift-ci please test |
@slavapestov This implements your request from #58965 (comment) |
Would be glad to see feedback from everyone interested |
Also tagging @rxwei |
Would be glad to see feedback from everyone interested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I have one non-actionable comment, but let's go ahead and merge
if (onlyDerivatives) | ||
if (AbstractFunctionDecl *AFD = getDerivative()) | ||
CustomDerivatives.push_back(AFD); | ||
if (!onlyOperators && !onlyDerivatives && VD->hasName()) { | ||
TopLevelValues.add(VD); | ||
if (VD->getAttrs().hasAttribute<CustomAttr>()) | ||
MayHaveAuxiliaryDecls.push_back(VD); | ||
} | ||
if (AbstractFunctionDecl *AFD = getDerivative()) | ||
CustomDerivatives.push_back(AFD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a specific suggestion on how to improve it, but this logic was a little tangled before with onlyOperators
and now it's... really hard to sort through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing attention to this! I agree that the logic is pretty complicated and should be simplified somehow. I was also unable to quickly find a nice way to fix this, but I'll think of it and submit a subsequent PR once the refactoring of this function is ready.
@swift-ci please smoke test |
Kicking off CI once more just to be sure, then once it's green let's merge |
In #58965, lookup for custom derivatives in non-primary source files was
introduced. It required triggering delayed members parsing of nominal types in
a file if the file was compiled with differential programming enabled.
This patch introduces
CustomDerivativesRequest
to address the issue.We only parse delayed members if tokens
@
andderivative
appeartogether inside skipped nominal type body (similar to how member operators
are handled).
Resolves #60102