Make binary bin search reusable. (#6058)
* Move binary search row to hist util. * Remove dead code.
This commit is contained in:
@@ -34,7 +34,7 @@ namespace tree {
|
||||
* to avoid outliers, as the full reduction is reproducible on GPU with reduction tree.
|
||||
*/
|
||||
template <typename T>
|
||||
DEV_INLINE __host__ T CreateRoundingFactor(T max_abs, int n) {
|
||||
XGBOOST_DEV_INLINE __host__ T CreateRoundingFactor(T max_abs, int n) {
|
||||
T delta = max_abs / (static_cast<T>(1.0) - 2 * n * std::numeric_limits<T>::epsilon());
|
||||
|
||||
// Calculate ceil(log_2(delta)).
|
||||
@@ -53,20 +53,20 @@ struct Pair {
|
||||
GradientPair first;
|
||||
GradientPair second;
|
||||
};
|
||||
DEV_INLINE Pair operator+(Pair const& lhs, Pair const& rhs) {
|
||||
XGBOOST_DEV_INLINE Pair operator+(Pair const& lhs, Pair const& rhs) {
|
||||
return {lhs.first + rhs.first, lhs.second + rhs.second};
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
struct Clip : public thrust::unary_function<GradientPair, Pair> {
|
||||
static DEV_INLINE float Pclip(float v) {
|
||||
static XGBOOST_DEV_INLINE float Pclip(float v) {
|
||||
return v > 0 ? v : 0;
|
||||
}
|
||||
static DEV_INLINE float Nclip(float v) {
|
||||
static XGBOOST_DEV_INLINE float Nclip(float v) {
|
||||
return v < 0 ? abs(v) : 0;
|
||||
}
|
||||
|
||||
DEV_INLINE Pair operator()(GradientPair x) const {
|
||||
XGBOOST_DEV_INLINE Pair operator()(GradientPair x) const {
|
||||
auto pg = Pclip(x.GetGrad());
|
||||
auto ph = Pclip(x.GetHess());
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ template <typename GradientSumT>
|
||||
GradientSumT CreateRoundingFactor(common::Span<GradientPair const> gpair);
|
||||
|
||||
template <typename T>
|
||||
DEV_INLINE T TruncateWithRoundingFactor(T const rounding_factor, float const x) {
|
||||
XGBOOST_DEV_INLINE T TruncateWithRoundingFactor(T const rounding_factor, float const x) {
|
||||
return (rounding_factor + static_cast<T>(x)) - rounding_factor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user