Use template for actvation calculation (#5198)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 16 May 2019 05:03:06 +0000 (14:03 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 16 May 2019 05:03:06 +0000 (14:03 +0900)
Change activation implementation to use template
Prepare to support more type (int32, uint32, etc)

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
libs/cker/include/cker/Utils.h

index 6734239..84bbbc3 100644 (file)
@@ -28,10 +28,10 @@ namespace nnfw
 namespace cker
 {
 
-inline float ActivationFunctionWithMinMax(float x, float output_activation_min,
-                                          float output_activation_max)
+template <typename T>
+inline T ActivationFunctionWithMinMax(T x, T output_activation_min, T output_activation_max)
 {
-  return std::min(std::max(x, output_activation_min), output_activation_max);
+  return std::min<T>(std::max<T>(x, output_activation_min), output_activation_max);
 }
 
 inline int32_t MultiplyByQuantizedMultiplier(int32_t x, int32_t quantized_multiplier, int shift)