-
Notifications
You must be signed in to change notification settings - Fork 75
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
[TensorV2] Refactoring TensorBase pointer to shared_ptr #2428
[TensorV2] Refactoring TensorBase pointer to shared_ptr #2428
Conversation
This PR proposes refactoring the TensorV2 class to use a shared_ptr instead of a raw pointer for managing its TensorBase object. By adopting this change, we can improve the safety and reliability of our code and reduce the likelihood of memory leaks and other issues related to manual memory management. **Changes proposed in this PR:** - Replace the TensorBase pointer in the Tensor class with a shared_ptr. - Update any relevant code to use the shared_ptr instead of the raw pointer. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2428. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
@@ -79,14 +87,16 @@ TensorV2::TensorV2(const TensorDim &d, const void *buf) { | |||
TensorV2::TensorV2( | |||
std::vector<std::vector<std::vector<std::vector<float>>>> const &d, | |||
ml::train::TensorDim::TensorType t_type) { | |||
itensor = new FloatTensor(d, t_type.format); | |||
itensor = std::shared_ptr<FloatTensor>(new FloatTensor(d, t_type.format), | |||
std::default_delete<FloatTensor>()); | |||
} | |||
|
|||
#ifdef ENABLE_FP16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be removed according to our offline discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR resolves a bug that occurred after nnstreamer#2428 in the TensorV2 class when getting a shared data tensor, which shares memory. ** Self-evaluation** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
This PR resolves a bug that occurred after #2428 in the TensorV2 class when getting a shared data tensor, which shares memory. ** Self-evaluation** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
This PR resolves a bug that occurred after nnstreamer#2428 in the TensorV2 class when getting a shared data tensor, which shares memory. ** Self-evaluation** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
This PR proposes refactoring the TensorV2 class to use a shared_ptr instead of a raw pointer for managing its TensorBase object. By adopting this change, we can improve the safety and reliability of our code and reduce the likelihood of memory leaks and other issues related to manual memory management.
Changes proposed in this PR:
Self-evaluation: