-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff upstream] @derivative
attribute type-checking fixes.
#28853
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
[AutoDiff upstream] @derivative
attribute type-checking fixes.
#28853
Conversation
Could you also include the tests from #28785, which I just remembered to merge? |
// before extracting the differential/pullback type from it, so that the | ||
// derivative interface type generic signature is available for simplifying | ||
// types. | ||
CanType canActualResultType = derivativeInterfaceType->getCanonicalType(); |
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 wonder if it's possible to canonicalize derivativeInterfaceType
earlier, like:
- auto *derivativeInterfaceType = derivative->getInterfaceType()
- ->castTo<AnyFunctionType>();
+ auto derivativeInterfaceType = dyn_cast<AnyFunctionType>(
+ derivative->getInterfaceType()->getCanonicalType());
I tried this on tensorflow
branch but it didn't work out of the box:
/Users/danielzheng/swift-tf/swift/test/AutoDiff/derivative_attr_type_checking.swift:58:25: error: incorrect message found
Assertion failed: ((size_t)sys::locale::columnWidth(I->getText()) == I->getText().size()), function buildFixItLine, file /Users/danielzheng/swift-tf/llvm-project/llvm/lib/Support/SourceMgr.cpp, line 316.
I believe this error occurs when diagnostic messages contain archetypes (τ_0_0
). Filed TF-1073 to track this improvement.
})) | ||
return false; | ||
|
||
// If required result type is not a function type, check that result types | ||
// match exactly. | ||
auto requiredResultFnTy = dyn_cast<AnyFunctionType>(required.getResult()); | ||
auto candidateResultTy = mapType(candidateFnTy.getResult()); |
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 wonder if it's possible to remap candidateFnTy
once, instead of remapping its individual components.
Filed TF-1073 to track this improvement.
Upstream `@derivative` attribute type-checking fixes regarding derivative generic signatures with all concrete generic parameters. Cherry-picked from: - swiftlang#28762 - swiftlang#28772
7fd79ed
to
1d66571
Compare
@swift-ci Please test and merge |
Upstream
@derivative
attribute type-checking fixes regarding derivativegeneric signatures with all concrete generic parameters.
Cherry-picked from: