2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ONERT_BACKEND_XNNPACK_OPS_OPERATION_UTILS_H__
18 #define __ONERT_BACKEND_XNNPACK_OPS_OPERATION_UTILS_H__
20 // duplicated from cpu/ops/OperationUtils.h
21 #include <ir/InternalType.h>
22 #include <ir/Padding.h>
23 #include <ir/DataType.h>
34 using OperandType = ir::DataType;
37 void CalculateActivationRange(ir::Activation activation, T *activation_min, T *activation_max)
39 if (activation == ir::Activation::RELU)
42 *activation_max = std::numeric_limits<T>::max();
44 else if (activation == ir::Activation::RELU6)
49 else if (activation == ir::Activation::RELU1)
54 else if (activation == ir::Activation::SIGMOID)
59 else if (activation == ir::Activation::NONE)
61 *activation_min = std::numeric_limits<T>::lowest();
62 *activation_max = std::numeric_limits<T>::max();
66 throw std::runtime_error{"Unsupported fused activation function"};
71 } // namespace xnnpack
72 } // namespace backend
75 #endif // __ONERT_BACKEND_XNNPACK_OPS_OPERATION_UTILS_H__