[PyTorch] Save a refcount bump in make_variable#51180
Closed
swolchok wants to merge 1 commit intogh/swolchok/94/basefrom
Closed
[PyTorch] Save a refcount bump in make_variable#51180swolchok wants to merge 1 commit intogh/swolchok/94/basefrom
swolchok wants to merge 1 commit intogh/swolchok/94/basefrom
Conversation
This fast path still did a refcount bump because it copied the inner intrusive_ptr to the stack. Now it's moved. Differential Revision: [D26094951](https://our.internmc.facebook.com/intern/diff/D26094951/) [ghstack-poisoned]
Contributor
💊 CI failures summary and remediationsAs of commit 7e82d4c (more details on the Dr. CI page):
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
swolchok
added a commit
that referenced
this pull request
Jan 27, 2021
This fast path still did a refcount bump because it copied the inner intrusive_ptr to the stack. Now it's moved. Differential Revision: [D26094951](https://our.internmc.facebook.com/intern/diff/D26094951/) ghstack-source-id: 120460258 Pull Request resolved: #51180
dzhulgakov
reviewed
Jan 27, 2021
| return impl_; | ||
| } | ||
|
|
||
| c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl> unsafeReleaseIntrusivePtr() { |
Collaborator
There was a problem hiding this comment.
have you considered instead calling it
c10::intrusive_ptr<TensorImpl, UndefinedTensorImpl> getIntrusivePtr() && {
return std::move(impl_);
}
Then the call site can be std::move(data).getIntrusivePtr(). Not sure it's better but I've seen this pattern in other libraries (e.g. https://github.com/apache/arrow/blob/master/cpp/src/arrow/result.h#L84 )
Contributor
Author
There was a problem hiding this comment.
That would be inconsistent with unsafeReleaseTensorImpl(), above..
Codecov Report
@@ Coverage Diff @@
## gh/swolchok/94/base #51180 +/- ##
=======================================================
- Coverage 80.88% 80.88% -0.01%
=======================================================
Files 1929 1929
Lines 210519 210519
=======================================================
- Hits 170287 170282 -5
- Misses 40232 40237 +5 |
Contributor
|
This pull request has been merged in 1c8d11c. |
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Pull Request resolved: pytorch#51180 This fast path still did a refcount bump because it copied the inner intrusive_ptr to the stack. Now it's moved. ghstack-source-id: 120460258 Test Plan: 1) profile empty benchmark & inspect assembly to verify move 2) run framework overhead benchmarks Reviewed By: bhosmer Differential Revision: D26094951 fbshipit-source-id: b2e09f9ad885cb633402885ca1e61a370723f6b8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
This fast path still did a refcount bump because it copied the inner intrusive_ptr to the stack. Now it's moved.
Differential Revision: D26094951