Skip to content

[AD] Rewrite some of the tests with Tracked<Float> (2) #27767

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 12 commits into from
Oct 18, 2019

Conversation

bgogul
Copy link
Contributor

@bgogul bgogul commented Oct 17, 2019

Enable more leak checking for the AD tests: https://bugs.swift.org/browse/TF-895

@bgogul
Copy link
Contributor Author

bgogul commented Oct 17, 2019

@swift-ci please test tensorflow

@bgogul bgogul requested review from rxwei and dan-zheng and removed request for rxwei October 17, 2019 23:36
return pullback(at: x, in: f)(1)
// Differential operators for `Tracked<T>`.

public func gradient<T, U>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Differential operators in this file can actually be deleted once Tracked conforms to FloatingPoint. Were you working in this direction?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC,Tracked: FloatingPoint conformance caused * operator lookup for @differentiating(*) to become ambiguous.

That seems workaround-able by using @differentiable(vjp: ...) for now. We should probably investigate fixing @differentiating(*) ambiguous lookup (and @differentiating original declaration lookup for initializers/subscripts/properties) sometime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rxwei, yes it would be good to make Tracked conform to FloatingPoint, but have issues that Dan mentions. I had already filed a bug: https://bugs.swift.org/browse/TF-926

// MethodTests.testWithLeakChecking(
// "instance method with generated adjoint, wrt self and non-self"
// ) {
// let g = #gradient({ (p: Parameter, o: Tracked<Float>) in p.multiplied(with: o) })
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a comment: some tests are outdated:

  • Reference to outdated #gradient expression.
  • Reference to "adjoint" functions, which are now called "pullback "functions.
  • Deprecated comment; multiple @differentiable attributes are now possible:
  // There is currently no way to define multiple custom VJPs wrt different
  // parameters on the same func, so we define a copy of this func per adjoint.

Filed TF-929 to track updating outdated AutoDiff tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I generally did not make changes in the comments, but this should have slipped through.

return pullback(at: x, in: f)(1)
// Differential operators for `Tracked<T>`.

public func gradient<T, U>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Single gradient operator definitions for (...) -> Tracked<T> functions is great!
For reference: TF-927 tracks the confusing type-checker error we encountered this morning.

@bgogul bgogul merged commit e9bfd14 into swiftlang:tensorflow Oct 18, 2019
@bgogul bgogul deleted the ad_tracked_tests branch November 26, 2019 17:32
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