Skip to content
Snippets Groups Projects

v0.2.0

Merged Maxence Naud requested to merge dev into main
38 files
+ 649
1323
Compare changes
  • Side-by-side
  • Inline
Files
38
@@ -4,36 +4,36 @@
#include <type_traits>
#include "network/typedefs.hpp"
#include "network/utils.hpp"
#include "network/rescaling.hpp"
#include "kernels/rescaling.hpp"
template<typename Output_T, typename T,
template<typename Output_T, typename T,
typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
__attribute__((always_inline)) inline
Output_T saturate (T value, int32_t /*sat*/)
Output_T saturate (T value, int32_t /*sat*/)
{
return value;
}
template<typename Output_T, typename T,
template<typename Output_T, typename T,
typename std::enable_if<!std::is_floating_point<T>::value>::type* = nullptr>
__attribute__((always_inline)) inline
Output_T saturate (T value, uint32_t sat)
Output_T saturate (T value, uint32_t sat)
{
if (std::is_unsigned<Output_T>::value) {
return clamp(value, T(0), (T(1) << sat) - 1);
} else {
return clamp(value, -(T(1) << (sat - 1)), (T(1) << (sat - 1)) - 1);
}
}
}
template<typename Output_T,
typename Sum_T,
template<typename Output_T,
typename Sum_T,
typename Rescaling_T>
__attribute__((always_inline)) inline
Output_T activation_forward_value (Sum_T weightedSum,
int output,
ActivationFunction_T func,
const Rescaling_T& __restrict rescaling)
__attribute__((always_inline)) inline
Output_T activation_forward_value (Sum_T weightedSum,
int output,
ActivationFunction_T func,
const Rescaling_T& __restrict rescaling)
{
switch(func) {
case Linear:
@@ -49,7 +49,7 @@ Output_T activation_forward_value (Sum_T weightedSum,
break;
}
// Value fixed here for now but it should be generated by
// Value fixed here for now but it should be generated by
// the export module or determined by the type of Output_T
// For now only works for int8_t and uint8_t
const uint32_t NB_BITS = 8;
@@ -60,7 +60,7 @@ Output_T activation_forward_value (Sum_T weightedSum,
template<int NB_DATA,
ActivationFunction_T ACTIVATION,
typename Input_T, typename Output_T, typename Rescaling_T>
__attribute__((always_inline)) inline
__attribute__((always_inline)) inline
void activation_forward (
const Input_T* __restrict inputs,
Output_T* __restrict outputs,
Loading