blob: 3bff047f2e29bd92b68c5f80f16d39bb9f921571 [file] [log] [blame]
Eric Kunzee5e26762020-10-13 16:11:07 -07001
Tai Ly8690a082023-12-18 20:40:24 +00002// Copyright (c) 2020-2024, 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 "data_layout.h"
17#include "quant_util.h"
18
19using namespace TosaReference;
20using namespace Eigen;
21using namespace tosa;
22
Tai Lya4d748b2023-03-28 22:06:56 +000023template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +000024OpConcat<Rank, Dtype>::OpConcat(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -070025 : GraphNode(sgt_, Op_CONCAT, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -070026{
Kevin Chengad15dfa2021-03-04 15:15:03 -080027 setRequiredOperands(-1, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +000028 setRequiredRank(1);
Eric Kunzee5e26762020-10-13 16:11:07 -070029
30 INIT_ATTRIBUTE(Axis);
31}
32
Tai Lya4d748b2023-03-28 22:06:56 +000033template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -070034OpConcat<Rank, Dtype>::~OpConcat()
35{
36 if (attribute)
37 delete attribute;
38}
39
Tai Lya4d748b2023-03-28 22:06:56 +000040template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -070041int OpConcat<Rank, Dtype>::checkTensorAttributes()
42{
Jerry Gea793f462023-04-11 00:05:02 +000043 // Check Tosa Level
44 auto tosa_level = g_func_config.tosa_level;
45 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
46
Eric Kunzee5e26762020-10-13 16:11:07 -070047 if (validateRequiredOperands())
48 return 1;
49
Kevin Chengad15dfa2021-03-04 15:15:03 -080050 if (inputs.empty())
Eric Kunzee5e26762020-10-13 16:11:07 -070051 {
Kevin Chengad15dfa2021-03-04 15:15:03 -080052 printNodeValidationError("Concat operator must have at least one input tensor");
Eric Kunzee5e26762020-10-13 16:11:07 -070053 return 1;
54 }
Kevin Chengcc61be32021-10-14 17:09:57 -070055
56 int32_t num_inputs = inputs.size();
57
Eric Kunzee5e26762020-10-13 16:11:07 -070058 // output and input must be the same types and rank
Kevin Chengcc61be32021-10-14 17:09:57 -070059 for (int32_t i = 0; i < num_inputs; i++)
Eric Kunzee5e26762020-10-13 16:11:07 -070060 {
Kevin Chengad15dfa2021-03-04 15:15:03 -080061 if (inputs[i]->matchRankType(*outputs[0]))
62 {
Kevin Chengcc61be32021-10-14 17:09:57 -070063 printNodeValidationError("OpConcat: input ranks and types must match");
Kevin Chengad15dfa2021-03-04 15:15:03 -080064 return 1;
65 }
66 ins.push_back(dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[i]));
Eric Kunzee5e26762020-10-13 16:11:07 -070067 }
68
Kevin Chengcc61be32021-10-14 17:09:57 -070069 if (attribute->axis() < 0 || (size_t)attribute->axis() >= Rank)
Eric Kunzee5e26762020-10-13 16:11:07 -070070 {
Kevin Chengcc61be32021-10-14 17:09:57 -070071 printNodeValidationError("OpConcat: axis is beyond output tensor rank");
Eric Kunzee5e26762020-10-13 16:11:07 -070072 return 1;
73 }
74
Kevin Chengcc61be32021-10-14 17:09:57 -070075 int32_t output_dim_on_axis = 0;
76 for (int32_t j = 0; j < num_inputs; j++)
77 {
78 for (int32_t i = 0; i < Rank; i++)
79 {
80 int32_t input_dim = inputs[j]->getShape()[i];
81 if (i == attribute->axis())
82 {
83 output_dim_on_axis += input_dim;
84 }
85 else if (input_dim != outputs[0]->getShape()[i])
86 {
87 printNodeValidationError("OpConcat: input dimension not matching output dimension");
88 return 1;
89 }
90 }
91 }
92
Kevin Cheng6e528662021-10-20 17:35:33 +000093 ERROR_IF(output_dim_on_axis != outputs[0]->getShape()[attribute->axis()],
Kevin Chengcc61be32021-10-14 17:09:57 -070094 "OpConcat: sum of input dimension on axis not equal to output dimension on axis");
95
96 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
97
Eric Kunzee5e26762020-10-13 16:11:07 -070098 return 0;
99}
100
Tai Lya4d748b2023-03-28 22:06:56 +0000101template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700102int OpConcat<Rank, Dtype>::eval()
103{
104
105 int32_t reversed_axis = Rank - 1 - attribute->axis();
106
107 for (int32_t d = 0; d < Rank; d++)
108 {
109 reverser[d] = Rank - 1 - d;
110 }
111
Kevin Chengad15dfa2021-03-04 15:15:03 -0800112 TIn result = ins[0]->getTensor().shuffle(reverser);
Eric Kunzee5e26762020-10-13 16:11:07 -0700113
Kevin Chengad15dfa2021-03-04 15:15:03 -0800114 for (size_t i = 1; i < ins.size(); i++)
115 {
116 TIn in_reversed = ins[i]->getTensor().shuffle(reverser);
117 TIn temp = result.concatenate(in_reversed, reversed_axis);
118 result = temp;
119 }
120 out->getTensor() = result.shuffle(reverser);
Eric Kunzee5e26762020-10-13 16:11:07 -0700121
122 return GraphNode::eval();
123}
124
Tai Lya4d748b2023-03-28 22:06:56 +0000125template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000126OpPad<Rank, Dtype>::OpPad(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700127 : GraphNode(sgt_, Op_PAD, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700128{
Tai Lye095da72024-01-25 22:00:18 +0000129 setRequiredOperands(2, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +0000130 setRequiredRank(1);
Eric Kunzee5e26762020-10-13 16:11:07 -0700131
Kevin Chengfe392ce2021-10-18 21:51:55 +0000132 INIT_ATTRIBUTE(Pad);
Eric Kunzee5e26762020-10-13 16:11:07 -0700133}
134
Tai Lya4d748b2023-03-28 22:06:56 +0000135template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700136OpPad<Rank, Dtype>::~OpPad()
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000137{}
Eric Kunzee5e26762020-10-13 16:11:07 -0700138
Tai Lya4d748b2023-03-28 22:06:56 +0000139template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700140int OpPad<Rank, Dtype>::checkTensorAttributes()
141{
Jerry Gea793f462023-04-11 00:05:02 +0000142 // Check Tosa Level
143 auto tosa_level = g_func_config.tosa_level;
144 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
145
Eric Kunzee5e26762020-10-13 16:11:07 -0700146 if (validateRequiredOperands())
147 return 1;
148
149 if (validateRequiredRank(inputs[0]) || validateRequiredRank(outputs[0]))
150 {
151 return 1;
152 }
153
154 // output and input must be the same types
155 if (inputs[0]->matchRankType(*outputs[0]))
156 {
157 printNodeValidationError("Failure to match input and output type and rank");
158 return 1;
159 }
160
Tai Lye095da72024-01-25 22:00:18 +0000161 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
162 padding = dynamic_cast<TosaReference::TensorTemplate<TPadding>*>(inputs[1]);
163 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
Kevin Chengfe392ce2021-10-18 21:51:55 +0000164 ASSERT_MEM(in && out);
165
Eric Kunzee5e26762020-10-13 16:11:07 -0700166 return 0;
167}
168
Tai Lya4d748b2023-03-28 22:06:56 +0000169template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700170int OpPad<Rank, Dtype>::eval()
171{
Kevin Chengfe392ce2021-10-18 21:51:55 +0000172 InEigenType pad_value = 0;
173
174 switch (Dtype)
Kevin Chengcc61be32021-10-14 17:09:57 -0700175 {
Tai Lya4d748b2023-03-28 22:06:56 +0000176 case TOSA_REF_TYPE_BOOL:
177 case TOSA_REF_TYPE_INT8:
178 case TOSA_REF_TYPE_INT16:
179 case TOSA_REF_TYPE_INT32:
Kevin Chengfe392ce2021-10-18 21:51:55 +0000180 pad_value = (InEigenType)attribute->pad_const_int();
181 break;
Tai Lya4d748b2023-03-28 22:06:56 +0000182 case TOSA_REF_TYPE_FP16:
183 case TOSA_REF_TYPE_BF16:
184 case TOSA_REF_TYPE_FP32:
185 case TOSA_REF_TYPE_FP64:
Kevin Chengfe392ce2021-10-18 21:51:55 +0000186 pad_value = (InEigenType)attribute->pad_const_fp();
187 break;
TatWai Chong86c403b2022-06-06 20:46:01 -0700188 default:
189 printNodeValidationError("Unsupported data type");
190 break;
Kevin Chengcc61be32021-10-14 17:09:57 -0700191 }
192
Tai Lye095da72024-01-25 22:00:18 +0000193 // padding is an 1D array of [Rank * 2], with ordering:
194 // [Rank0_front, Rank0_back, Rank1_front, Rank1_back, ..., Rank(N-1)_front, Rank(N-1)_back]
195 TPadding padding_val = this->padding->getTensor();
196 ERROR_IF(padding_val.size() != (Rank * 2), "OpPad: padding length needs to be (rank(input1) * 2)");
197 for (int i = 0; i < Rank; i++)
198 {
199 auto pad_front = padding_val(2 * i);
200 auto pad_back = padding_val(2 * i + 1);
201 ERROR_IF((pad_front < 0) || (pad_back < 0), "OpPad: padding can't be smaller than 0");
202 ERROR_IF(out->getShape()[i] != pad_front + in->getShape()[i] + pad_back,
203 "OpPad: output shape not equal to input plus padding");
204 paddings_array[i] = std::make_pair(pad_front, pad_back);
205 }
206
Eric Kunzee5e26762020-10-13 16:11:07 -0700207 this->out->getTensor() = this->in->getTensor().pad(this->paddings_array, pad_value);
208
209 return GraphNode::eval();
210}
211
Won Jeona21b2e82023-08-10 10:33:01 +0000212template <int Rank, TOSA_REF_TYPE Dtype>
213OpDim<Rank, Dtype>::OpDim(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
214 : GraphNode(sgt_, Op_DIM, id_)
215{
216 setRequiredOperands(1, 1);
217
218 INIT_ATTRIBUTE(Axis);
219}
220
221template <int Rank, TOSA_REF_TYPE Dtype>
222OpDim<Rank, Dtype>::~OpDim()
223{
224 if (attribute)
225 delete attribute;
226}
227
228template <int Rank, TOSA_REF_TYPE Dtype>
229int OpDim<Rank, Dtype>::checkTensorAttributes()
230{
231 // Check Tosa Level
232 auto tosa_level = g_func_config.tosa_level;
233 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
234
235 if (validateRequiredOperands())
236 return 1;
237
238 if (validateRequiredRank(inputs[0]))
239 return 1;
240
241 if (attribute->axis() < 0 || (size_t)attribute->axis() >= Rank)
242 {
243 printNodeValidationError("OpDim: axis must between [0, input_rank - 1]");
244 return 1;
245 }
246
247 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
248 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
249
250 ASSERT_MEM(in && out);
251
252 return 0;
253}
254
255template <int Rank, TOSA_REF_TYPE Dtype>
256int OpDim<Rank, Dtype>::eval()
257{
258 int32_t axis = attribute->axis();
259 int64_t out_val = in->getShape()[axis];
260
Tai Ly8690a082023-12-18 20:40:24 +0000261 this->out->getTensor().setValues({ out_val });
Won Jeona21b2e82023-08-10 10:33:01 +0000262
263 return GraphNode::eval();
264}
265
Tai Lya4d748b2023-03-28 22:06:56 +0000266template <int InRank, int OutRank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000267OpReshape<InRank, OutRank, Dtype>::OpReshape(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700268 : GraphNode(sgt_, Op_RESHAPE, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700269{
Tai Ly8690a082023-12-18 20:40:24 +0000270 setRequiredOperands(2, 1);
Eric Kunzee5e26762020-10-13 16:11:07 -0700271}
272
Tai Lya4d748b2023-03-28 22:06:56 +0000273template <int InRank, int OutRank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700274OpReshape<InRank, OutRank, Dtype>::~OpReshape()
Tai Ly8690a082023-12-18 20:40:24 +0000275{}
Eric Kunzee5e26762020-10-13 16:11:07 -0700276
Tai Lya4d748b2023-03-28 22:06:56 +0000277template <int InRank, int OutRank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700278int OpReshape<InRank, OutRank, Dtype>::checkTensorAttributes()
279{
Jerry Gea793f462023-04-11 00:05:02 +0000280 // Check Tosa Level
281 auto tosa_level = g_func_config.tosa_level;
282 LEVEL_CHECK(InRank <= tosa_level.MAX_RANK, "InRank should be smaller than or equal to MAX_RANK");
283 LEVEL_CHECK(OutRank <= tosa_level.MAX_RANK, "OutRank should be smaller than or equal to MAX_RANK");
284
Eric Kunzee5e26762020-10-13 16:11:07 -0700285 if (validateRequiredOperands())
286 return 1;
287
Eric Kunzee5e26762020-10-13 16:11:07 -0700288 // output and input must be the same types
289 if (inputs[0]->matchType(*outputs[0]))
290 {
291 printNodeValidationError("OpReshape: Input and output types must match");
292 return 1;
293 }
294
Kevin Chengcc61be32021-10-14 17:09:57 -0700295 ERROR_IF(inputs[0]->getElementCount() != outputs[0]->getElementCount(),
296 "Input tensor size does not match output tensor size");
297
Eric Kunzee5e26762020-10-13 16:11:07 -0700298 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
299 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
300
Tai Ly8690a082023-12-18 20:40:24 +0000301 // note: do not assert mem on shape input, because it may be {} for reshape to scalar
302 // and also, because the shape input is not actually used in eval()
303
304 ASSERT_MEM(in && out)
305
Eric Kunzee5e26762020-10-13 16:11:07 -0700306 return 0;
307}
308
Tai Lya4d748b2023-03-28 22:06:56 +0000309template <int InRank, int OutRank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700310int OpReshape<InRank, OutRank, Dtype>::eval()
311{
Eric Kunzee5e26762020-10-13 16:11:07 -0700312 for (int32_t d = 0; d < OutRank; d++)
313 {
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000314 array_shape[d] = getOutputs()[0]->getShape()[OutRank - 1 - d];
Eric Kunzee5e26762020-10-13 16:11:07 -0700315 out_reverser[d] = OutRank - 1 - d;
Eric Kunzee5e26762020-10-13 16:11:07 -0700316 }
317
318 for (int32_t d = 0; d < InRank; d++)
319 {
320 in_reverser[d] = InRank - 1 - d;
321 }
322
323 // Eigen Tensor is col-major, and we're referencing row-major result
324 // need to reverse it to row-major before reshape, and perform another reverse afterward
325
326 // input tensor rank 0 can't do .shuffle(), need to be handled otherwise
327 TIn in_reversed;
328 if (InRank > 1)
329 {
330 in_reversed = in->getTensor().shuffle(in_reverser);
331 }
332 else
333 {
334 in_reversed = in->getTensor();
335 }
336
337 TOut in_reshaped = in_reversed.reshape(array_shape);
338
339 // output tensor can be rank 0, .reshape() and .shuffle() don't work, need to be handled otherwise
340 if (OutRank > 1)
341 {
342 out->getTensor() = in_reshaped.shuffle(out_reverser);
343 }
344 else
345 {
346 out->getTensor() = in_reshaped;
347 }
348
349 return GraphNode::eval();
350}
351
Tai Lya4d748b2023-03-28 22:06:56 +0000352template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000353OpReverse<Rank, Dtype>::OpReverse(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700354 : GraphNode(sgt_, Op_REVERSE, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700355{
356 setRequiredOperands(1, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +0000357 setRequiredRank(1);
Eric Kunzee5e26762020-10-13 16:11:07 -0700358
359 INIT_ATTRIBUTE(Axis);
360}
361
Tai Lya4d748b2023-03-28 22:06:56 +0000362template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700363OpReverse<Rank, Dtype>::~OpReverse()
364{
365 if (attribute)
366 delete attribute;
367}
368
Tai Lya4d748b2023-03-28 22:06:56 +0000369template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700370int OpReverse<Rank, Dtype>::checkTensorAttributes()
371{
Jerry Gea793f462023-04-11 00:05:02 +0000372 // Check Tosa Level
373 auto tosa_level = g_func_config.tosa_level;
374 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
375
Eric Kunzee5e26762020-10-13 16:11:07 -0700376 if (validateRequiredOperands())
377 return 1;
378
379 if (validateRequiredRank(inputs[0]) || validateRequiredRank(outputs[0]))
380 {
381 return 1;
382 }
383
384 // output and input must be the same types
385 if (inputs[0]->matchRankTypeShape(*outputs[0]))
386 {
387 printNodeValidationError("Failure to match input and output rank/type/shape");
388 return 1;
389 }
390
391 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
392 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
393
394 ASSERT_MEM(in && out);
395
396 if (attribute->axis() < 0 || attribute->axis() >= inputs[0]->getRank())
397 {
398 printNodeValidationError("Reverse axis must between [0, input_rank - 1]");
399 return 1;
400 }
401
402 // transform list of axis into true or false list
403 // e.g. rank=4, axis=[1,2], reverse array would be [false, true, true, false]
404 for (int i = 0; i < Rank; i++)
405 {
406 reverse_array[i] = false;
407 }
408 reverse_array[attribute->axis()] = true;
409
410 return 0;
411}
412
Tai Lya4d748b2023-03-28 22:06:56 +0000413template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700414int OpReverse<Rank, Dtype>::eval()
415{
416 out->getTensor() = in->getTensor().reverse(reverse_array);
417
418 return GraphNode::eval();
419}
420
Tai Lya4d748b2023-03-28 22:06:56 +0000421template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000422OpSlice<Rank, Dtype>::OpSlice(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700423 : GraphNode(sgt_, Op_SLICE, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700424{
TatWai Chong01f937a2024-01-24 22:57:07 -0800425 setRequiredOperands(3, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +0000426 setRequiredRank(1);
Eric Kunzee5e26762020-10-13 16:11:07 -0700427}
428
Tai Lya4d748b2023-03-28 22:06:56 +0000429template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700430OpSlice<Rank, Dtype>::~OpSlice()
TatWai Chong01f937a2024-01-24 22:57:07 -0800431{}
Eric Kunzee5e26762020-10-13 16:11:07 -0700432
Tai Lya4d748b2023-03-28 22:06:56 +0000433template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700434int OpSlice<Rank, Dtype>::checkTensorAttributes()
435{
Jerry Gea793f462023-04-11 00:05:02 +0000436 // Check Tosa Level
437 auto tosa_level = g_func_config.tosa_level;
438 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
439
Eric Kunzee5e26762020-10-13 16:11:07 -0700440 if (validateRequiredOperands())
441 return 1;
442
443 if (validateRequiredRank(inputs[0]) || validateRequiredRank(outputs[0]))
444 {
445 return 1;
446 }
447
448 // output and input must be the same types
Luke Huttona4e48ca2023-02-22 11:53:48 +0000449 if (inputs[0]->matchRankType(*outputs[0]))
Eric Kunzee5e26762020-10-13 16:11:07 -0700450 {
Luke Huttona4e48ca2023-02-22 11:53:48 +0000451 printNodeValidationError("Failure to match input and output rank or type");
Eric Kunzee5e26762020-10-13 16:11:07 -0700452 return 1;
453 }
454
TatWai Chong01f937a2024-01-24 22:57:07 -0800455 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
TatWai Chong97f1c0e2024-02-05 11:56:46 -0800456 start = dynamic_cast<TosaReference::TensorTemplate<TSlicing>*>(inputs[1]);
457 size = dynamic_cast<TosaReference::TensorTemplate<TSlicing>*>(inputs[2]);
TatWai Chong01f937a2024-01-24 22:57:07 -0800458 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
Eric Kunzee5e26762020-10-13 16:11:07 -0700459
TatWai Chong97f1c0e2024-02-05 11:56:46 -0800460 ASSERT_MEM(in && out && start && size);
Luke Huttona4e48ca2023-02-22 11:53:48 +0000461
TatWai Chong01f937a2024-01-24 22:57:07 -0800462 return 0;
463}
464
465template <int Rank, TOSA_REF_TYPE Dtype>
466int OpSlice<Rank, Dtype>::eval()
467{
TatWai Chong97f1c0e2024-02-05 11:56:46 -0800468 TSlicing start_tensor = start->getTensor();
469 TSlicing size_tensor = size->getTensor();
470
471 // According to https://eigen.tuxfamily.org/dox/unsupported/eigen_tensors.html
472 // The type of size() is <Tensor-Type>::Index, but can always handily use it like an int.
473 // However, apply explicit cast to int32_t is preferred.
474 ERROR_IF(static_cast<int32_t>(start_tensor.size()) != in->getRank(),
475 "OpSlice: start array length needs to be rank(input)");
476 ERROR_IF(static_cast<int32_t>(size_tensor.size()) != in->getRank(),
477 "OpSlice: size array length needs to be rank(input)");
Eric Kunzee5e26762020-10-13 16:11:07 -0700478
Kevin Chengcc61be32021-10-14 17:09:57 -0700479 for (int32_t i = 0; i < in->getRank(); i++)
Eric Kunzee5e26762020-10-13 16:11:07 -0700480 {
TatWai Chong97f1c0e2024-02-05 11:56:46 -0800481 int32_t b = start_tensor(i);
482 int32_t s = size_tensor(i);
Kevin Chengcc61be32021-10-14 17:09:57 -0700483 ERROR_IF(b < 0 || b >= in->getShape()[i], "OpSlice: start out of boundary");
484 ERROR_IF((b + s) < 0 || (b + s) > in->getShape()[i], "OpSlice: (start+size) out of boundary");
485 ERROR_IF(s <= 0, "OpSlice: output must be positive");
486 ERROR_IF(s != out->getShape()[i], "OpSlice: size doesn't match output tensor dimension");
487 begin_array[i] = b;
488 size_array[i] = s;
Eric Kunzee5e26762020-10-13 16:11:07 -0700489 }
490
Eric Kunzee5e26762020-10-13 16:11:07 -0700491 out->getTensor() = in->getTensor().slice(begin_array, size_array);
492
493 return GraphNode::eval();
494}
495
Tai Lya4d748b2023-03-28 22:06:56 +0000496template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000497OpTileBase<Rank, Dtype>::OpTileBase(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700498 : GraphNode(sgt_, Op_TILE, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700499{
Tai Ly8690a082023-12-18 20:40:24 +0000500 setRequiredOperands(2, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +0000501 setRequiredRank(1);
Eric Kunzee5e26762020-10-13 16:11:07 -0700502}
503
Tai Lya4d748b2023-03-28 22:06:56 +0000504template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700505OpTileBase<Rank, Dtype>::~OpTileBase()
Tai Ly8690a082023-12-18 20:40:24 +0000506{}
Eric Kunzee5e26762020-10-13 16:11:07 -0700507
Tai Lya4d748b2023-03-28 22:06:56 +0000508template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700509int OpTileBase<Rank, Dtype>::checkTensorAttributes()
510{
Jerry Gea793f462023-04-11 00:05:02 +0000511 // Check Tosa Level
512 auto tosa_level = g_func_config.tosa_level;
513 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
514
Eric Kunzee5e26762020-10-13 16:11:07 -0700515 if (validateRequiredOperands())
516 return 1;
517
518 if (validateRequiredRank(inputs[0]) || validateRequiredRank(outputs[0]))
519 {
520 return 1;
521 }
522
523 // output and input must be the same ranks and types
524 if (inputs[0]->matchRankType(*outputs[0]))
525 {
526 printNodeValidationError("Failure to match input and output rank or type");
527 return 1;
528 }
529
Tai Ly8690a082023-12-18 20:40:24 +0000530 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
531 multiples = dynamic_cast<TosaReference::TensorTemplate<TInMultiples>*>(inputs[1]);
532 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
Eric Kunzee5e26762020-10-13 16:11:07 -0700533
Tai Ly8690a082023-12-18 20:40:24 +0000534 ASSERT_MEM(in && multiples && out);
Luke Huttona4e48ca2023-02-22 11:53:48 +0000535
Tai Ly8690a082023-12-18 20:40:24 +0000536 if (multiples->getElementCount() != Rank)
Eric Kunzee5e26762020-10-13 16:11:07 -0700537 {
538 printNodeValidationError("1D list 'multiples' must have size equal to input rank");
539 return 1;
540 }
541
Eric Kunzee5e26762020-10-13 16:11:07 -0700542 return 0;
543}
544
Tai Lya4d748b2023-03-28 22:06:56 +0000545template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700546int OpTile<Rank, Dtype>::eval()
547{
548 // primary template shouldn't be called
Tai Lya4d748b2023-03-28 22:06:56 +0000549 FATAL_ERROR("OpTile rank=%i, dtype=%s: not implemented yet", Rank, EnumNameTOSAREFTYPE(Dtype));
Eric Kunzee5e26762020-10-13 16:11:07 -0700550}
551
Tai Lya4d748b2023-03-28 22:06:56 +0000552template <TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700553int OpTile<1, Dtype>::eval()
554{
555 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
556 {
557 int32_t id0 = od0 % this->in->getShape()[0];
558 this->out->getTensor()(od0) = this->in->getTensor()(id0);
559 }
560
561 return GraphNode::eval();
562}
563
Tai Lya4d748b2023-03-28 22:06:56 +0000564template <TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700565int OpTile<2, Dtype>::eval()
566{
567 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
568 {
569 int32_t id0 = od0 % this->in->getShape()[0];
570 for (int32_t od1 = 0; od1 < this->out->getShape()[1]; od1++)
571 {
572 int32_t id1 = od1 % this->in->getShape()[1];
573 this->out->getTensor()(od0, od1) = this->in->getTensor()(id0, id1);
574 }
575 }
576
577 return GraphNode::eval();
578}
579
Tai Lya4d748b2023-03-28 22:06:56 +0000580template <TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700581int OpTile<3, Dtype>::eval()
582{
583 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
584 {
585 int32_t id0 = od0 % this->in->getShape()[0];
586 for (int32_t od1 = 0; od1 < this->out->getShape()[1]; od1++)
587 {
588 int32_t id1 = od1 % this->in->getShape()[1];
589 for (int32_t od2 = 0; od2 < this->out->getShape()[2]; od2++)
590 {
591 int32_t id2 = od2 % this->in->getShape()[2];
592 this->out->getTensor()(od0, od1, od2) = this->in->getTensor()(id0, id1, id2);
593 }
594 }
595 }
596
597 return GraphNode::eval();
598}
599
Tai Lya4d748b2023-03-28 22:06:56 +0000600template <TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700601int OpTile<4, Dtype>::eval()
602{
603 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
604 {
605 int32_t id0 = od0 % this->in->getShape()[0];
606 for (int32_t od1 = 0; od1 < this->out->getShape()[1]; od1++)
607 {
608 int32_t id1 = od1 % this->in->getShape()[1];
609 for (int32_t od2 = 0; od2 < this->out->getShape()[2]; od2++)
610 {
611 int32_t id2 = od2 % this->in->getShape()[2];
612 for (int32_t od3 = 0; od3 < this->out->getShape()[3]; od3++)
613 {
614 int32_t id3 = od3 % this->in->getShape()[3];
615 this->out->getTensor()(od0, od1, od2, od3) = this->in->getTensor()(id0, id1, id2, id3);
616 }
617 }
618 }
619 }
620
621 return GraphNode::eval();
622}
623
Tai Lya4d748b2023-03-28 22:06:56 +0000624template <TOSA_REF_TYPE Dtype>
Luke Huttona4e48ca2023-02-22 11:53:48 +0000625int OpTile<5, Dtype>::eval()
626{
627 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
628 {
629 int32_t id0 = od0 % this->in->getShape()[0];
630 for (int32_t od1 = 0; od1 < this->out->getShape()[1]; od1++)
631 {
632 int32_t id1 = od1 % this->in->getShape()[1];
633 for (int32_t od2 = 0; od2 < this->out->getShape()[2]; od2++)
634 {
635 int32_t id2 = od2 % this->in->getShape()[2];
636 for (int32_t od3 = 0; od3 < this->out->getShape()[3]; od3++)
637 {
638 int32_t id3 = od3 % this->in->getShape()[3];
639 for (int32_t od4 = 0; od4 < this->out->getShape()[4]; od4++)
640 {
641 int32_t id4 = od4 % this->in->getShape()[4];
642 this->out->getTensor()(od0, od1, od2, od3, od4) =
643 this->in->getTensor()(id0, id1, id2, id3, id4);
644 }
645 }
646 }
647 }
648 }
649
650 return GraphNode::eval();
651}
652
Tai Lya4d748b2023-03-28 22:06:56 +0000653template <TOSA_REF_TYPE Dtype>
Luke Huttona4e48ca2023-02-22 11:53:48 +0000654int OpTile<6, Dtype>::eval()
655{
656 for (int32_t od0 = 0; od0 < this->out->getShape()[0]; od0++)
657 {
658 int32_t id0 = od0 % this->in->getShape()[0];
659 for (int32_t od1 = 0; od1 < this->out->getShape()[1]; od1++)
660 {
661 int32_t id1 = od1 % this->in->getShape()[1];
662 for (int32_t od2 = 0; od2 < this->out->getShape()[2]; od2++)
663 {
664 int32_t id2 = od2 % this->in->getShape()[2];
665 for (int32_t od3 = 0; od3 < this->out->getShape()[3]; od3++)
666 {
667 int32_t id3 = od3 % this->in->getShape()[3];
668 for (int32_t od4 = 0; od4 < this->out->getShape()[4]; od4++)
669 {
670 int32_t id4 = od4 % this->in->getShape()[4];
671 for (int32_t od5 = 0; od5 < this->out->getShape()[5]; od5++)
672 {
673 int32_t id5 = od5 % this->in->getShape()[5];
674 this->out->getTensor()(od0, od1, od2, od3, od4, od5) =
675 this->in->getTensor()(id0, id1, id2, id3, id4, id5);
676 }
677 }
678 }
679 }
680 }
681 }
682
683 return GraphNode::eval();
684}
685
Tai Lya4d748b2023-03-28 22:06:56 +0000686template <int Rank, TOSA_REF_TYPE Dtype>
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000687OpTranspose<Rank, Dtype>::OpTranspose(SubgraphTraverser* sgt_, TosaAttributeBase* attribute_, uint64_t id_)
Kevin Chengacb550f2021-06-29 15:32:19 -0700688 : GraphNode(sgt_, Op_TRANSPOSE, id_)
Eric Kunzee5e26762020-10-13 16:11:07 -0700689{
Kevin Chengfe392ce2021-10-18 21:51:55 +0000690 setRequiredOperands(1, 1);
Jerry Ge0bd4ec82023-05-01 18:36:43 +0000691 setRequiredRank(1);
Kevin Chengfe392ce2021-10-18 21:51:55 +0000692
693 INIT_ATTRIBUTE(Transpose);
Eric Kunzee5e26762020-10-13 16:11:07 -0700694}
695
Tai Lya4d748b2023-03-28 22:06:56 +0000696template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700697OpTranspose<Rank, Dtype>::~OpTranspose()
Jerry Gea6827492022-11-16 10:41:55 -0800698{
Jerry Ge9c9c8da2023-07-19 23:08:16 +0000699 if (attribute)
700 delete attribute;
Jerry Gea6827492022-11-16 10:41:55 -0800701}
Eric Kunzee5e26762020-10-13 16:11:07 -0700702
Tai Lya4d748b2023-03-28 22:06:56 +0000703template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700704int OpTranspose<Rank, Dtype>::checkTensorAttributes()
705{
Jerry Gea793f462023-04-11 00:05:02 +0000706 // Check Tosa Level
707 auto tosa_level = g_func_config.tosa_level;
708 LEVEL_CHECK(Rank <= tosa_level.MAX_RANK, "Rank should be smaller than or equal to MAX_RANK");
709
Eric Kunzee5e26762020-10-13 16:11:07 -0700710 if (validateRequiredOperands())
711 return 1;
712
713 if (validateRequiredRank(inputs[0]) || validateRequiredRank(outputs[0]))
714 {
715 return 1;
716 }
717
718 // output and input must be the same types
719 if (inputs[0]->matchRankType(*outputs[0]))
720 {
721 printNodeValidationError("Failure to match input and output rank and type");
722 return 1;
723 }
724
725 if (inputs[0]->getElementCount() != outputs[0]->getElementCount())
726 {
727 printNodeValidationError("Failure to match input and output total element count");
728 return 1;
729 }
730
Kevin Chengfe392ce2021-10-18 21:51:55 +0000731 in = dynamic_cast<TosaReference::TensorTemplate<TIn>*>(inputs[0]);
732 out = dynamic_cast<TosaReference::TensorTemplate<TOut>*>(outputs[0]);
733
734 ASSERT_MEM(in && out);
Eric Kunzee5e26762020-10-13 16:11:07 -0700735
TatWai Chong86c403b2022-06-06 20:46:01 -0700736 ERROR_IF(attribute->perms().size() != Rank, "OpTranspose: perms array size needs to match rank(input)");
Kevin Chengf3e016f2021-11-02 01:15:50 +0000737
738 std::array<bool, Rank> index_used;
739 index_used.fill(false);
740 for (int32_t d = 0; d < Rank; d++)
741 {
TatWai Chong86c403b2022-06-06 20:46:01 -0700742 int32_t index = attribute->perms()[d];
Kevin Chengf3e016f2021-11-02 01:15:50 +0000743 ERROR_IF(index < 0 or index >= Rank, "OpTranspose: index out of boundary");
744 ERROR_IF(index_used[index], "OpTranspose: index duplicated in perm attribute");
745 index_used[index] = true;
746 ERROR_IF(in->getShape()[index] != out->getShape()[d], "OpTranspose: input output shape mismatch");
747 perm_array[d] = index;
748 }
749
Eric Kunzee5e26762020-10-13 16:11:07 -0700750 return 0;
751}
752
Tai Lya4d748b2023-03-28 22:06:56 +0000753template <int Rank, TOSA_REF_TYPE Dtype>
Eric Kunzee5e26762020-10-13 16:11:07 -0700754int OpTranspose<Rank, Dtype>::eval()
755{
Eric Kunzee5e26762020-10-13 16:11:07 -0700756 out->getTensor() = in->getTensor().shuffle(perm_array);
757
758 return GraphNode::eval();
759}
760
761// template explicit instantiation
James Ward8b390432022-08-12 20:48:56 +0100762DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, FP16)
James Ward24dbc422022-10-19 12:20:31 +0100763DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, BF16)
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +0100764DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, FP32)
Eric Kunzee5e26762020-10-13 16:11:07 -0700765DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, INT8)
766DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, INT16)
767DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, INT32)
768DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, BOOL)
Tai Lya4d748b2023-03-28 22:06:56 +0000769DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, FP64)
Won Jeon2c34b462024-02-06 18:37:00 +0000770DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, FP8E4M3);
771DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpConcat, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700772
James Ward8b390432022-08-12 20:48:56 +0100773DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, FP16);
James Ward24dbc422022-10-19 12:20:31 +0100774DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +0100775DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -0700776DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, INT8);
777DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, INT16);
778DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, INT32);
779DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000780DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000781DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, FP8E4M3);
782DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpPad, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700783
Won Jeona21b2e82023-08-10 10:33:01 +0000784DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, FP16);
785DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, BF16);
786DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, FP32);
787DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, INT8);
788DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, INT16);
789DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, INT32);
790DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, BOOL);
Won Jeon2c34b462024-02-06 18:37:00 +0000791DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, FP8E4M3);
792DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpDim, FP8E5M2);
Won Jeona21b2e82023-08-10 10:33:01 +0000793
James Ward8b390432022-08-12 20:48:56 +0100794DEF_INSTANTIATE_RESHAPE(OpReshape, FP16);
James Ward24dbc422022-10-19 12:20:31 +0100795DEF_INSTANTIATE_RESHAPE(OpReshape, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +0100796DEF_INSTANTIATE_RESHAPE(OpReshape, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -0700797DEF_INSTANTIATE_RESHAPE(OpReshape, INT8);
798DEF_INSTANTIATE_RESHAPE(OpReshape, INT16);
799DEF_INSTANTIATE_RESHAPE(OpReshape, INT32);
800DEF_INSTANTIATE_RESHAPE(OpReshape, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000801DEF_INSTANTIATE_RESHAPE(OpReshape, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000802DEF_INSTANTIATE_RESHAPE(OpReshape, FP8E4M3);
803DEF_INSTANTIATE_RESHAPE(OpReshape, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700804
James Ward8b390432022-08-12 20:48:56 +0100805DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, FP16);
James Ward24dbc422022-10-19 12:20:31 +0100806DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, BF16);
Jeremy Johnsonbc2a3db2022-09-27 13:50:00 +0100807DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, FP32);
Eric Kunzee5e26762020-10-13 16:11:07 -0700808DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, INT8);
809DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, INT16);
810DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, INT32);
811DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000812DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000813DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, FP8E4M3);
814DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpReverse, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700815
Luke Huttona4e48ca2023-02-22 11:53:48 +0000816DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, FP16);
817DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, BF16);
818DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, FP32);
819DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, INT8);
820DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, INT16);
821DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, INT32);
822DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000823DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000824DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, FP8E4M3);
825DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpSlice, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700826
Luke Huttona4e48ca2023-02-22 11:53:48 +0000827DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, FP16);
828DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, BF16);
829DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, FP32);
830DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, INT8);
831DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, INT16);
832DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, INT32);
833DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000834DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000835DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, FP8E4M3);
836DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTileBase, FP8E5M2);
Jared Smolens98c281f2022-12-20 15:09:25 -0800837
Luke Huttona4e48ca2023-02-22 11:53:48 +0000838DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, FP16);
839DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, BF16);
840DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, FP32);
841DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, INT8);
842DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, INT16);
843DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, INT32);
844DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000845DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000846DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, FP8E4M3);
847DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTile, FP8E5M2);
Eric Kunzee5e26762020-10-13 16:11:07 -0700848
Luke Huttona4e48ca2023-02-22 11:53:48 +0000849DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, FP16);
850DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, BF16);
851DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, FP32);
852DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, INT8);
853DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, INT16);
854DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, INT32);
855DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, BOOL);
Tai Lya4d748b2023-03-28 22:06:56 +0000856DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, FP64);
Won Jeon2c34b462024-02-06 18:37:00 +0000857DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, FP8E4M3);
858DEF_INSTANTIATE_RANK1_6_ONE_RANK_ONE_TYPE(OpTranspose, FP8E5M2);