diff options
Diffstat (limited to 'runtime/onert/backend/cpu/ops/OperationUtils.h')
-rw-r--r-- | runtime/onert/backend/cpu/ops/OperationUtils.h | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/runtime/onert/backend/cpu/ops/OperationUtils.h b/runtime/onert/backend/cpu/ops/OperationUtils.h index ac2fbb84f..1fefc3228 100644 --- a/runtime/onert/backend/cpu/ops/OperationUtils.h +++ b/runtime/onert/backend/cpu/ops/OperationUtils.h @@ -18,19 +18,19 @@ #define __NNFW_SUPPORT_NNAPI_OPERATION_UTILS_H__ #include <backend/IPortableTensor.h> - -#include <cker/Shape.h> -#include <cker/Types.h> -#include <iostream> #include <ir/DataType.h> -#include <ir/InternalType.h> #include <ir/Operand.h> #include <ir/Padding.h> +#include <util/CalculateActivationRange.h> + +#include <cker/Shape.h> +#include <cker/Types.h> #include <limits> #include <vector> using OperandType = onert::ir::DataType; +using namespace onert::util; namespace onert { @@ -166,40 +166,6 @@ void GetQuantizedConvolutionMultipliersAndShifts( int num_channels, std::vector<int32_t> &per_channel_output_multiplier, std::vector<int> &per_channel_output_shift); -template <typename T> -void CalculateActivationRange(ir::Activation activation, T *activation_min, T *activation_max) -{ - if (activation == ir::Activation::RELU) - { - *activation_min = 0; - *activation_max = std::numeric_limits<T>::max(); - } - else if (activation == ir::Activation::RELU6) - { - *activation_min = 0; - *activation_max = 6; - } - else if (activation == ir::Activation::RELU1) - { - *activation_min = -1; - *activation_max = 1; - } - else if (activation == ir::Activation::SIGMOID) - { - *activation_min = 0; - *activation_max = 1; - } - else if (activation == ir::Activation::NONE) - { - *activation_min = std::numeric_limits<T>::lowest(); - *activation_max = std::numeric_limits<T>::max(); - } - else - { - std::cout << "Unsupported fused activation function." << std::endl; - } -} - void CalculateActivationRangeQuantized(ir::Activation activation, const IPortableTensor *output, int32_t *act_min, int32_t *act_max); |