blob: 402e152ebeb7bb8881537d9e3ded0a56007a4818 [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#include "comparison.h"
17#include "arith_util.h"
18#include "quant_util.h"
19#include "template_types.h"
20
21using namespace TosaReference;
22using namespace Eigen;
23using namespace tosa;
24
25template <int Rank, DType Dtype>
26int OpEqual<Rank, Dtype>::register_fcn()
27{
28 switch (Dtype)
29 {
30 case DType_FLOAT:
31 case DType_INT32:
32 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a == b; };
33 break;
34 default:
35 FATAL_ERROR_NODE("unsupported DType %s", EnumNamesDType()[Dtype]);
36 }
37
38 return 0;
39}
40
41template <int Rank, DType Dtype>
42int OpGreater<Rank, Dtype>::register_fcn()
43{
44 switch (Dtype)
45 {
46 case DType_FLOAT:
47 case DType_INT32:
48 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a > b; };
49 break;
50 default:
51 FATAL_ERROR_NODE("unsupported DType %s", EnumNamesDType()[Dtype]);
52 }
53
54 return 0;
55}
56
57template <int Rank, DType Dtype>
58int OpGreaterEqual<Rank, Dtype>::register_fcn()
59{
60 switch (Dtype)
61 {
62 case DType_FLOAT:
63 case DType_INT32:
64 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a >= b; };
65 break;
66 default:
67 FATAL_ERROR_NODE("unsupported DType %s", EnumNamesDType()[Dtype]);
68 }
69
70 return 0;
71}
72
73// template explicit instantiation
74DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FLOAT);
75DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, INT32);
76
77DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FLOAT);
78DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, INT32);
79
80DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FLOAT);
81DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, INT32);