summaryrefslogtreecommitdiff
path: root/runtime/onert/backend/cpu/ops
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2022-04-15 19:15:11 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2022-04-15 19:15:11 +0900
commit3ad689f0803519e343c36d5700646e86059df961 (patch)
tree862346c401a5577518fa7f042532aa931b53aa0e /runtime/onert/backend/cpu/ops
parentac6e4dd7b480e83b586ef533d7b29a8a97eb48fe (diff)
downloadnnfw-3ad689f0803519e343c36d5700646e86059df961.tar.gz
nnfw-3ad689f0803519e343c36d5700646e86059df961.tar.bz2
nnfw-3ad689f0803519e343c36d5700646e86059df961.zip
Imported Upstream version 1.20.0upstream/1.20.0submit/tizen/20220415.103159
Diffstat (limited to 'runtime/onert/backend/cpu/ops')
-rw-r--r--runtime/onert/backend/cpu/ops/OperationUtils.cc2
-rw-r--r--runtime/onert/backend/cpu/ops/OperationUtils.h44
2 files changed, 6 insertions, 40 deletions
diff --git a/runtime/onert/backend/cpu/ops/OperationUtils.cc b/runtime/onert/backend/cpu/ops/OperationUtils.cc
index 8ac875842..aa4ef352e 100644
--- a/runtime/onert/backend/cpu/ops/OperationUtils.cc
+++ b/runtime/onert/backend/cpu/ops/OperationUtils.cc
@@ -194,7 +194,7 @@ void CalculateActivationRangeQuantized(ir::Activation activation, const IPortabl
}
else
{
- std::cout << "Unsupported fused activation function." << std::endl;
+ throw std::runtime_error{"Unsupported fused activation function."};
}
}
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);