Remove rabit dependency on public headers. (#6005)
This commit is contained in:
parent
12e3fb6a6c
commit
674c409e9d
@ -10,7 +10,6 @@
|
|||||||
#include <dmlc/base.h>
|
#include <dmlc/base.h>
|
||||||
#include <dmlc/data.h>
|
#include <dmlc/data.h>
|
||||||
#include <dmlc/serializer.h>
|
#include <dmlc/serializer.h>
|
||||||
#include <rabit/rabit.h>
|
|
||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
#include <xgboost/span.h>
|
#include <xgboost/span.h>
|
||||||
#include <xgboost/host_device_vector.h>
|
#include <xgboost/host_device_vector.h>
|
||||||
@ -273,14 +272,7 @@ class SparsePage {
|
|||||||
inline Inst operator[](size_t i) const {
|
inline Inst operator[](size_t i) const {
|
||||||
const auto& data_vec = data.HostVector();
|
const auto& data_vec = data.HostVector();
|
||||||
const auto& offset_vec = offset.HostVector();
|
const auto& offset_vec = offset.HostVector();
|
||||||
size_t size;
|
size_t size = offset_vec[i + 1] - offset_vec[i];
|
||||||
// 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],
|
return {data_vec.data() + offset_vec[i],
|
||||||
static_cast<Inst::index_type>(size)};
|
static_cast<Inst::index_type>(size)};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
#define XGBOOST_LEARNER_H_
|
#define XGBOOST_LEARNER_H_
|
||||||
|
|
||||||
#include <dmlc/any.h>
|
#include <dmlc/any.h>
|
||||||
#include <rabit/rabit.h>
|
|
||||||
#include <xgboost/base.h>
|
#include <xgboost/base.h>
|
||||||
#include <xgboost/feature_map.h>
|
#include <xgboost/feature_map.h>
|
||||||
#include <xgboost/predictor.h>
|
#include <xgboost/predictor.h>
|
||||||
@ -63,7 +62,7 @@ struct XGBAPIThreadLocalEntry {
|
|||||||
*
|
*
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
class Learner : public Model, public Configurable, public rabit::Serializable {
|
class Learner : public Model, public Configurable, public dmlc::Serializable {
|
||||||
public:
|
public:
|
||||||
/*! \brief virtual destructor */
|
/*! \brief virtual destructor */
|
||||||
~Learner() override;
|
~Learner() override;
|
||||||
|
|||||||
@ -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 common
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user