-
Notifications
You must be signed in to change notification settings - Fork 25.8k
make THPPointer have explicit constructors #1636
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
Conversation
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
colesbury
reviewed
May 24, 2017
torch/csrc/utils.cpp
Outdated
| } | ||
|
|
||
| THLongStoragePtr THPUtils_unpackSize(PyObject *arg) { | ||
| THLongStorage* THPUtils_unpackSize(PyObject *arg) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/csrc/utils/object_ptr.h
Outdated
| THPPointer(): ptr(nullptr) {}; | ||
| THPPointer(T *ptr): ptr(ptr) {}; | ||
| THPPointer(THPPointer &&p) { free(); ptr = p.ptr; p.ptr = nullptr; }; | ||
| explicit THPPointer(): ptr(nullptr) {}; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Contributor
Author
|
@colesbury I think it was due to the fact that the move constructor had been marked explicit. By removing the keyword, I no longer need to pass the Tensor as a raw pointer return type in order for it to compile. |
soumith
approved these changes
May 25, 2017
jjsjann123
added a commit
to jjsjann123/pytorch
that referenced
this pull request
May 3, 2022
update CI tests with lintrunner to ensure format stuff are running in CI
jagadish-amd
pushed a commit
to jagadish-amd/pytorch
that referenced
this pull request
Oct 24, 2024
Improve performance for smaller shapes that use block radix sort by decreasing the item_per_thread to 8. This will increase the thread block size leading to higher occupancy. Co-author: @amd-sushetty --------- Co-authored-by: Pruthvi Madugundu <[email protected]>
jagadish-amd
pushed a commit
to jagadish-amd/pytorch
that referenced
this pull request
Jan 14, 2025
Improve performance for smaller shapes that use block radix sort by decreasing the item_per_thread to 8. This will increase the thread block size leading to higher occupancy. Co-author: @amd-sushetty --------- Co-authored-by: Pruthvi Madugundu <[email protected]> (cherry picked from commit 1024f36)
pytorch-bot bot
pushed a commit
that referenced
this pull request
Feb 24, 2025
Improve performance for smaller shapes that use block radix sort by decreasing the item_per_thread to 8. This will increase the thread block size leading to higher occupancy. Co-author: @amd-sushetty --------- Co-authored-by: Pruthvi Madugundu <[email protected]> (cherry picked from commit 1024f36)
pytorch-bot bot
pushed a commit
that referenced
this pull request
Feb 24, 2025
Improve performance for smaller shapes that use block radix sort by decreasing the item_per_thread to 8. This will increase the thread block size leading to higher occupancy. Co-author: @amd-sushetty --------- Co-authored-by: Pruthvi Madugundu <[email protected]> (cherry picked from commit 1024f36)
jagadish-amd
pushed a commit
to jagadish-amd/pytorch
that referenced
this pull request
May 8, 2025
Improve performance for smaller shapes that use block radix sort by decreasing the item_per_thread to 8. This will increase the thread block size leading to higher occupancy. Co-author: @amd-sushetty --------- Co-authored-by: Pruthvi Madugundu <[email protected]> (cherry picked from commit 1024f36) (cherry picked from commit 08c0749)
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.
Previously, THPPointer did not have its constructors marked as explicit. As a result, something like:
The fact that
THPTensortakes "ownership" of theTHTensorin this case is obfuscated, which could lead to double frees.This diff marks all the
THPTensorconstructors explicit, preventing this type of implicit constructor from a pointer. I followed it with the following codemod:To replace all assignment calls with calls to the explicit constructor. There were a couple of other places where I need to fix this, e.g. in the
THPPlugin.pyallocation template.Test Plan: Run Tests locally