[BLOCKING] fix the issue with infrequent feature (#4045)
* fix the issue with infrequent feature * handle exception * use only 2 workers * address the comments
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <dmlc/base.h>
|
||||
#include <dmlc/data.h>
|
||||
#include <rabit/rabit.h>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
@@ -169,8 +170,16 @@ class SparsePage {
|
||||
inline Inst operator[](size_t i) const {
|
||||
const auto& data_vec = data.HostVector();
|
||||
const auto& offset_vec = offset.HostVector();
|
||||
size_t size;
|
||||
// in distributed mode, some partitions may not get any instance for a feature. Therefore
|
||||
// we should set the size as zero
|
||||
if (rabit::IsDistributed() && i + 1 >= offset_vec.size()) {
|
||||
size = 0;
|
||||
} else {
|
||||
size = offset_vec[i + 1] - offset_vec[i];
|
||||
}
|
||||
return {data_vec.data() + offset_vec[i],
|
||||
static_cast<Inst::index_type>(offset_vec[i + 1] - offset_vec[i])};
|
||||
static_cast<Inst::index_type>(size)};
|
||||
}
|
||||
|
||||
/*! \brief constructor */
|
||||
@@ -285,7 +294,6 @@ class SparsePage {
|
||||
auto& data_vec = data.HostVector();
|
||||
auto& offset_vec = offset.HostVector();
|
||||
offset_vec.push_back(offset_vec.back() + inst.size());
|
||||
|
||||
size_t begin = data_vec.size();
|
||||
data_vec.resize(begin + inst.size());
|
||||
if (inst.size() != 0) {
|
||||
|
||||
Reference in New Issue
Block a user