blob: 4853971251d55e8f1c2d452596485551160c5d51 [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:
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 }
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>
Eric Kunzee5e26762020-10-13 16:11:07 -070048class OpSigmoid : public UnaryNode<Rank, Dtype>
49{
50public:
Eric Kunzeb5fabec2022-06-07 05:20:44 +000051 OpSigmoid(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070052 : UnaryNode<Rank, Dtype>(sgt_, Op_SIGMOID, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070053 {
54 register_fcn();
55 }
56 static constexpr int32_t QMin = GetQMin<Dtype>::value;
57 static constexpr int32_t QMax = GetQMax<Dtype>::value;
58 using InEigenType = typename GetEigenType<Dtype>::type;
59 using OutEigenType = typename GetEigenType<Dtype>::type;
60 virtual int register_fcn();
61};
62
63template <int Rank, DType Dtype>
64class OpTanh : public UnaryNode<Rank, Dtype>
65{
66public:
Eric Kunzeb5fabec2022-06-07 05:20:44 +000067 OpTanh(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070068 : UnaryNode<Rank, Dtype>(sgt_, Op_TANH, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070069 {
70 register_fcn();
71 }
72 static constexpr int32_t QMin = GetQMin<Dtype>::value;
73 static constexpr int32_t QMax = GetQMax<Dtype>::value;
74 using InEigenType = typename GetEigenType<Dtype>::type;
75 using OutEigenType = typename GetEigenType<Dtype>::type;
76 virtual int register_fcn();
77};
78
79}; // namespace TosaReference
80
81#endif