Extract RowBuffer class for SparseRowMatrix.#863
Merged
reyoung merged 9 commits intoPaddlePaddle:developfrom Jan 18, 2017
Merged
Extract RowBuffer class for SparseRowMatrix.#863reyoung merged 9 commits intoPaddlePaddle:developfrom
reyoung merged 9 commits intoPaddlePaddle:developfrom
Conversation
* The original SparseRowMatrix use two fields to store each rows, which let code very confusing. Try to extract a RowBuffer class, for SparseRowMatrix data storage, and manage auto-growth logic.
dade0ec to
f63fbcd
Compare
hedaoyuan
requested changes
Dec 16, 2016
paddle/math/RowBuffer.h
Outdated
| */ | ||
| inline void resize(int rowCnt) { | ||
| if (preallocatedBuf_) { | ||
| CHECK(preallocatedBuf_->getSize() < rowCnt * width_ * sizeof(real)); |
|
|
||
| private: | ||
| CpuMemHandlePtr preallocatedBuf_; | ||
| std::vector<real, AlignedAllocator<real, 32>> rowStore_; |
Contributor
There was a problem hiding this comment.
rowStore_是不是直接用CpuMemoryHandle就可以了,只是resize greater的时候需要一次copy。
Collaborator
Author
There was a problem hiding this comment.
有道理,不过再下一个PR里面加吧。
加了一个TODO注释
paddle/math/RowBuffer.h
Outdated
| */ | ||
| inline size_t getRowCount() const { | ||
| if (preallocatedBuf_) { | ||
| return preallocatedBuf_->getSize() / sizeof(float) / width_; |
paddle/math/RowBuffer.h
Outdated
| * @brief get is this buffer can automatically grow or not. | ||
| * @return ture if can automacitally grow. | ||
| */ | ||
| inline bool isAutoGrowth() const { return preallocatedBuf_ == nullptr; } |
Contributor
There was a problem hiding this comment.
return !preallocatedBuf_;
hedaoyuan
approved these changes
Jan 16, 2017
zhhsplendid
pushed a commit
to zhhsplendid/Paddle
that referenced
this pull request
Sep 25, 2019
wangxicoding
pushed a commit
to wangxicoding/Paddle
that referenced
this pull request
Dec 9, 2021
* optimize the time cost for the wordtag * update the optimize code for the predictor
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.
which make code very confusing. Try to extract a RowBuffer class,
for SparseRowMatrix data storage, and manage auto-growth logic.