"...git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "ba15a16abd4d3a0cb341335fccb0d56fc2e80cd1"
cuda_regression_objective.cpp 4.31 KB
Newer Older
1
2
3
4
5
6
/*!
 * Copyright (c) 2021 Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for
 * license information.
 */

7
#ifdef USE_CUDA
8
9
10
11
12
13
14
15
16

#include "cuda_regression_objective.hpp"

#include <string>
#include <vector>

namespace LightGBM {

CUDARegressionL2loss::CUDARegressionL2loss(const Config& config):
17
CUDARegressionObjectiveInterface<RegressionL2loss>(config) {}
18
19

CUDARegressionL2loss::CUDARegressionL2loss(const std::vector<std::string>& strs):
20
CUDARegressionObjectiveInterface<RegressionL2loss>(strs) {}
21

22
CUDARegressionL2loss::~CUDARegressionL2loss() {}
23
24

void CUDARegressionL2loss::Init(const Metadata& metadata, data_size_t num_data) {
25
  CUDARegressionObjectiveInterface<RegressionL2loss>::Init(metadata, num_data);
26
27
}

28
CUDARegressionL1loss::CUDARegressionL1loss(const Config& config):
29
CUDARegressionObjectiveInterface<RegressionL1loss>(config) {}
30
31

CUDARegressionL1loss::CUDARegressionL1loss(const std::vector<std::string>& strs):
32
CUDARegressionObjectiveInterface<RegressionL1loss>(strs) {}
33
34
35
36

CUDARegressionL1loss::~CUDARegressionL1loss() {}

void CUDARegressionL1loss::Init(const Metadata& metadata, data_size_t num_data) {
37
  CUDARegressionObjectiveInterface<RegressionL1loss>::Init(metadata, num_data);
38
39
40
41
42
43
44
45
46
47
48
  cuda_data_indices_buffer_.Resize(static_cast<size_t>(num_data));
  cuda_percentile_result_.Resize(1);
  if (cuda_weights_ != nullptr) {
    const int num_blocks = (num_data + GET_GRADIENTS_BLOCK_SIZE_REGRESSION - 1) / GET_GRADIENTS_BLOCK_SIZE_REGRESSION + 1;
    cuda_weights_prefix_sum_.Resize(static_cast<size_t>(num_data));
    cuda_weights_prefix_sum_buffer_.Resize(static_cast<size_t>(num_blocks));
    cuda_weight_by_leaf_buffer_.Resize(static_cast<size_t>(num_data));
  }
  cuda_residual_buffer_.Resize(static_cast<size_t>(num_data));
}

49
50

CUDARegressionHuberLoss::CUDARegressionHuberLoss(const Config& config):
51
CUDARegressionObjectiveInterface<RegressionHuberLoss>(config) {}
52
53

CUDARegressionHuberLoss::CUDARegressionHuberLoss(const std::vector<std::string>& strs):
54
CUDARegressionObjectiveInterface<RegressionHuberLoss>(strs) {}
55
56
57

CUDARegressionHuberLoss::~CUDARegressionHuberLoss() {}

58
59

CUDARegressionFairLoss::CUDARegressionFairLoss(const Config& config):
60
CUDARegressionObjectiveInterface<RegressionFairLoss>(config) {}
61
62

CUDARegressionFairLoss::CUDARegressionFairLoss(const std::vector<std::string>& strs):
63
CUDARegressionObjectiveInterface<RegressionFairLoss>(strs) {}
64
65
66
67

CUDARegressionFairLoss::~CUDARegressionFairLoss() {}


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
CUDARegressionPoissonLoss::CUDARegressionPoissonLoss(const Config& config):
CUDARegressionObjectiveInterface<RegressionPoissonLoss>(config) {}

CUDARegressionPoissonLoss::CUDARegressionPoissonLoss(const std::vector<std::string>& strs):
CUDARegressionObjectiveInterface<RegressionPoissonLoss>(strs) {}

CUDARegressionPoissonLoss::~CUDARegressionPoissonLoss() {}

void CUDARegressionPoissonLoss::Init(const Metadata& metadata, data_size_t num_data) {
  CUDARegressionObjectiveInterface<RegressionPoissonLoss>::Init(metadata, num_data);
  LaunchCheckLabelKernel();
}

double CUDARegressionPoissonLoss::LaunchCalcInitScoreKernel(const int class_id) const {
  return Common::SafeLog(CUDARegressionObjectiveInterface<RegressionPoissonLoss>::LaunchCalcInitScoreKernel(class_id));
}


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
CUDARegressionQuantileloss::CUDARegressionQuantileloss(const Config& config):
CUDARegressionObjectiveInterface<RegressionQuantileloss>(config) {}

CUDARegressionQuantileloss::CUDARegressionQuantileloss(const std::vector<std::string>& strs):
CUDARegressionObjectiveInterface<RegressionQuantileloss>(strs) {}

CUDARegressionQuantileloss::~CUDARegressionQuantileloss() {}

void CUDARegressionQuantileloss::Init(const Metadata& metadata, data_size_t num_data) {
  CUDARegressionObjectiveInterface<RegressionQuantileloss>::Init(metadata, num_data);
  cuda_data_indices_buffer_.Resize(static_cast<size_t>(num_data));
  cuda_percentile_result_.Resize(1);
  if (cuda_weights_ != nullptr) {
    const int num_blocks = (num_data + GET_GRADIENTS_BLOCK_SIZE_REGRESSION - 1) / GET_GRADIENTS_BLOCK_SIZE_REGRESSION + 1;
    cuda_weights_prefix_sum_.Resize(static_cast<size_t>(num_data));
    cuda_weights_prefix_sum_buffer_.Resize(static_cast<size_t>(num_blocks));
    cuda_weight_by_leaf_buffer_.Resize(static_cast<size_t>(num_data));
  }
  cuda_residual_buffer_.Resize(static_cast<size_t>(num_data));
}

107
108
}  // namespace LightGBM

109
#endif  // USE_CUDA