提交 a2412ce0 编写于 作者: T typhoonzero

fix sparse update size

上级 516f5472
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
*/ */
inline real* get(int row) const { inline real* get(int row) const {
if (preallocatedBuf_) { if (preallocatedBuf_) {
CHECK_LE((row + 1) * width_ * sizeof(real), preallocatedBuf_->getSize()); CHECK_LE((row)*width_ * sizeof(real), preallocatedBuf_->getSize());
return reinterpret_cast<real*>(preallocatedBuf_->getBuf()) + row * width_; return reinterpret_cast<real*>(preallocatedBuf_->getBuf()) + row * width_;
} else { } else {
CHECK_LE((row + 1) * width_, rowStore_.size()); CHECK_LE((row + 1) * width_, rowStore_.size());
......
...@@ -186,6 +186,7 @@ void ParameterClient2::sendParallel(int tid, ...@@ -186,6 +186,7 @@ void ParameterClient2::sendParallel(int tid,
parameter->getMat(recvParameterType).get()); parameter->getMat(recvParameterType).get());
CHECK(recvMat); CHECK(recvMat);
size_t width = parameter->getConfig().dims(1); size_t width = parameter->getConfig().dims(1);
// TODO(wuyi): need add lock here? may also cause resize.
buf = recvMat->getLocalRow(block.begin_pos() / width); buf = recvMat->getLocalRow(block.begin_pos() / width);
} }
/// sparse_id is not useful while receiving data since sparse data /// sparse_id is not useful while receiving data since sparse data
...@@ -265,9 +266,9 @@ void ParameterClient2::prepareSendData( ...@@ -265,9 +266,9 @@ void ParameterClient2::prepareSendData(
uint64_t beginDim = 0; uint64_t beginDim = 0;
uint64_t endDim = 0; uint64_t endDim = 0;
// FIXME(typhoonzero): let it resize first // HACK(typhoonzero): let it resize first
prefetchMat->getLocalRow(nLocalBlocks + 1); prefetchMat->getLocalRow(nLocalBlocks);
sendMat->getLocalRow(nLocalBlocks + 1); sendMat->getLocalRow(nLocalBlocks);
for (size_t row = 0; row < nLocalBlocks; ++row) { for (size_t row = 0; row < nLocalBlocks; ++row) {
int64_t blockId = localIndices[row]; // local row -> sparse row int64_t blockId = localIndices[row]; // local row -> sparse row
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册