cuda_binary_objective.hpp 1.74 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
8
#ifndef LIGHTGBM_SRC_OBJECTIVE_CUDA_CUDA_BINARY_OBJECTIVE_HPP_
#define LIGHTGBM_SRC_OBJECTIVE_CUDA_CUDA_BINARY_OBJECTIVE_HPP_
9

10
#ifdef USE_CUDA
11
12
13
14
15
16
17
18
19
20
21
22
23

#define GET_GRADIENTS_BLOCK_SIZE_BINARY (1024)
#define CALC_INIT_SCORE_BLOCK_SIZE_BINARY (1024)

#include <LightGBM/cuda/cuda_objective_function.hpp>

#include <string>
#include <vector>

#include "../binary_objective.hpp"

namespace LightGBM {

24
class CUDABinaryLogloss : public CUDAObjectiveInterface<BinaryLogloss> {
25
26
27
28
29
30
31
32
33
34
35
 public:
  explicit CUDABinaryLogloss(const Config& config);

  explicit CUDABinaryLogloss(const Config& config, const int ova_class_id);

  explicit CUDABinaryLogloss(const std::vector<std::string>& strs);

  ~CUDABinaryLogloss();

  void Init(const Metadata& metadata, data_size_t num_data) override;

36
37
  bool NeedConvertOutputCUDA() const override { return true; }

38
 private:
39
  void LaunchGetGradientsKernel(const double* scores, score_t* gradients, score_t* hessians) const override;
40

41
  double LaunchCalcInitScoreKernel(const int class_id) const override;
42

43
  const double* LaunchConvertOutputCUDAKernel(const data_size_t num_data, const double* input, double* output) const override;
44

45
  void LaunchResetOVACUDALabelKernel() const;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

  // CUDA memory, held by other objects
  const label_t* cuda_label_;
  label_t* cuda_ova_label_;
  const label_t* cuda_weights_;

  // CUDA memory, held by this object
  double* cuda_boost_from_score_;
  double* cuda_sum_weights_;
  double* cuda_label_weights_;
  const int ova_class_id_ = -1;
};

}  // namespace LightGBM

61
#endif  // USE_CUDA
62

63
#endif  // LIGHTGBM_SRC_OBJECTIVE_CUDA_CUDA_BINARY_OBJECTIVE_HPP_