Remove rabit dependency on public headers. (#6005)

This commit is contained in:
Jiaming Yuan 2020-08-13 08:26:20 +08:00 committed by GitHub
parent 12e3fb6a6c
commit 674c409e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -10,7 +10,6 @@
#include <dmlc/base.h>
#include <dmlc/data.h>
#include <dmlc/serializer.h>
#include <rabit/rabit.h>
#include <xgboost/base.h>
#include <xgboost/span.h>
#include <xgboost/host_device_vector.h>
@ -273,14 +272,7 @@ 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];
}
size_t size = offset_vec[i + 1] - offset_vec[i];
return {data_vec.data() + offset_vec[i],
static_cast<Inst::index_type>(size)};
}

View File

@ -9,7 +9,6 @@
#define XGBOOST_LEARNER_H_
#include <dmlc/any.h>
#include <rabit/rabit.h>
#include <xgboost/base.h>
#include <xgboost/feature_map.h>
#include <xgboost/predictor.h>
@ -63,7 +62,7 @@ struct XGBAPIThreadLocalEntry {
*
* \endcode
*/
class Learner : public Model, public Configurable, public rabit::Serializable {
class Learner : public Model, public Configurable, public dmlc::Serializable {
public:
/*! \brief virtual destructor */
~Learner() override;

View File

@ -519,5 +519,12 @@ TEST(Span, Empty) {
}
}
TEST(SpanDeathTest, Empty) {
std::vector<float> data(1, 0);
ASSERT_TRUE(data.data());
Span<float> s{data.data(), Span<float>::index_type(0)}; // ok to define 0 size span.
EXPECT_DEATH(s[0], "\\[xgboost\\] Condition .* failed.\n"); // not ok to use it.
}
} // namespace common
} // namespace xgboost