Skip to content

[AutoDiff] Propagate '@nondiff' from AST function types to SIL function types. #23854

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 11 commits into from
Apr 11, 2019

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Apr 8, 2019

This is to unblock @differentiable functions with @nondiff parameters.

  • Propagate @nondiff from AST to SIL.
  • Add AnyFunctionType::getWithoutDifferentiability, which drops all @differentiable and @nondiff attributes from a function type.
  • Use autodiff parameter indices from function types now that @nondiff has been propagated.
  • Replace currying logic from SILFunctionType::getAssociatedFunctionType with lightweight logic that handles methods, which is needed for differentiable protocol requirements.
  • Emit an error when a @nondiff parameter is being differentiated with respect to.
  • Fix @nondiff AST printing.

Note:

Resolves TF-421.

…on types.

This is to unblock `@differentiable` functions with `@nondiff` parameters.

Once `SILDifferentiableFunctionType` in swiftlang#23482 lands, `@nondiff` should be nuked from SIL.
@rxwei rxwei added the tensorflow This is for "tensorflow" branch PRs. label Apr 8, 2019
@rxwei rxwei requested a review from dan-zheng April 8, 2019 10:46
@rxwei
Copy link
Contributor Author

rxwei commented Apr 8, 2019

@swift-ci please test tensorflow

Copy link
Contributor

@dan-zheng dan-zheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needle in a haystack change 😄

@dan-zheng
Copy link
Contributor

dan-zheng commented Apr 8, 2019

Crash:

swift: /home/swiftci/jenkins/workspace/swift-PR-TensorFlow-Linux/swift/lib/AST/ASTContext.cpp:4204: swift::SILFunctionType::SILFunctionType(swift::GenericSignature *, swift::SILFunctionType::ExtInfo, swift::SILCoroutineKind, swift::ParameterConvention, ArrayRefswift::SILParameterInfo, ArrayRefswift::SILYieldInfo, ArrayRefswift::SILResultInfo, Optionalswift::SILResultInfo, const swift::ASTContext &, swift::RecursiveTypeProperties, Optionalswift::ProtocolConformanceRef): Assertion `param.getDifferentiability() == SILParameterDifferentiability::DifferentiableOrNotApplicable && "non-differentiable function has NotDifferentiable parameter"' failed.

@rxwei
Copy link
Contributor Author

rxwei commented Apr 8, 2019

@swift-ci please test tensorflow

2 similar comments
@rxwei
Copy link
Contributor Author

rxwei commented Apr 8, 2019

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 8, 2019

@swift-ci please test tensorflow

@marcrasi
Copy link

@swift-ci please test tensorflow

@marcrasi
Copy link

@swift-ci please test tensorflow

3 similar comments
@marcrasi
Copy link

@swift-ci please test tensorflow

@marcrasi
Copy link

@swift-ci please test tensorflow

@marcrasi
Copy link

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

4 similar comments
@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

Fixed. Thanks @marcrasi for the help!

@rxwei
Copy link
Contributor Author

rxwei commented Apr 11, 2019

@swift-ci please test tensorflow

@rxwei rxwei merged commit 341bb33 into swiftlang:tensorflow Apr 11, 2019
@rxwei rxwei deleted the nondiff-sil branch April 11, 2019 07:15
rxwei added a commit to rxwei/swift that referenced this pull request May 11, 2019
…on types. (swiftlang#23854)

This is to unblock `@differentiable` functions with `@nondiff` parameters. 

- Propagate `@nondiff` from AST to SIL.
- Add `AnyFunctionType::getWithoutDifferentiability`, which drops all `@differentiable` and `@nondiff` attributes from a function type.
- Use autodiff parameter indices from function types now that `@nondiff` has been propagated.
- Replace currying logic from `SILFunctionType::getAssociatedFunctionType` with lightweight logic that handles methods, which is needed for differentiable protocol requirements.
- Emit an error when a `@nondiff` parameter is being differentiated with respect to.
- Fix `@nondiff` AST printing.

Note: 
- Once `SILDifferentiableFunctionType` in swiftlang#23482 lands, `@nondiff` should be nuked from SIL.
- Before merging, pull from the `tensorflow` branch to make sure swiftlang#23887 is merged.

Resolves [TF-421](https://bugs.swift.org/browse/TF-421).
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