meta.h 1.85 KB
Newer Older
1
2
3
4
/*!
 * Copyright (c) 2016 Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for license information.
 */
Guolin Ke's avatar
Guolin Ke committed
5
6
7
8
#ifndef LIGHTGBM_META_H_
#define LIGHTGBM_META_H_

#include <limits>
9
#include <cstdint>
Guolin Ke's avatar
Guolin Ke committed
10
#include <functional>
Guolin Ke's avatar
Guolin Ke committed
11
#include <memory>
12
13
#include <utility>
#include <vector>
Guolin Ke's avatar
Guolin Ke committed
14
15
16
17
18

namespace LightGBM {

/*! \brief Type of data size, it is better to use signed type*/
typedef int32_t data_size_t;
19

20
// Enable following macro to use double for score_t
21
22
// #define SCORE_T_USE_DOUBLE

23
// Enable following macro to use double for label_t
24
25
// #define LABEL_T_USE_DOUBLE

26
/*! \brief Type of score, and gradients */
27
28
29
#ifdef SCORE_T_USE_DOUBLE
typedef double score_t;
#else
30
typedef float score_t;
31
32
33
34
35
36
37
38
#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
39

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

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

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

Guolin Ke's avatar
Guolin Ke committed
46
47

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

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

Guolin Ke's avatar
Guolin Ke committed
52
53
54
55
56
57
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
58

Guolin Ke's avatar
Guolin Ke committed
59
60
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
61
62


Guolin Ke's avatar
Guolin Ke committed
63
64
#define NO_SPECIFIC (-1)

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

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