Skip to content

[AutoDiff upstream] Add TangentSpace. #29107

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

Conversation

dan-zheng
Copy link
Contributor

TangentSpace represents the tangent space of a type.

  • For Differentiable-conforming types:
    • The tangent space is the TangentVector associated type.
  • For tuple types:
    • The tangent space is a tuple of the elements' tangent space types, for the
      elements that have a tangent space.
  • For function types whose innermost result type has a tangent space:
    • The tangent space is the same function type, replacing the innermost
      result type with its tangent space type.
  • Other types have no tangent space.

TangentSpace is used to:

  • Compute the derivative function type of a given original function type.
  • Compute the type of tangent/adjoint values during automatic differentiation.

Progress towards TF-828: upstream @differentiable attribute type-checking.
@differentiable attribute type-checking mega-patch: #29091


Tests exist on tensorflow branch and will be upstreamed later.
Currently, not enough code has been upstreamed for meaningful testing.

@rxwei
Copy link
Contributor

rxwei commented Jan 10, 2020

For function types whose innermost result type has a tangent space:

  • The tangent space is the same function type, replacing the innermost
    result type with its tangent space type.

Function is a dead case that should be eliminated before upstreaming. Function's tangent space is AnyDerivative and will be implemented later.

@dan-zheng dan-zheng changed the title [AutoDiff] Add TangentSpace and TypeBase::getAutoDiffTangentSpace. [AutoDiff upstream] Add TangentSpace. Jan 10, 2020
`TangentSpace` represents the tangent space of a type.

- For `Differentiable`-conforming types:
  - The tangent space is the `TangentVector` associated type.
- For tuple types:
  - The tangent space is a tuple of the elements' tangent space types, for the
    elements that have a tangent space.
- Other types have no tangent space.

`TangentSpace` is used to:
- Compute the derivative function type of a given original function type.
- Compute the type of tangent/adjoint values during automatic differentiation.

Progress towards TF-828: upstream `@differentiable` attribute type-checking.
@dan-zheng dan-zheng force-pushed the autodiff-upstream-tangent-space branch from 60290a4 to 32514cc Compare January 10, 2020 21:59
@dan-zheng
Copy link
Contributor Author

Function is a dead case that should be eliminated before upstreaming. Function's tangent space is AnyDerivative and will be implemented later.

Thanks for the info! I've removed the Function case, could you please re-review?

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 60290a4214632e121a8d7d975eded0332982aeb8

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 60290a4214632e121a8d7d975eded0332982aeb8

@dan-zheng
Copy link
Contributor Author

dan-zheng commented Jan 12, 2020

macOS CI seems to have flaked (error when cloning sources). Retriggering.
@swift-ci Please smoke test macOS platform

@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test macOS platform

@dan-zheng dan-zheng merged commit a98fe74 into swiftlang:master Jan 12, 2020
@dan-zheng dan-zheng deleted the autodiff-upstream-tangent-space branch January 12, 2020 20:29
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