sparse_bin.cpp 2.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*!
 * Copyright (c) 2021 Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for
 * license information.
 */

#include "sparse_bin.hpp"

namespace LightGBM {

template <>
const void* SparseBin<uint8_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  std::vector<BinIterator*>* bin_iterator,
  const int num_threads) const {
  *is_sparse = true;
  *bit_type = 8;
  for (int thread_index = 0; thread_index < num_threads; ++thread_index) {
    bin_iterator->emplace_back(new SparseBinIterator<uint8_t>(this, 0));
  }
  return nullptr;
}

template <>
const void* SparseBin<uint16_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  std::vector<BinIterator*>* bin_iterator,
  const int num_threads) const {
  *is_sparse = true;
  *bit_type = 16;
  for (int thread_index = 0; thread_index < num_threads; ++thread_index) {
    bin_iterator->emplace_back(new SparseBinIterator<uint16_t>(this, 0));
  }
  return nullptr;
}

template <>
const void* SparseBin<uint32_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  std::vector<BinIterator*>* bin_iterator,
  const int num_threads) const {
  *is_sparse = true;
  *bit_type = 32;
  for (int thread_index = 0; thread_index < num_threads; ++thread_index) {
    bin_iterator->emplace_back(new SparseBinIterator<uint32_t>(this, 0));
  }
  return nullptr;
}

template <>
const void* SparseBin<uint8_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  BinIterator** bin_iterator) const {
  *is_sparse = true;
  *bit_type = 8;
  *bin_iterator = new SparseBinIterator<uint8_t>(this, 0);
  return nullptr;
}

template <>
const void* SparseBin<uint16_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  BinIterator** bin_iterator) const {
  *is_sparse = true;
  *bit_type = 16;
  *bin_iterator = new SparseBinIterator<uint16_t>(this, 0);
  return nullptr;
}

template <>
const void* SparseBin<uint32_t>::GetColWiseData(
  uint8_t* bit_type,
  bool* is_sparse,
  BinIterator** bin_iterator) const {
  *is_sparse = true;
  *bit_type = 32;
  *bin_iterator = new SparseBinIterator<uint32_t>(this, 0);
  return nullptr;
}

}  // namespace LightGBM