blob: b051b9dcf80773a7c94d18fbceee88873c20ee90 [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001
2// Copyright (c) 2020, ARM Limited.
3//
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:
31 OpClamp(TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_)
32 : UnaryNode<Rank, Dtype>(Op_CLAMP, id_)
33 {
34 INIT_ATTRIBUTE(Clamp);
35 register_fcn();
36 }
37 static constexpr int32_t QMin = GetQMin<Dtype>::value;
38 static constexpr int32_t QMax = GetQMax<Dtype>::value;
39 using InEigenType = typename GetEigenType<Dtype>::type;
40 using OutEigenType = typename GetEigenType<Dtype>::type;
41 virtual int register_fcn();
42
43protected:
44 TosaClampAttribute* attribute;
45};
46
47template <int Rank, DType Dtype>
48class OpReluN : public UnaryNode<Rank, Dtype>
49{
50public:
51 OpReluN(TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_)
52 : UnaryNode<Rank, Dtype>(Op_RELUN, id_)
53 {
54 INIT_ATTRIBUTE(ReluN);
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
63protected:
64 TosaReluNAttribute* attribute;
65};
66
67template <int Rank, DType Dtype>
68class OpSigmoid : public UnaryNode<Rank, Dtype>
69{
70public:
71 OpSigmoid(TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_)
72 : UnaryNode<Rank, Dtype>(Op_SIGMOID, id_)
73 {
74 register_fcn();
75 }
76 static constexpr int32_t QMin = GetQMin<Dtype>::value;
77 static constexpr int32_t QMax = GetQMax<Dtype>::value;
78 using InEigenType = typename GetEigenType<Dtype>::type;
79 using OutEigenType = typename GetEigenType<Dtype>::type;
80 virtual int register_fcn();
81};
82
83template <int Rank, DType Dtype>
84class OpTanh : public UnaryNode<Rank, Dtype>
85{
86public:
87 OpTanh(TosaAttributeBase* attribute_, TosaQuantInfoBase* qinfo_, uint64_t id_)
88 : UnaryNode<Rank, Dtype>(Op_TANH, id_)
89 {
90 register_fcn();
91 }
92 static constexpr int32_t QMin = GetQMin<Dtype>::value;
93 static constexpr int32_t QMax = GetQMax<Dtype>::value;
94 using InEigenType = typename GetEigenType<Dtype>::type;
95 using OutEigenType = typename GetEigenType<Dtype>::type;
96 virtual int register_fcn();
97};
98
99}; // namespace TosaReference
100
101#endif