Open junliangxing opened 9 years ago
There is a bug in Line 296-312 void DataHandler::LoadChunk(DataIterator& it, Matrix& mat, vector& random_rows) { float* data_ptr = mat.GetHostData(); int num_dims = it.GetDims(); int num_rand = (chunksize + random_access_chunksize - 1) / random_access_chunksize; int row, end; for (int i = 0; i < num_rand; i++) { row = random_rows[i]; end = (row + random_access_chunksize) % datasetsize; if (end < row) { it.Get(data_ptr, row, datasetsize); it.Get(data_ptr + num_dims * (datasetsize - row), 0, end); } else { it.Get(data_ptr, row, end); } data_ptr += num_dims * random_access_chunksize; } }
One possible way to fix it could be : void DataHandler::LoadChunk(DataIterator& it, Matrix& mat, vector& random_rows) { float* data_ptr = mat.GetHostData(); int num_dims = it.GetDims(); int num_rand = (chunksize + random_access_chunksize - 1) / random_access_chunksize; int row, end; for (int i = 0; i < num_rand; i++) { row = random_rows[i]; end = (row + random_access_chunksize) % datasetsize; if (end < row) { it.Get(data_ptr, row, datasetsize); int remain_size = random_access_chunksize - (datasetsize - row); if (remain_size > 0) { it.Get(data_ptr + num_dims * (datasetsize - row), 0, remain_size); } } else { it.Get(data_ptr, row, end); } data_ptr += num_dims * random_access_chunksize; } }
Thanks for pointing this about. This has been fixed now.
There is a bug in Line 296-312 void DataHandler::LoadChunk(DataIterator& it, Matrix& mat, vector& random_rows) {
float* data_ptr = mat.GetHostData();
int num_dims = it.GetDims();
int num_rand = (chunksize + random_access_chunksize - 1) / random_access_chunksize;
int row, end;
for (int i = 0; i < num_rand; i++) {
row = random_rows[i];
end = (row + random_access_chunksize) % datasetsize;
if (end < row) {
it.Get(data_ptr, row, datasetsize);
it.Get(data_ptr + num_dims * (datasetsize - row), 0, end);
} else {
it.Get(data_ptr, row, end);
}
data_ptr += num_dims * random_access_chunksize;
}
}
One possible way to fix it could be : void DataHandler::LoadChunk(DataIterator& it, Matrix& mat, vector& random_rows) {
float* data_ptr = mat.GetHostData();
int num_dims = it.GetDims();
int num_rand = (chunksize + random_access_chunksize - 1) / random_access_chunksize;
int row, end;
for (int i = 0; i < num_rand; i++) {
row = random_rows[i];
end = (row + random_access_chunksize) % datasetsize;
if (end < row) {
it.Get(data_ptr, row, datasetsize);
int remain_size = random_access_chunksize - (datasetsize - row);
if (remain_size > 0)
{
it.Get(data_ptr + num_dims * (datasetsize - row), 0, remain_size);
}
} else {
it.Get(data_ptr, row, end);
}
data_ptr += num_dims * random_access_chunksize;
}
}