Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 1 | |
Luke Hutton | 261b7b6 | 2023-01-10 14:50:31 +0000 | [diff] [blame] | 2 | // Copyright (c) 2020-2023, ARM Limited. |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 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_TENSOR_OPS_H |
| 17 | #define OPS_TENSOR_OPS_H |
| 18 | |
| 19 | #include "graph_node.h" |
| 20 | #include "quant_util.h" |
| 21 | |
| 22 | using namespace tosa; |
| 23 | |
| 24 | namespace TosaReference |
| 25 | { |
| 26 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 27 | template <int Rank, TOSA_REF_TYPE Dtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 28 | class OpArgMax : public GraphNode |
| 29 | { |
| 30 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 31 | OpArgMax(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 32 | virtual ~OpArgMax(); |
| 33 | |
| 34 | virtual int checkTensorAttributes(); |
| 35 | virtual int eval(); |
| 36 | |
| 37 | using InEigenType = typename GetEigenType<Dtype>::type; |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 38 | using OutEigenType = typename GetEigenType<TOSA_REF_TYPE_INT32>::type; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 39 | using TIn = Eigen::Tensor<InEigenType, Rank>; |
| 40 | using TOut = Eigen::Tensor<OutEigenType, Rank - 1>; |
| 41 | |
| 42 | protected: |
| 43 | TosaAxisAttribute* attribute; |
| 44 | TosaReference::TensorTemplate<TIn>* input; |
| 45 | TosaReference::TensorTemplate<TOut>* output; |
| 46 | }; |
| 47 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 48 | template <TOSA_REF_TYPE Dtype, TOSA_REF_TYPE AccDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 49 | class OpAvgPool2d : public GraphNode |
| 50 | { |
| 51 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 52 | OpAvgPool2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 53 | virtual ~OpAvgPool2d(); |
| 54 | |
| 55 | virtual int checkTensorAttributes(); |
| 56 | virtual int eval(); |
| 57 | |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 58 | using InEigenType = typename GetEigenType<Dtype>::type; |
| 59 | using AccEigenType = typename GetAccEigenType<AccDtype>::type; // Note: different from GetEigenType |
| 60 | using OutEigenType = typename GetEigenType<Dtype>::type; |
| 61 | using TIn = Eigen::Tensor<InEigenType, 4>; |
| 62 | using TOut = Eigen::Tensor<OutEigenType, 4>; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 63 | |
| 64 | static constexpr int64_t QMin = GetQMin<Dtype>::value; |
| 65 | static constexpr int64_t QMax = GetQMax<Dtype>::value; |
| 66 | |
| 67 | protected: |
| 68 | TosaReference::TensorTemplate<TIn>* in; |
| 69 | TosaReference::TensorTemplate<TOut>* out; |
Kevin Cheng | 93a1628 | 2021-08-31 16:14:03 -0700 | [diff] [blame] | 70 | tosa::TosaPoolAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 71 | |
| 72 | protected: |
| 73 | // return a 1D [N] tensor that describes a how many valid elements covered in the input space |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 74 | ETensor1<int32_t> calculate_div_map_1d( |
| 75 | int in_size, int out_size, int kernel_size, int stride, int32_t padding_left, int32_t padding_right); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 78 | template <TOSA_REF_TYPE InDtype, TOSA_REF_TYPE WeightDtype, TOSA_REF_TYPE AccDtype, TOSA_REF_TYPE OutDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 79 | class OpConv2d : public GraphNode |
| 80 | { |
| 81 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 82 | OpConv2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 83 | virtual ~OpConv2d(); |
| 84 | |
| 85 | virtual int checkTensorAttributes() final; |
| 86 | virtual int eval() final; |
| 87 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 88 | using InEigenType = typename GetEigenType<InDtype>::type; |
| 89 | using WeightEigenType = typename GetEigenType<WeightDtype>::type; |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 90 | using AccEigenType = typename GetAccEigenType<AccDtype>::type; // Note: different from GetEigenType |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 91 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 92 | using TIn = Eigen::Tensor<InEigenType, 4>; |
| 93 | using TWeight = Eigen::Tensor<WeightEigenType, 4>; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 94 | using TBias = Eigen::Tensor<OutEigenType, 1>; |
| 95 | using TOut = Eigen::Tensor<OutEigenType, 4>; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 96 | |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 97 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 98 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 99 | |
| 100 | protected: |
| 101 | TosaReference::TensorTemplate<TIn>* input; |
| 102 | TosaReference::TensorTemplate<TWeight>* weight; |
| 103 | TosaReference::TensorTemplate<TBias>* bias; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 104 | TosaReference::TensorTemplate<TOut>* output; |
Kevin Cheng | 93a1628 | 2021-08-31 16:14:03 -0700 | [diff] [blame] | 105 | tosa::TosaConvAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 108 | template <TOSA_REF_TYPE InDtype, TOSA_REF_TYPE WeightDtype, TOSA_REF_TYPE AccDtype, TOSA_REF_TYPE OutDtype> |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 109 | class OpConv3d : public GraphNode |
| 110 | { |
| 111 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 112 | OpConv3d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 113 | virtual ~OpConv3d(); |
| 114 | |
| 115 | virtual int checkTensorAttributes() final; |
| 116 | virtual int eval() final; |
| 117 | |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 118 | using InEigenType = typename GetEigenType<InDtype>::type; |
| 119 | using WeightEigenType = typename GetEigenType<WeightDtype>::type; |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 120 | using AccEigenType = typename GetAccEigenType<AccDtype>::type; // Note: different from GetEigenType |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 121 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 122 | using TIn = Eigen::Tensor<InEigenType, 5>; |
| 123 | using TWeight = Eigen::Tensor<WeightEigenType, 5>; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 124 | using TBias = Eigen::Tensor<OutEigenType, 1>; |
| 125 | using TOut = Eigen::Tensor<OutEigenType, 5>; |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 126 | |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 127 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 128 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 129 | |
| 130 | protected: |
| 131 | TosaReference::TensorTemplate<TIn>* input; |
| 132 | TosaReference::TensorTemplate<TWeight>* weight; |
| 133 | TosaReference::TensorTemplate<TBias>* bias; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 134 | TosaReference::TensorTemplate<TOut>* output; |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 135 | tosa::TosaConvAttribute* attribute; |
Kevin Cheng | 1533b85 | 2021-09-01 12:51:58 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 138 | template <TOSA_REF_TYPE InDtype, TOSA_REF_TYPE WeightDtype, TOSA_REF_TYPE AccDtype, TOSA_REF_TYPE OutDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 139 | class OpDepthwiseConv2d : public GraphNode |
| 140 | { |
| 141 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 142 | OpDepthwiseConv2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 143 | virtual ~OpDepthwiseConv2d(); |
| 144 | |
| 145 | virtual int checkTensorAttributes() final; |
| 146 | virtual int eval() final; |
| 147 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 148 | using InEigenType = typename GetEigenType<InDtype>::type; |
| 149 | using WeightEigenType = typename GetEigenType<WeightDtype>::type; |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 150 | using AccEigenType = typename GetAccEigenType<AccDtype>::type; // Note: different from GetEigenType |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 151 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 152 | using TIn = Eigen::Tensor<InEigenType, 4>; |
| 153 | using TWeight = Eigen::Tensor<WeightEigenType, 4>; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 154 | using TBias = Eigen::Tensor<OutEigenType, 1>; |
| 155 | using TOut = Eigen::Tensor<OutEigenType, 4>; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 156 | |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 157 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 158 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 159 | |
| 160 | protected: |
| 161 | TosaReference::TensorTemplate<TIn>* input; |
| 162 | TosaReference::TensorTemplate<TWeight>* weight; |
| 163 | TosaReference::TensorTemplate<TBias>* bias; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 164 | TosaReference::TensorTemplate<TOut>* output; |
Kevin Cheng | 93a1628 | 2021-08-31 16:14:03 -0700 | [diff] [blame] | 165 | tosa::TosaConvAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 168 | template <TOSA_REF_TYPE InDtype, TOSA_REF_TYPE WeightDtype, TOSA_REF_TYPE OutDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 169 | class OpFullyConnected : public GraphNode |
| 170 | { |
| 171 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 172 | OpFullyConnected(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 173 | virtual ~OpFullyConnected(); |
| 174 | |
| 175 | virtual int checkTensorAttributes() final; |
| 176 | virtual int eval() final; |
| 177 | |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 178 | using InEigenType = typename GetEigenType<InDtype>::type; |
| 179 | using WeightEigenType = typename GetEigenType<WeightDtype>::type; |
| 180 | using AccEigenType = typename GetAccEigenType<OutDtype>::type; // Note: different from GetEigenType |
| 181 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
| 182 | using TIn = Eigen::Tensor<InEigenType, 2>; |
| 183 | using TWeight = Eigen::Tensor<WeightEigenType, 2>; |
| 184 | using TBias = Eigen::Tensor<OutEigenType, 1>; |
| 185 | using TOut = Eigen::Tensor<OutEigenType, 2>; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 186 | |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 187 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 188 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 189 | |
| 190 | protected: |
| 191 | TosaReference::TensorTemplate<TIn>* input; |
| 192 | TosaReference::TensorTemplate<TWeight>* weight; |
| 193 | TosaReference::TensorTemplate<TBias>* bias; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 194 | TosaReference::TensorTemplate<TOut>* output; |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 195 | |
| 196 | tosa::TosaFullyConnectedAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 197 | }; |
| 198 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 199 | template <TOSA_REF_TYPE Dtype, TOSA_REF_TYPE OutDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 200 | class OpMatMul : public GraphNode |
| 201 | { |
| 202 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 203 | OpMatMul(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 204 | virtual ~OpMatMul(); |
| 205 | |
| 206 | virtual int checkTensorAttributes() final; |
| 207 | virtual int eval() final; |
| 208 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 209 | using InEigenType = typename GetEigenType<Dtype>::type; |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 210 | using AccEigenType = typename GetAccEigenType<OutDtype>::type; // Note: different from GetEigenType |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 211 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
Kevin Cheng | 2d60f00 | 2021-06-09 14:18:32 -0700 | [diff] [blame] | 212 | using TIn = Eigen::Tensor<InEigenType, 3>; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 213 | using TOut = Eigen::Tensor<OutEigenType, 3>; |
Kevin Cheng | 2d60f00 | 2021-06-09 14:18:32 -0700 | [diff] [blame] | 214 | using TInRank2 = Eigen::Tensor<InEigenType, 2>; |
| 215 | using TAccRank2 = Eigen::Tensor<AccEigenType, 2>; |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 216 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 217 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 218 | |
| 219 | protected: |
| 220 | TosaReference::TensorTemplate<TIn>* a; |
| 221 | TosaReference::TensorTemplate<TIn>* b; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 222 | TosaReference::TensorTemplate<TOut>* output; |
Kevin Cheng | 2d60f00 | 2021-06-09 14:18:32 -0700 | [diff] [blame] | 223 | int64_t N; |
| 224 | int64_t H; |
| 225 | int64_t W; |
| 226 | int64_t C; |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 227 | |
| 228 | tosa::TosaMatMulAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 231 | template <TOSA_REF_TYPE Dtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 232 | class OpMaxPool2d : public GraphNode |
| 233 | { |
| 234 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 235 | OpMaxPool2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 236 | virtual ~OpMaxPool2d(); |
| 237 | |
| 238 | virtual int checkTensorAttributes(); |
| 239 | virtual int eval(); |
| 240 | |
| 241 | using InEigenType = typename GetEigenType<Dtype>::type; |
| 242 | using OutEigenType = typename GetEigenType<Dtype>::type; |
| 243 | using TIn = Eigen::Tensor<InEigenType, 4>; |
| 244 | using TOut = Eigen::Tensor<OutEigenType, 4>; |
| 245 | |
| 246 | protected: |
| 247 | TosaReference::TensorTemplate<TIn>* in; |
| 248 | TosaReference::TensorTemplate<TOut>* out; |
Kevin Cheng | 93a1628 | 2021-08-31 16:14:03 -0700 | [diff] [blame] | 249 | tosa::TosaPoolAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 252 | template <TOSA_REF_TYPE Dtype> |
Luke Hutton | 5728713 | 2023-02-06 14:54:18 +0000 | [diff] [blame] | 253 | class OpFFT2d : public GraphNode |
| 254 | { |
| 255 | public: |
| 256 | OpFFT2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
| 257 | virtual ~OpFFT2d(); |
| 258 | |
| 259 | virtual int checkTensorAttributes() final; |
| 260 | virtual int eval() final; |
| 261 | |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 262 | using InEigenType = typename GetEigenType<Dtype>::type; |
| 263 | using OutEigenType = typename GetEigenType<Dtype>::type; |
| 264 | using TIn = Eigen::Tensor<InEigenType, 3>; |
| 265 | using TOut = Eigen::Tensor<OutEigenType, 3>; |
Luke Hutton | 5728713 | 2023-02-06 14:54:18 +0000 | [diff] [blame] | 266 | |
| 267 | protected: |
| 268 | TosaReference::TensorTemplate<TIn>* in_real; |
| 269 | TosaReference::TensorTemplate<TIn>* in_imag; |
| 270 | TosaReference::TensorTemplate<TOut>* out_real; |
| 271 | TosaReference::TensorTemplate<TOut>* out_imag; |
| 272 | tosa::TosaFFTAttribute* attribute; |
| 273 | }; |
| 274 | |
Tai Ly | a4d748b | 2023-03-28 22:06:56 +0000 | [diff] [blame] | 275 | template <TOSA_REF_TYPE Dtype> |
Luke Hutton | 261b7b6 | 2023-01-10 14:50:31 +0000 | [diff] [blame] | 276 | class OpRFFT2d : public GraphNode |
| 277 | { |
| 278 | public: |
| 279 | OpRFFT2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
| 280 | virtual ~OpRFFT2d(); |
| 281 | |
| 282 | virtual int checkTensorAttributes() final; |
| 283 | virtual int eval() final; |
| 284 | |
Jerry Ge | 9c9c8da | 2023-07-19 23:08:16 +0000 | [diff] [blame] | 285 | using InEigenType = typename GetEigenType<Dtype>::type; |
| 286 | using OutEigenType = typename GetEigenType<Dtype>::type; |
| 287 | using TIn = Eigen::Tensor<InEigenType, 3>; |
| 288 | using TOut = Eigen::Tensor<OutEigenType, 3>; |
Luke Hutton | 261b7b6 | 2023-01-10 14:50:31 +0000 | [diff] [blame] | 289 | |
| 290 | protected: |
| 291 | TosaReference::TensorTemplate<TIn>* in; |
| 292 | TosaReference::TensorTemplate<TOut>* out_real; |
| 293 | TosaReference::TensorTemplate<TOut>* out_imag; |
Tai Ly | fd8fde8 | 2023-11-13 20:18:14 +0000 | [diff] [blame] | 294 | tosa::TosaRFFTAttribute* attribute; |
Luke Hutton | 261b7b6 | 2023-01-10 14:50:31 +0000 | [diff] [blame] | 295 | }; |
| 296 | |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 297 | template <TOSA_REF_TYPE InDtype, TOSA_REF_TYPE WeightDtype, TOSA_REF_TYPE AccDtype, TOSA_REF_TYPE OutDtype> |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 298 | class OpTransposeConv2d : public GraphNode |
| 299 | { |
| 300 | public: |
Eric Kunze | b5fabec | 2022-06-07 05:20:44 +0000 | [diff] [blame] | 301 | OpTransposeConv2d(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_); |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 302 | virtual ~OpTransposeConv2d(); |
| 303 | |
| 304 | virtual int checkTensorAttributes() final; |
| 305 | virtual int eval() final; |
| 306 | |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 307 | using InEigenType = typename GetEigenType<InDtype>::type; |
| 308 | using WeightEigenType = typename GetEigenType<WeightDtype>::type; |
Tai Ly | f36f256 | 2024-03-14 16:21:29 +0000 | [diff] [blame] | 309 | using AccEigenType = typename GetAccEigenType<AccDtype>::type; // Note: different from GetEigenType |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 310 | using OutEigenType = typename GetEigenType<OutDtype>::type; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 311 | using TIn = Eigen::Tensor<InEigenType, 4>; |
| 312 | using TWeight = Eigen::Tensor<WeightEigenType, 4>; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 313 | using TBias = Eigen::Tensor<OutEigenType, 1>; |
| 314 | using TOut = Eigen::Tensor<OutEigenType, 4>; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 315 | |
James Ward | d34b3fc | 2023-01-18 14:51:25 +0000 | [diff] [blame] | 316 | static constexpr int64_t AccQMin = GetQMin<OutDtype>::value; |
| 317 | static constexpr int64_t AccQMax = GetQMax<OutDtype>::value; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 318 | |
| 319 | protected: |
| 320 | TosaReference::TensorTemplate<TIn>* input; |
| 321 | TosaReference::TensorTemplate<TWeight>* weight; |
| 322 | TosaReference::TensorTemplate<TBias>* bias; |
James Ward | 8b39043 | 2022-08-12 20:48:56 +0100 | [diff] [blame] | 323 | TosaReference::TensorTemplate<TOut>* output; |
Kevin Cheng | 93a1628 | 2021-08-31 16:14:03 -0700 | [diff] [blame] | 324 | TosaTransposeConvAttribute* attribute; |
Eric Kunze | e5e2676 | 2020-10-13 16:11:07 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | }; // namespace TosaReference |
| 328 | |
| 329 | #endif |