Implement slope for Pseduo-Huber. (#7727)
* Add objective and metric. * Some refactoring for CPU/GPU dispatching using linalg module.
This commit is contained in:
@@ -49,6 +49,8 @@ struct GenericParameter : public XGBoostParameter<GenericParameter> {
|
||||
*/
|
||||
int32_t Threads() const;
|
||||
|
||||
bool IsCPU() const { return gpu_id == kCpuId; }
|
||||
|
||||
// declare parameters
|
||||
DMLC_DECLARE_PARAMETER(GenericParameter) {
|
||||
DMLC_DECLARE_FIELD(seed).set_default(kDefaultSeed).describe(
|
||||
|
||||
@@ -545,8 +545,19 @@ using VectorView = TensorView<T, 1>;
|
||||
*/
|
||||
template <typename T>
|
||||
auto MakeVec(T *ptr, size_t s, int32_t device = -1) {
|
||||
using U = std::remove_const_t<std::remove_pointer_t<decltype(ptr)>> const;
|
||||
return linalg::TensorView<U, 1>{{ptr, s}, {s}, device};
|
||||
return linalg::TensorView<T, 1>{{ptr, s}, {s}, device};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto MakeVec(HostDeviceVector<T> *data) {
|
||||
return MakeVec(data->DeviceIdx() == -1 ? data->HostPointer() : data->DevicePointer(),
|
||||
data->Size(), data->DeviceIdx());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
auto MakeVec(HostDeviceVector<T> const *data) {
|
||||
return MakeVec(data->DeviceIdx() == -1 ? data->ConstHostPointer() : data->ConstDevicePointer(),
|
||||
data->Size(), data->DeviceIdx());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,10 @@ class Metric : public Configurable {
|
||||
* override this function to maintain internal configuration
|
||||
* \param out pointer to output JSON object
|
||||
*/
|
||||
void SaveConfig(Json*) const override {}
|
||||
void SaveConfig(Json* p_out) const override {
|
||||
auto& out = *p_out;
|
||||
out["name"] = String(this->Name());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief evaluate a specific metric
|
||||
|
||||
Reference in New Issue
Block a user