Calculate base_score based on input labels for mae. (#8107)
Fit an intercept as base score for abs loss.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <dmlc/omp.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint> // std::int32_t
|
||||
#include <limits>
|
||||
#include <type_traits> // std::is_signed
|
||||
#include <vector>
|
||||
@@ -253,7 +254,7 @@ inline int32_t OmpGetNumThreads(int32_t n_threads) {
|
||||
* MaxStackSize, it will be allocated inside the stack. Otherwise, it will be
|
||||
* heap-allocated.
|
||||
*/
|
||||
template <typename T, size_t MaxStackSize>
|
||||
template <typename T, std::size_t MaxStackSize>
|
||||
class MemStackAllocator {
|
||||
public:
|
||||
explicit MemStackAllocator(size_t required_size) : required_size_(required_size) {
|
||||
@@ -278,11 +279,23 @@ class MemStackAllocator {
|
||||
T& operator[](size_t i) { return ptr_[i]; }
|
||||
T const& operator[](size_t i) const { return ptr_[i]; }
|
||||
|
||||
auto data() const { return ptr_; } // NOLINT
|
||||
auto data() { return ptr_; } // NOLINT
|
||||
std::size_t size() const { return required_size_; } // NOLINT
|
||||
|
||||
auto cbegin() const { return data(); } // NOLINT
|
||||
auto cend() const { return data() + size(); } // NOLINT
|
||||
|
||||
private:
|
||||
T* ptr_ = nullptr;
|
||||
size_t required_size_;
|
||||
T stack_mem_[MaxStackSize];
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Constant that can be used for initializing static thread local memory.
|
||||
*/
|
||||
std::int32_t constexpr DefaultMaxThreads() { return 128; }
|
||||
} // namespace common
|
||||
} // namespace xgboost
|
||||
|
||||
|
||||
Reference in New Issue
Block a user