Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame^] | 1 | |
| 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 | |
| 21 | using namespace TosaReference; |
| 22 | using namespace Eigen; |
| 23 | using namespace tosa; |
| 24 | |
| 25 | template <int Rank, DType Dtype> |
| 26 | int 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 | |
| 41 | template <int Rank, DType Dtype> |
| 42 | int 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 | |
| 57 | template <int Rank, DType Dtype> |
| 58 | int 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 |
| 74 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, FLOAT); |
| 75 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpEqual, INT32); |
| 76 | |
| 77 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, FLOAT); |
| 78 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreater, INT32); |
| 79 | |
| 80 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, FLOAT); |
| 81 | DEF_INSTANTIATE_RANK0_6_ONE_RANK_ONE_TYPE(OpGreaterEqual, INT32); |