Implement extend method for meta info. (#5800)
* Implement extend for host device vector.
This commit is contained in:
@@ -158,6 +158,16 @@ class MetaInfo {
|
||||
*/
|
||||
void SetInfo(const char* key, std::string const& interface_str);
|
||||
|
||||
/*
|
||||
* \brief Extend with other MetaInfo.
|
||||
*
|
||||
* \param that The other MetaInfo object.
|
||||
*
|
||||
* \param accumulate_rows Whether rows need to be accumulated in this function. If
|
||||
* client code knows number of rows in advance, set this parameter to false.
|
||||
*/
|
||||
void Extend(MetaInfo const& that, bool accumulate_rows);
|
||||
|
||||
private:
|
||||
/*! \brief argsort of labels */
|
||||
mutable std::vector<size_t> label_order_cache_;
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
#include "span.h"
|
||||
|
||||
@@ -83,6 +84,8 @@ enum GPUAccess {
|
||||
|
||||
template <typename T>
|
||||
class HostDeviceVector {
|
||||
static_assert(std::is_standard_layout<T>::value, "HostDeviceVector admits only POD types");
|
||||
|
||||
public:
|
||||
explicit HostDeviceVector(size_t size = 0, T v = T(), int device = -1);
|
||||
HostDeviceVector(std::initializer_list<T> init, int device = -1);
|
||||
@@ -117,6 +120,8 @@ class HostDeviceVector {
|
||||
void Copy(const std::vector<T>& other);
|
||||
void Copy(std::initializer_list<T> other);
|
||||
|
||||
void Extend(const HostDeviceVector<T>& other);
|
||||
|
||||
std::vector<T>& HostVector();
|
||||
const std::vector<T>& ConstHostVector() const;
|
||||
const std::vector<T>& HostVector() const {return ConstHostVector(); }
|
||||
|
||||
Reference in New Issue
Block a user