blob: 9a697cd1ef010b10abc869db9e62dbb26f14882c [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001
Jerry Gea6827492022-11-16 10:41:55 -08002// Copyright (c) 2020-2022, ARM Limited.
Eric Kunzee5e26762020-10-13 16:11:07 -07003//
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
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
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.
15
16#ifndef OPS_ACTIVATION_FUNCS_H
17#define OPS_ACTIVATION_FUNCS_H
18
19#include "ewise_unary.h"
20#include "graph_node.h"
21
22using namespace tosa;
23
24namespace TosaReference
25{
26
27template <int Rank, DType Dtype>
28class OpClamp : public UnaryNode<Rank, Dtype>
29{
30public:
Eric Kunzeb5fabec2022-06-07 05:20:44 +000031 OpClamp(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070032 : UnaryNode<Rank, Dtype>(sgt_, Op_CLAMP, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070033 {
34 INIT_ATTRIBUTE(Clamp);
35 register_fcn();
36 }
Jerry Gea6827492022-11-16 10:41:55 -080037 virtual ~OpClamp();
Eric Kunzee5e26762020-10-13 16:11:07 -070038 static constexpr int32_t QMin = GetQMin<Dtype>::value;
39 static constexpr int32_t QMax = GetQMax<Dtype>::value;
40 using InEigenType = typename GetEigenType<Dtype>::type;
41 using OutEigenType = typename GetEigenType<Dtype>::type;
42 virtual int register_fcn();
43
44protected:
45 TosaClampAttribute* attribute;
46};
47
48template <int Rank, DType Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -070049class OpSigmoid : public UnaryNode<Rank, Dtype>
50{
51public:
Eric Kunzeb5fabec2022-06-07 05:20:44 +000052 OpSigmoid(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070053 : UnaryNode<Rank, Dtype>(sgt_, Op_SIGMOID, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070054 {
55 register_fcn();
56 }
57 static constexpr int32_t QMin = GetQMin<Dtype>::value;
58 static constexpr int32_t QMax = GetQMax<Dtype>::value;
59 using InEigenType = typename GetEigenType<Dtype>::type;
60 using OutEigenType = typename GetEigenType<Dtype>::type;
61 virtual int register_fcn();
62};
63
64template <int Rank, DType Dtype>
65class OpTanh : public UnaryNode<Rank, Dtype>
66{
67public:
Eric Kunzeb5fabec2022-06-07 05:20:44 +000068 OpTanh(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070069 : UnaryNode<Rank, Dtype>(sgt_, Op_TANH, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070070 {
71 register_fcn();
72 }
73 static constexpr int32_t QMin = GetQMin<Dtype>::value;
74 static constexpr int32_t QMax = GetQMax<Dtype>::value;
75 using InEigenType = typename GetEigenType<Dtype>::type;
76 using OutEigenType = typename GetEigenType<Dtype>::type;
77 virtual int register_fcn();
78};
79
80}; // namespace TosaReference
81
82#endif