blob: 5b78a4f1003d2c53c25d8b15e703234a5b32e760 [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:
James Ward24dbc422022-10-19 12:20:31 +010031 case DType_BF16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010032 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070033 case DType_INT32:
34 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a == b; };
35 break;
36 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070037 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070038 }
39
40 return 0;
41}
42
43template <int Rank, DType Dtype>
44int OpGreater<Rank, Dtype>::register_fcn()
45{
46 switch (Dtype)
47 {
James Ward8b390432022-08-12 20:48:56 +010048 case DType_FP16:
James Ward24dbc422022-10-19 12:20:31 +010049 case DType_BF16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010050 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070051 case DType_INT32:
52 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a > b; };
53 break;
54 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070055 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070056 }
57
58 return 0;
59}
60
61template <int Rank, DType Dtype>
62int OpGreaterEqual<Rank, Dtype>::register_fcn()
63{
64 switch (Dtype)
65 {
James Ward8b390432022-08-12 20:48:56 +010066 case DType_FP16:
James Ward24dbc422022-10-19 12:20:31 +010067 case DType_BF16:
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010068 case DType_FP32:
Eric Kunzee5e26762020-10-13 16:11:07 -070069 case DType_INT32:
70 this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a >= b; };
71 break;
72 default:
Kevin Chengacb550f2021-06-29 15:32:19 -070073 ERROR_IF(true, "unsupported DType %s", EnumNamesDType()[Dtype]);
Eric Kunzee5e26762020-10-13 16:11:07 -070074 }
75
76 return 0;
77}
78
79// template explicit instantiation
James Ward8b390432022-08-12 20:48:56 +010080DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FP16);
James Ward24dbc422022-10-19 12:20:31 +010081DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010082DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070083DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, INT32);
84
James Ward8b390432022-08-12 20:48:56 +010085DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FP16);
James Ward24dbc422022-10-19 12:20:31 +010086DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010087DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070088DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, INT32);
89
James Ward8b390432022-08-12 20:48:56 +010090DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FP16);
James Ward24dbc422022-10-19 12:20:31 +010091DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +010092DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -070093DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, INT32);