meta.h 1.72 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
5
6
7
8
#ifndef LIGHTGBM_META_H_
#define LIGHTGBM_META_H_

#include <cstdint>

#include <limits>
#include <vector>
#include <functional>
Guolin Ke's avatar
Guolin Ke committed
9
#include <memory>
Guolin Ke's avatar
Guolin Ke committed
10
11
12
13
14

namespace LightGBM {

/*! \brief Type of data size, it is better to use signed type*/
typedef int32_t data_size_t;
15
16
17
18
19
20
21

// Enable following marco to use double for score_t
// #define SCORE_T_USE_DOUBLE

// Enable following marco to use double for label_t
// #define LABEL_T_USE_DOUBLE

22
/*! \brief Type of score, and gradients */
23
24
25
#ifdef SCORE_T_USE_DOUBLE
typedef double score_t;
#else
26
typedef float score_t;
27
28
29
30
31
32
33
34
#endif

/*! \brief Type of metadata, include weight and label */
#ifdef LABEL_T_USE_DOUBLE
typedef double label_t;
#else
typedef float label_t;
#endif
Guolin Ke's avatar
Guolin Ke committed
35

36
const score_t kMinScore = -std::numeric_limits<score_t>::infinity();
Guolin Ke's avatar
Guolin Ke committed
37

38
const score_t kEpsilon = 1e-15f;
Guolin Ke's avatar
Guolin Ke committed
39

Guolin Ke's avatar
Guolin Ke committed
40
const double kZeroThreshold = 1e-35f;
Guolin Ke's avatar
Guolin Ke committed
41

Guolin Ke's avatar
Guolin Ke committed
42
43

typedef int32_t comm_size_t;
Guolin Ke's avatar
Guolin Ke committed
44

Guolin Ke's avatar
Guolin Ke committed
45
using PredictFunction =
Guolin Ke's avatar
Guolin Ke committed
46
std::function<void(const std::vector<std::pair<int, double>>&, double* output)>;
Guolin Ke's avatar
Guolin Ke committed
47

Guolin Ke's avatar
Guolin Ke committed
48
49
50
51
52
53
typedef void(*ReduceFunction)(const char* input, char* output, int type_size, comm_size_t array_size);


typedef void(*ReduceScatterFunction)(char* input, comm_size_t input_size, int type_size,
                                     const comm_size_t* block_start, const comm_size_t* block_len, int num_block, char* output, comm_size_t output_size,
                                     const ReduceFunction& reducer);
ww's avatar
ww committed
54

Guolin Ke's avatar
Guolin Ke committed
55
56
typedef void(*AllgatherFunction)(char* input, comm_size_t input_size, const comm_size_t* block_start,
                                 const comm_size_t* block_len, int num_block, char* output, comm_size_t output_size);
ww's avatar
ww committed
57
58


Guolin Ke's avatar
Guolin Ke committed
59
60
#define NO_SPECIFIC (-1)

61
62
63
64
#if (_MSC_VER <= 1800)
#define __func__ __FUNCTION__
#endif

Guolin Ke's avatar
Guolin Ke committed
65
66
}  // namespace LightGBM

Guolin Ke's avatar
Guolin Ke committed
67
#endif   // LightGBM_META_H_