Skip to content

Fix tensorflow/swift-apis compilation. #24578

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

Merged
merged 1 commit into from
May 7, 2019

Conversation

dan-zheng
Copy link
Contributor

Remove problematic call to TC.conformsToProtocol on synthesized
AllDifferentiableVariables struct, which produced an ErrorType
and caused an IRGen assertion failure.

tensorflow/swift-apis now compiles.

Remove problematic call to `TC.conformsToProtocol` on synthesized
`AllDifferentiableVariables` struct, which produced an `ErrorType`
and caused an IRGen assertion failure.
@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label May 7, 2019
@dan-zheng dan-zheng requested review from rxwei and pschuh May 7, 2019 18:14
@dan-zheng
Copy link
Contributor Author

Testing something - please hold off from merging.

@dan-zheng
Copy link
Contributor Author

I tried moving the call to TC.conformsToProtocol(allDiffableVarsStruct->getDeclaredTypeInContext(), ...) below, after adding typealiases to allDiffableVarsStruct:

diff --git a/lib/Sema/DerivedConformanceDifferentiable.cpp b/lib/Sema/DerivedConformanceDifferentiable.cpp
index 9c43d03eb1..02d425d9c2 100644
--- a/lib/Sema/DerivedConformanceDifferentiable.cpp
+++ b/lib/Sema/DerivedConformanceDifferentiable.cpp
@@ -1130,6 +1130,12 @@ deriveDifferentiable_AssociatedStruct(DerivedConformance &derived,
         allDiffableVarsStruct, allDiffableVarsStruct, TC);
     addAssociatedTypeAliasDecl(C.Id_CotangentVector,
         allDiffableVarsStruct, allDiffableVarsStruct, TC);
+    // `AllDifferentiableVariables` must conform to `AdditiveArithmetic`.
+    // This should be guaranteed.
+    assert(TC.conformsToProtocol(
+               allDiffableVarsStruct->getDeclaredTypeInContext(), addArithProto,
+               parentDC, ConformanceCheckFlags::Used) &&
+           "`AllDifferentiableVariables` must conform to `AdditiveArithmetic`");
     addAssociatedTypeAliasDecl(C.Id_TangentVector,
         parentDC, allDiffableVarsStruct, TC);
     addAssociatedTypeAliasDecl(C.Id_CotangentVector,

I thought this might help fix the crash, but it didn't.

@dan-zheng dan-zheng merged commit 05fa41a into swiftlang:tensorflow-merge May 7, 2019
@dan-zheng dan-zheng deleted the tensorflow-merge branch May 7, 2019 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants