Skip to content

[AutoDiff] Fix a 'partial_apply' leak caused by subset parameters thunks. #26384

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
Jul 28, 2019

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Jul 28, 2019

In ADContext::promoteToDifferentiableFunction when we emit a subset parameters thunk, the closure produced by emitAssociatedFunctionReference is not being used or released. This patch fixes that by releasing the closure.

In a future design, we should determine the actual parameter indices and whether thunking is needed before emitting an unused closure. This shall be addressed in a future patch.

A value leak checking test was added for protocols because this bug was originally discovered in eaplatanios/swift-ale#1 by using the newly split Layer protocol. However, value leak checking tests do not test for closure (partial_apply) leaks. The proper setup for catching closure leaks is moving AD before ownership stripping (#26157).

…nks.

In `ADContext::promoteToDifferentiableFunction` when we emit a subset parameters thunk, the closure produced by `emitAssociatedFunctionReference` is not being used or released. This patch fixes that by releasing the closure.

In a future design, we should determine the actual parameter indices and whether thunking is needed before emitting an unused closure. This shall be addressed in a future patch.

A value leak checking test was added for protocols because this bug was originally discovered in eaplatanios/swift-ale#1 by using the newly split `Layer` protocol. However, value leak checking tests do not test for closure (`partial_apply`) leaks. The proper setup for catching closure leaks is moving AD before ownership stripping (swiftlang#26157).
@rxwei rxwei added the tensorflow This is for "tensorflow" branch PRs. label Jul 28, 2019
@rxwei rxwei requested a review from dan-zheng July 28, 2019 13:45
@rxwei
Copy link
Contributor Author

rxwei commented Jul 28, 2019

@swift-ci please test tensorflow

@rxwei rxwei merged commit 0bf4460 into swiftlang:tensorflow Jul 28, 2019
@rxwei rxwei deleted the fix-subset-parameters-leak branch July 28, 2019 15:31
func vjpDefaultImpl(_ input: Input) -> (Output, (Self.Output.TangentVector) -> (Self.TangentVector, Self.Input.TangentVector)) {
return Swift.valueWithPullback(at: self, input) { (m, i) in m.requirement(i) }
func vjpDefaultImpl(_ input: Input)
-> (Output,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, missed wrong indentation.

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.

1 participant