Skip to content

[AutoDiff upstream] Add @transpose attribute. #27545

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 6 commits into from
Dec 18, 2019
Merged

Conversation

saeta
Copy link
Contributor

@saeta saeta commented Oct 4, 2019

The @transpose(of:) attribute registers a function as a transpose of another
function. This patch adds the @transpose(of:) attribute definition, syntax,
parsing, and printing.

Resolves TF-827.


Examples:

extension FloatingPoint where Self: Differentiable {
    @transpose(of: +)
    static func transposeAdd(_ v: Self) -> (Self, Self) { (v, v) }

    @transpose(of: *, wrt: 0)
    @transpose(of: *, wrt: 1)
    static func transposeMultiply(lhs: Self, rhs: Self) -> Self { lhs * rhs }
}

The differentiable programming manifesto has more information and examples.


Note: this code is upstreamed from tensorflow branch.

Known todos and issues are referenced in comments:

  • Upstream @transpose attribute type-checking (TF-830, TF-1060).
  • Enable @transpose attribute serialization (TF-838).
  • Use module-qualified names instead of custom qualified name syntax/parsing
    (TF-1066).

We would like to upstream code and continue development on master, if that's acceptable!

@saeta saeta requested review from dan-zheng, beccadax, rxwei, marcrasi and bgogul and removed request for dan-zheng October 4, 2019 18:23
@dan-zheng dan-zheng requested review from lattner and DougGregor and removed request for marcrasi, bgogul and beccadax December 16, 2019 20:21
The `@transpose(of:)` attribute registers a function as a transpose of another
function. This patch adds the `@transpose(of:)` attribute definition, syntax,
parsing, and printing.

Resolves TF-827.

Todos:
- Type-checking (TF-830, TF-1060).
- Enable serialization (TF-838).
- Use module-qualified names instead of custom qualified name syntax/parsing
  (TF-1066).
@dan-zheng
Copy link
Contributor

I revived this PR to upstream the current state of tensorflow branch, it is now ready for review. cc @rxwei @lattner

The PR description tracks todos and known issues.

@dan-zheng dan-zheng changed the title [AutoDiff upstream] Introduce @transposing attribute. [AutoDiff upstream] Add @transpose attribute. Dec 16, 2019
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.

Nice!

@dan-zheng dan-zheng marked this pull request as ready for review December 17, 2019 20:05
dan-zheng added a commit to dan-zheng/swift-syntax that referenced this pull request Dec 17, 2019
Update gyb-generated files for `@transpose` attribute.
Friend PR: swiftlang/swift#27545
@dan-zheng
Copy link
Contributor

swiftlang/swift-syntax#189
@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c842fee

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c842fee

@dan-zheng
Copy link
Contributor

CI failed for test/IDE/complete_decl_attribute.swift but the test passes for me locally.
Perhaps a clean test is necessary, I'll try it now.

@dan-zheng
Copy link
Contributor

swiftlang/swift-syntax#189
@swift-ci Please clean test

Use it in both `Parser::canParseTypeIdentifier` and
`Parser::canParseBaseTypeForQualifiedDeclName`.
@dan-zheng dan-zheng requested a review from rintaro December 18, 2019 00:37
Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Parser/Syntax changes look good!

dan-zheng added a commit to dan-zheng/swift-syntax that referenced this pull request Dec 18, 2019
Update gyb-generated files for `@transpose` attribute.
Friend PR: swiftlang/swift#27545
@dan-zheng
Copy link
Contributor

swiftlang/swift-syntax#189
@swift-ci Please clean test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cd1400d

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cd1400d

@akyrtzi akyrtzi merged commit a9c9f26 into master Dec 18, 2019
@dan-zheng dan-zheng deleted the transposing-attr branch December 18, 2019 20:01
dan-zheng added a commit to dan-zheng/swift-syntax that referenced this pull request Apr 8, 2020
Update gyb-generated files for `@transpose` attribute.
Friend PR: swiftlang/swift#27545
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.

7 participants