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