Skip to content

Commit 97fcaef

Browse files
authored
Merge pull request #5083 from typhoonzero/fix_sparse_update_size
fix sparse update size
2 parents d18d75d + a2412ce commit 97fcaef

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

paddle/math/RowBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class RowBuffer {
6060
*/
6161
inline real* get(int row) const {
6262
if (preallocatedBuf_) {
63-
CHECK_LE((row + 1) * width_ * sizeof(real), preallocatedBuf_->getSize());
63+
CHECK_LE((row)*width_ * sizeof(real), preallocatedBuf_->getSize());
6464
return reinterpret_cast<real*>(preallocatedBuf_->getBuf()) + row * width_;
6565
} else {
6666
CHECK_LE((row + 1) * width_, rowStore_.size());

paddle/pserver/ParameterClient2.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ void ParameterClient2::sendParallel(int tid,
186186
parameter->getMat(recvParameterType).get());
187187
CHECK(recvMat);
188188
size_t width = parameter->getConfig().dims(1);
189+
// TODO(wuyi): need add lock here? may also cause resize.
189190
buf = recvMat->getLocalRow(block.begin_pos() / width);
190191
}
191192
/// sparse_id is not useful while receiving data since sparse data
@@ -265,9 +266,9 @@ void ParameterClient2::prepareSendData(
265266
uint64_t beginDim = 0;
266267
uint64_t endDim = 0;
267268

268-
// FIXME(typhoonzero): let it resize first
269-
prefetchMat->getLocalRow(nLocalBlocks + 1);
270-
sendMat->getLocalRow(nLocalBlocks + 1);
269+
// HACK(typhoonzero): let it resize first
270+
prefetchMat->getLocalRow(nLocalBlocks);
271+
sendMat->getLocalRow(nLocalBlocks);
271272

272273
for (size_t row = 0; row < nLocalBlocks; ++row) {
273274
int64_t blockId = localIndices[row]; // local row -> sparse row

0 commit comments

Comments
 (0)