blob: f240aa570f660c99cceff2d897ec326f15f6fa62 [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001
James Ward8b390432022-08-12 20:48:56 +01002// 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#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 {
James Ward8b390432022-08-12 20:48:56 +010030 case DType_FP16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010031 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070032 case DType_INT32:
33 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a == b; };
34 break;
35 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070036 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070037 }
38
39 return 0;
40}
41
42template <int Rank, DType Dtype>
43int OpGreater<Rank, Dtype>::register_fcn()
44{
45 switch (Dtype)
46 {
James Ward8b390432022-08-12 20:48:56 +010047 case DType_FP16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010048 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070049 case DType_INT32:
50 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a > b; };
51 break;
52 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070053 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070054 }
55
56 return 0;
57}
58
59template <int Rank, DType Dtype>
60int OpGreaterEqual<Rank, Dtype>::register_fcn()
61{
62 switch (Dtype)
63 {
James Ward8b390432022-08-12 20:48:56 +010064 case DType_FP16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010065 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070066 case DType_INT32:
67 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a >= b; };
68 break;
69 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070070 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070071 }
72
73 return 0;
74}
75
76// template explicit instantiation
James Ward8b390432022-08-12 20:48:56 +010077DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FP16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010078DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070079DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, INT32);
80
James Ward8b390432022-08-12 20:48:56 +010081DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FP16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010082DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070083DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, INT32);
84
James Ward8b390432022-08-12 20:48:56 +010085DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FP16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010086DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070087DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, INT32);