| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <dmlc/registry.h> |
| 7 |
#include <xgboost/base.h> |
| 8 |
#include <xgboost/data.h> |
| 9 |
#include <xgboost/host_device_vector.h> |
| 10 |
#include <xgboost/model.h> |
| 11 |
|
| 12 |
#include <functional> |
| 13 |
#include <string> |
| 14 |
#include <utility> |
| 15 |
#include <vector> |
| 16 |
|
| 17 |
|
| 18 |
namespace xgboost { |
| 19 |
|
| 20 |
class Json; |
| 21 |
struct Context; |
| 22 |
|
| 23 |
namespace gbm { |
| 24 |
class GBLinearModel; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class LinearUpdater : public Configurable { |
| 31 |
protected: |
| 32 |
Context const* ctx_; |
| 33 |
|
| 34 |
public: |
| 35 |
|
| 36 |
~LinearUpdater() override = default; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
virtual void Configure( |
| 42 |
const std::vector<std::pair<std::string, std::string> >& args) = 0; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
virtual void Update(linalg::Matrix<GradientPair>* in_gpair, DMatrix* data, |
| 53 |
gbm::GBLinearModel* model, double sum_instance_weight) = 0; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
static LinearUpdater* Create(const std::string& name, Context const*); |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
struct LinearUpdaterReg |
| 66 |
: public dmlc::FunctionRegEntryBase<LinearUpdaterReg, |
| 67 |
std::function<LinearUpdater*()> > {}; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
#define XGBOOST_REGISTER_LINEAR_UPDATER(UniqueId, Name) \ |
| 73 |
static DMLC_ATTRIBUTE_UNUSED ::xgboost::LinearUpdaterReg& \ |
| 74 |
__make_##LinearUpdaterReg##_##UniqueId##__ = \ |
| 75 |
::dmlc::Registry< ::xgboost::LinearUpdaterReg>::Get()->__REGISTER__( \ |
| 76 |
Name) |
| 77 |
|
| 78 |
} |