CMS 3D CMS Logo

Namespaces | Classes | Enumerations | Functions
nnet Namespace Reference

Namespaces

 product
 

Classes

struct  activ_config
 
struct  dense_config
 
struct  layer_config
 
class  Op_add
 
class  Op_and
 
class  Op_max
 
class  Op_min
 
class  Op_or
 

Enumerations

enum  io_type { io_parallel = 0, io_serial, io_parallel = 0, io_stream }
 
enum  io_type { io_parallel = 0, io_serial, io_parallel = 0, io_stream }
 
enum  strategy { latency, resource }
 

Functions

template<class data_T , class res_T , typename CONFIG_T >
std::enable_if< std::is_same< data_T, ap_uint< 1 > >::value &&std::is_same< typename CONFIG_T::weight_t, ap_uint< 1 > >::value, ap_int< nnet::ceillog2(CONFIG_T::n_in)+2 > >::type cast (typename CONFIG_T::accum_t x)
 
template<class data_T , class res_T , typename CONFIG_T >
std::enable_if< std::is_same< data_T, ap_uint< 1 > >::value &&!std::is_same< typename CONFIG_T::weight_t, ap_uint< 1 > >::value, res_T >::type cast (typename CONFIG_T::accum_t x)
 
template<class data_T , class res_T , typename CONFIG_T >
std::enable_if<(!std::is_same< data_T, ap_uint< 1 >>::value), res_T >::type cast (typename CONFIG_T::accum_t x)
 
constexpr int ceillog2 (int x)
 
template<class data_T , class res_T , typename CONFIG_T >
void compute_layer (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_out], typename CONFIG_T::weight_t weights[CONFIG_T::n_in *CONFIG_T::n_out], typename CONFIG_T::bias_t biases[CONFIG_T::n_out])
 
template<class data_T , class res_T , typename CONFIG_T >
void dense (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_out], typename CONFIG_T::weight_t weights[CONFIG_T::n_in *CONFIG_T::n_out], typename CONFIG_T::bias_t biases[CONFIG_T::n_out])
 
float exp_fcn_float (float input)
 
template<typename CONFIG_T , int N_TABLE>
void init_exp_table (typename CONFIG_T::table_t table_out[N_TABLE])
 
template<typename CONFIG_T , int N_TABLE>
void init_invert_table (typename CONFIG_T::table_t table_out[N_TABLE])
 
template<class res_T , typename CONFIG_T , int N_TABLE>
void init_sigmoid_table (res_T table_out[N_TABLE])
 
template<typename CONFIG_T , int N_TABLE>
void init_tanh_table (typename CONFIG_T::table_t table_out[N_TABLE])
 
template<class data_T , class res_T , typename CONFIG_T >
void linear (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class data_T , class res_T , typename CONFIG_T >
void relu (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class data_T , class res_T , typename CONFIG_T >
void relu6 (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class data_T , class res_T , int MAX_INT, typename CONFIG_T >
void relu_max (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class data_T , class res_T , typename CONFIG_T >
void sigmoid (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class out_T >
out_T sigmoid_fcn_float (float input)
 
template<class data_T , class res_T , typename CONFIG_T >
void softmax (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 
template<class data_T , class res_T , typename CONFIG_T >
void tanh (data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
 

Enumeration Type Documentation

◆ io_type [1/2]

Enumerator
io_parallel 
io_serial 
io_parallel 
io_stream 

Definition at line 17 of file nnet_common.h.

◆ io_type [2/2]

Enumerator
io_parallel 
io_serial 
io_parallel 
io_stream 

Definition at line 28 of file nnet_common.h.

◆ strategy

Enumerator
latency 
resource 

Definition at line 18 of file nnet_common.h.

Function Documentation

◆ cast() [1/3]

template<class data_T , class res_T , typename CONFIG_T >
std::enable_if<std::is_same<data_T, ap_uint<1> >::value && std::is_same<typename CONFIG_T::weight_t, ap_uint<1> >::value, ap_int<nnet::ceillog2(CONFIG_T::n_in) + 2> >::type nnet::cast ( typename CONFIG_T::accum_t  x)
inline

Definition at line 88 of file nnet_mult.h.

References ceillog2(), and x.

Referenced by edm::cmspybind11::readPSetsFrom(), reco::parser::AnyMethodArgumentFixup::retOk_(), and edm::toPython11List().

88  {
89  return (ap_int<nnet::ceillog2(CONFIG_T::n_in) + 2>)(x - CONFIG_T::n_in / 2) * 2;
90  }
constexpr int ceillog2(int x)
Definition: nnet_mult.h:10
float x

◆ cast() [2/3]

template<class data_T , class res_T , typename CONFIG_T >
std::enable_if<std::is_same<data_T, ap_uint<1> >::value && !std::is_same<typename CONFIG_T::weight_t, ap_uint<1> >::value, res_T>::type nnet::cast ( typename CONFIG_T::accum_t  x)
inline

Definition at line 96 of file nnet_mult.h.

References x.

96  {
97  return (res_T)x;
98  }
float x

◆ cast() [3/3]

template<class data_T , class res_T , typename CONFIG_T >
std::enable_if<(!std::is_same<data_T, ap_uint<1>>::value), res_T>::type nnet::cast ( typename CONFIG_T::accum_t  x)
inline

Definition at line 101 of file nnet_mult.h.

References x.

102  {
103  return (res_T)x;
104  }
float x

◆ ceillog2()

constexpr int nnet::ceillog2 ( int  x)

Definition at line 10 of file nnet_mult.h.

References x.

Referenced by cast().

10 { return (x <= 2) ? 1 : 1 + ceillog2((x + 1) / 2); }
constexpr int ceillog2(int x)
Definition: nnet_mult.h:10
float x

◆ compute_layer()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::compute_layer ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_out],
typename CONFIG_T::weight_t  weights[CONFIG_T::n_in *CONFIG_T::n_out],
typename CONFIG_T::bias_t  biases[CONFIG_T::n_out] 
)

Definition at line 50 of file nnet_layer.h.

References utilities::cache(), data, DIV_ROUNDUP, cuy::ii, findQualityFiles::jj, PixelBaryCentreAnalyzer_cfg::mult, and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

53  {
54  unsigned cycle_factor = DIV_ROUNDUP(CONFIG_T::n_in * CONFIG_T::n_out, CONFIG_T::reuse_factor);
55  typename CONFIG_T::weight_t mult[CONFIG_T::n_in * CONFIG_T::n_out];
56  /*
57  if(CONFIG_T::use_lowlatency) {
58  int multiplier_limit = ceil(float(CONFIG_T::n_in*CONFIG_T::n_out) / float(CONFIG_T::reuse_factor)) - floor(float(CONFIG_T::n_zeros) / float(CONFIG_T::reuse_factor));
59  }
60  */
61  typename CONFIG_T::accum_t acc[CONFIG_T::n_out];
62  for (unsigned iacc = 0; iacc < CONFIG_T::n_out; iacc++) {
63  acc[iacc] = (typename CONFIG_T::accum_t)biases[iacc];
64  }
65  unsigned rufactor = CONFIG_T::reuse_factor;
66  if (CONFIG_T::use_lowlatency) {
67  rufactor = CONFIG_T::n_in;
68  cycle_factor = CONFIG_T::n_out;
69  }
70  data_T cache;
71  for (unsigned ii = 0; ii < rufactor; ii++) {
72  if (CONFIG_T::use_lowlatency) {
73  cache = data[ii];
74  }
75  for (unsigned jj = 0; jj < cycle_factor; jj++) {
76  unsigned windex = ii * cycle_factor + jj;
77  unsigned index = windex / CONFIG_T::n_out;
78  if (windex > CONFIG_T::n_in * CONFIG_T::n_out - 1)
79  continue;
80  if (CONFIG_T::use_lowlatency) {
81  mult[windex] = cache * (weights[windex]);
82  } else {
83  int aindex = windex / CONFIG_T::n_in;
84  acc[aindex] += data[index] * weights[windex];
85  }
86  }
87  }
88  if (CONFIG_T::use_lowlatency) {
89  // Accumulate multiplication result
90  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
91  for (unsigned jj = 0; jj < CONFIG_T::n_out; jj++) {
92  int index = ii * CONFIG_T::n_out + jj;
93  acc[jj] += mult[index];
94  }
95  }
96  }
97  for (unsigned ires = 0; ires < CONFIG_T::n_out; ires++) {
98  res[ires] = (res_T)(acc[ires]);
99  }
100  }
Definition: Electron.h:6
#define DIV_ROUNDUP(n, d)
Definition: nnet_layer.h:47
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
def cache(function)
Definition: utilities.py:3

◆ dense()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::dense ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_out],
typename CONFIG_T::weight_t  weights[CONFIG_T::n_in *CONFIG_T::n_out],
typename CONFIG_T::bias_t  biases[CONFIG_T::n_out] 
)

Definition at line 33 of file nnet_dense.h.

References utilities::cache(), data, cuy::ii, findQualityFiles::jj, PixelBaryCentreAnalyzer_cfg::mult, svgfig::template(), and hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights.

36  {
37  data_T cache;
38  typename CONFIG_T::accum_t mult[CONFIG_T::n_in * CONFIG_T::n_out];
39  typename CONFIG_T::accum_t acc[CONFIG_T::n_out];
40 
41  // Do the matrix-multiply
42  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
43  cache = data[ii];
44  for (unsigned jj = 0; jj < CONFIG_T::n_out; jj++) {
45  unsigned index = ii * CONFIG_T::n_out + jj;
46  mult[index] = CONFIG_T::template product<data_T, typename CONFIG_T::weight_t>::product(cache, weights[index]);
47  }
48  }
49 
50  // Initialize accumulator with input biases
51  for (unsigned iacc = 0; iacc < CONFIG_T::n_out; iacc++) {
52  acc[iacc] = (typename CONFIG_T::accum_t)biases[iacc];
53  }
54 
55  // Accumulate multiplication result
56  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
57  for (unsigned jj = 0; jj < CONFIG_T::n_out; jj++) {
58  unsigned index = ii * CONFIG_T::n_out + jj;
59  acc[jj] += mult[index];
60  }
61  }
62 
63  // Cast to "res_t" type
64  for (unsigned ires = 0; ires < CONFIG_T::n_out; ires++) {
65  // res[ires] = (res_T) (acc[ires]);
66  res[ires] = cast<data_T, res_T, CONFIG_T>(acc[ires]);
67  }
68  }
Definition: Electron.h:6
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
def cache(function)
Definition: utilities.py:3

◆ exp_fcn_float()

float nnet::exp_fcn_float ( float  input)
inline

Definition at line 134 of file nnet_activation.h.

References JetChargeProducer_cfi::exp, and input.

Referenced by init_exp_table().

134 { return exp(input); }
static std::string const input
Definition: EdmProvDump.cc:50

◆ init_exp_table()

template<typename CONFIG_T , int N_TABLE>
void nnet::init_exp_table ( typename CONFIG_T::table_t  table_out[N_TABLE])

Definition at line 137 of file nnet_activation.h.

References exp_fcn_float(), ALCARECOEcalPhiSym_cff::float, cuy::ii, and P2L1HTMHTEmu::N_TABLE.

137  {
138  for (unsigned ii = 0; ii < N_TABLE; ii++) {
139  // First, convert from table index to X-value (signed 8-bit, range -8 to +8)
140  float in_val = 2 * 8.0 * (ii - float(N_TABLE) / 2.0) / float(N_TABLE);
141  // Next, compute lookup table function
142  typename CONFIG_T::table_t real_val = exp_fcn_float(in_val);
143  //std::cout << "Lookup table In Value: " << in_val << " Result: " << real_val << std::endl;
144  table_out[ii] = real_val;
145  }
146  }
ii
Definition: cuy.py:589
static constexpr int N_TABLE
float exp_fcn_float(float input)

◆ init_invert_table()

template<typename CONFIG_T , int N_TABLE>
void nnet::init_invert_table ( typename CONFIG_T::table_t  table_out[N_TABLE])

Definition at line 149 of file nnet_activation.h.

References ALCARECOEcalPhiSym_cff::float, cuy::ii, and P2L1HTMHTEmu::N_TABLE.

149  {
150  // Inversion function:
151  // result = 1/x
152  for (unsigned ii = 0; ii < N_TABLE; ii++) {
153  // First, convert from table index to X-value (signed 8-bit, range 0 to +64)
154  float in_val = 64.0 * ii / float(N_TABLE);
155  // Next, compute lookup table function
156  if (in_val > 0.0)
157  table_out[ii] = 1.0 / in_val;
158  else
159  table_out[ii] = 0.0;
160  }
161  }
ii
Definition: cuy.py:589
static constexpr int N_TABLE

◆ init_sigmoid_table()

template<class res_T , typename CONFIG_T , int N_TABLE>
void nnet::init_sigmoid_table ( res_T  table_out[N_TABLE])

Definition at line 98 of file nnet_activation.h.

References ALCARECOEcalPhiSym_cff::float, cuy::ii, and P2L1HTMHTEmu::N_TABLE.

98  {
99  // Default logistic sigmoid function:
100  // result = 1/(1+e^(-x))
101  for (unsigned ii = 0; ii < N_TABLE; ii++) {
102  // First, convert from table index to X-value (signed 8-bit, range -8 to +8)
103  float in_val = 2 * 8.0 * (ii - float(N_TABLE) / 2.0) / float(N_TABLE);
104  // Next, compute lookup table function
105  res_T real_val = sigmoid_fcn_float<res_T>(in_val);
106  //std::cout << "Lookup table In Value: " << in_val << " Result: " << real_val << std::endl;
107  table_out[ii] = (res_T)real_val;
108  }
109  }
ii
Definition: cuy.py:589
static constexpr int N_TABLE

◆ init_tanh_table()

template<typename CONFIG_T , int N_TABLE>
void nnet::init_tanh_table ( typename CONFIG_T::table_t  table_out[N_TABLE])

Definition at line 214 of file nnet_activation.h.

References ALCARECOEcalPhiSym_cff::float, cuy::ii, P2L1HTMHTEmu::N_TABLE, and tanh().

214  {
215  // Implement tanh lookup
216  for (unsigned ii = 0; ii < N_TABLE; ii++) {
217  // First, convert from table index to X-value (signed 8-bit, range -4 to +4)
218  float in_val = 2 * 4.0 * (ii - float(N_TABLE) / 2.0) / float(N_TABLE);
219  // Next, compute lookup table function
220  typename CONFIG_T::table_t real_val = tanh(in_val);
221  //std::cout << "Tanh: Lookup table Index: " << ii<< " In Value: " << in_val << " Result: " << real_val << std::endl;
222  table_out[ii] = real_val;
223  }
224  }
void tanh(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_in])
ii
Definition: cuy.py:589
static constexpr int N_TABLE

◆ linear()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::linear ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 49 of file nnet_activation.h.

References data, and cuy::ii.

49  {
50  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
51  res[ii] = data[ii];
52  }
53  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ relu()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::relu ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 59 of file nnet_activation.h.

References data, and cuy::ii.

59  {
60  data_T datareg;
61  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
62  datareg = data[ii];
63  if (datareg > 0)
64  res[ii] = datareg;
65  else
66  res[ii] = 0;
67  }
68  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ relu6()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::relu6 ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 85 of file nnet_activation.h.

References data.

85  {
86  relu_max<data_T, res_T, 6, CONFIG_T>(data, res);
87  }
Definition: Electron.h:6
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ relu_max()

template<class data_T , class res_T , int MAX_INT, typename CONFIG_T >
void nnet::relu_max ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 71 of file nnet_activation.h.

References data, and cuy::ii.

71  {
72  data_T datareg;
73  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
74  datareg = data[ii];
75  if (datareg < 0)
76  res[ii] = 0;
77  else if (datareg > MAX_INT)
78  res[ii] = MAX_INT;
79  else
80  res[ii] = datareg;
81  }
82  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ sigmoid()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::sigmoid ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 112 of file nnet_activation.h.

References data, and cuy::ii.

112  {
113  // Initialize the lookup table
114  res_T sigmoid_table[CONFIG_T::table_size];
115  init_sigmoid_table<res_T, CONFIG_T, CONFIG_T::table_size>(sigmoid_table);
116 
117  // Index into the lookup table based on data
118  int data_round;
119  unsigned index;
120  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
121  data_round = data[ii] * CONFIG_T::table_size / 16;
122  index = data_round + 8 * CONFIG_T::table_size / 16;
123  /*if (index < 0)
124  index = 0;*/
125  if (index > CONFIG_T::table_size - 1)
126  index = CONFIG_T::table_size - 1;
127  res[ii] = (res_T)sigmoid_table[index];
128  }
129  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ sigmoid_fcn_float()

template<class out_T >
out_T nnet::sigmoid_fcn_float ( float  input)
inline

Definition at line 93 of file nnet_activation.h.

References JetChargeProducer_cfi::exp, and input.

93  {
94  return 1.0 / (1 + exp(-input));
95  }
static std::string const input
Definition: EdmProvDump.cc:50

◆ softmax()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::softmax ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 164 of file nnet_activation.h.

References data, cuy::ii, and findQualityFiles::jj.

164  {
165  // Initialize the lookup table
166  typename CONFIG_T::table_t exp_table[CONFIG_T::table_size];
167  init_exp_table<CONFIG_T, CONFIG_T::table_size>(exp_table);
168 
169  typename CONFIG_T::table_t invert_table[CONFIG_T::table_size];
170  init_invert_table<CONFIG_T, CONFIG_T::table_size>(invert_table);
171 
172  // Index into the lookup table based on data for exponentials
173  typename CONFIG_T::table_t exp_res[CONFIG_T::n_in]; // different, independent, fixed point precision
174  typename CONFIG_T::table_t exp_diff_res[CONFIG_T::n_in]
175  [CONFIG_T::n_in]; // different, independent, fixed point precision
176  int data_round;
177  int index;
178  for (int ii = 0; ii < CONFIG_T::n_in; ii++) {
179  exp_res[ii] = 0;
180  }
181  for (int ii = 0; ii < CONFIG_T::n_in; ii++) {
182  for (int jj = 0; jj < CONFIG_T::n_in; jj++) {
183  if (ii == jj)
184  exp_diff_res[ii][jj] = 1;
185  else {
186  data_round = (data[jj] - data[ii]) * CONFIG_T::table_size / 16;
187  index = data_round + 8 * CONFIG_T::table_size / 16;
188  if (index < 0)
189  index = 0;
190  if (index > CONFIG_T::table_size - 1)
191  index = CONFIG_T::table_size - 1;
192  exp_diff_res[ii][jj] = exp_table[index];
193  }
194  exp_res[ii] += exp_diff_res[ii][jj];
195  }
196  }
197 
198  //Second loop to invert
199  for (unsigned ii = 0; ii < CONFIG_T::n_in; ii++) {
200  int exp_res_index = exp_res[ii] * CONFIG_T::table_size / 64;
201  if (exp_res_index < 0)
202  exp_res_index = 0;
203  if (exp_res_index > CONFIG_T::table_size - 1)
204  exp_res_index = CONFIG_T::table_size - 1;
205  //typename CONFIG_T::table_t exp_res_invert = invert_table[exp_res_index];
206  res[ii] = (res_T)invert_table[exp_res_index];
207  }
208  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ tanh()

template<class data_T , class res_T , typename CONFIG_T >
void nnet::tanh ( data_T  data[CONFIG_T::n_in],
res_T  res[CONFIG_T::n_in] 
)

Definition at line 227 of file nnet_activation.h.

References data, and cuy::ii.

Referenced by ZCountingElectrons::analyze(), HcalGeomCheck::analyze(), CSCGattiFunction::binValue(), HFRecoEcalCandidateAlgo::correctEPosition(), MaterialBudgetMtdHistos::fillEndTrack(), HcalHardcodeGeometryLoader::fillHE(), HcalFlexiHardcodeGeometryLoader::fillHE(), GflashHadronShowerProfile::fTanh(), FWExpressionValidator::FWExpressionValidator(), PythiaFilterIsolatedTrack::getDistInCM(), spr::getDistInCMatEcal(), spr::getDistInCMatHcal(), IsoTrig::getGoodTracks(), HFGflash::gfParameterization(), init_tanh_table(), reco::HcalIsolatedTrackCandidate::l1jetp(), CaloTowerHardcodeGeometryLoader::makeCell(), SiPixelDigitizerAlgorithm::missCalibrate(), reco::parser::tanh_f::operator()(), HFRecoEcalCandidateAlgo::produce(), L2MuonSeedGeneratorFromL1TkMu::produce(), CaloDualConeSelector< T >::selectCallback(), CaloConeSelector< T >::selectCallback(), GflashShowino::simulateFirstInteractionPoint(), QGLikelihoodCalculator::smearingFunction(), reco::isodeposit::Direction::theta(), and pat::PackedGenParticle::unpack().

227  {
228  // Initialize the lookup table
229  typename CONFIG_T::table_t tanh_table[CONFIG_T::table_size];
230  init_tanh_table<CONFIG_T, CONFIG_T::table_size>(tanh_table);
231 
232  // Index into the lookup table based on data
233  int data_round;
234  int index;
235  for (int ii = 0; ii < CONFIG_T::n_in; ii++) {
236  data_round = data[ii] * CONFIG_T::table_size / 8;
237  index = data_round + 4 * CONFIG_T::table_size / 8;
238  //std::cout << "Input: " << data[ii] << " Round: " << data_round << " Index: " << index << std::endl;
239  if (index < 0)
240  index = 0;
241  if (index > CONFIG_T::table_size - 1)
242  index = CONFIG_T::table_size - 1;
243  res[ii] = (res_T)tanh_table[index];
244  }
245  }
Definition: Electron.h:6
ii
Definition: cuy.py:589
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80