Skip to content

[AutoDiff upstream] AST bits for @differentiable fn ty #28156

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
Nov 13, 2019

Conversation

marcrasi
Copy link

@marcrasi marcrasi commented Nov 8, 2019

Adds the AST bits necessary to represent @differentiable AnyFunctionType and SILFunctionType. Plumbs these bits through parsing and printing so that they can be tested. Adds serialization for them.

This resolves TF-871.

Intentionally omits any functionality based on these bits to keep this PR small. (e.g. typechecking that the @differentiable attr is allowed on the types; lowering @differentiable AnyFunctionType to the corresponding @differentiable SILFunctionType)

Copy link
Contributor

@lattner lattner left a comment

Choose a reason for hiding this comment

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

LG thanks!

@@ -3750,6 +3774,16 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
// Is this function guaranteed to be no-escape by the type system?
bool isNoEscape() const { return Bits & NoEscapeMask; }

bool isDifferentiable() const {
return getDifferentiabilityKind() >
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, but it seems like != would be more natural here than >

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

auto einfo = SILFunctionType::ExtInfo(representation,
flags.isPseudogeneric(),
!flags.isEscaping());
auto einfo = SILFunctionType::ExtInfo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a mangling for these flags? If so, it seems like it should be plumbed in here for the demangler to use.

Copy link
Author

@marcrasi marcrasi Nov 11, 2019

Choose a reason for hiding this comment

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

We've got some mangling in the tensorflow branch. I will upstream it in a separate PR. There is a ticket for that: https://bugs.swift.org/browse/TF-948

@marcrasi marcrasi force-pushed the diff-fn-ty-ast-bits branch from fbbde63 to 1b8b0bc Compare November 11, 2019 19:16
@marcrasi
Copy link
Author

@swift-ci please test and merge

@marcrasi marcrasi force-pushed the diff-fn-ty-ast-bits branch from 1b8b0bc to 40524de Compare November 12, 2019 18:25
@marcrasi
Copy link
Author

@swift-ci please test and merge

1 similar comment
@marcrasi
Copy link
Author

@swift-ci please test and merge

@marcrasi marcrasi force-pushed the diff-fn-ty-ast-bits branch from 40524de to 6413f43 Compare November 12, 2019 23:19
@marcrasi
Copy link
Author

@swift-ci please test and merge

2 similar comments
@marcrasi
Copy link
Author

@swift-ci please test and merge

@marcrasi
Copy link
Author

@swift-ci please test and merge

@swift-ci swift-ci merged commit 39fb55b into swiftlang:master Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants