Skip to content

Commit 1b83814

Browse files
committed
Fix formatting: apply clang-format from pre-commit
1 parent e1014b2 commit 1b83814

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

hls4ml/templates/vivado/nnet_utils/nnet_activation.h.bak

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -721,23 +721,18 @@ template <class data_T, class res_T, typename CONFIG_T> void selu(data_T data[CO
721721
static const selu_const_t lambda = 1.0507009873554805;
722722

723723
//#pragma HLS PIPELINE
724-
for (int ii = 0; ii < CONFIG_T::n_in; ii++) {
725-
data_T datareg = data[ii];
726724

725+
data_T datareg;
726+
// Index into the lookup table based on data
727+
int index;
728+
for (int ii = 0; ii < CONFIG_T::n_in; ii++) {
729+
datareg = data[ii];
727730
if (datareg >= 0) {
728-
// Positive branch y = λ · x
729-
res[ii] = lambda * datareg;
731+
res[ii] = res_T(1.0507009873554804934193349852946) * datareg;
730732
} else {
731-
// Negative branch y = table(x)
732-
int index = datareg * CONFIG_T::table_size / -8;
733-
734-
// clamp index to [0, table_size-1]
735-
if (index < 0)
736-
index = 0;
737-
else if (index > CONFIG_T::table_size - 1) {
733+
index = datareg * CONFIG_T::table_size / -8;
734+
if (index > CONFIG_T::table_size - 1)
738735
index = CONFIG_T::table_size - 1;
739-
}
740-
741736
res[ii] = selu_table[index];
742737
}
743738
}

0 commit comments

Comments
 (0)