ArmNN
 22.02
WorkloadData.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "TensorHandle.hpp"
8 
9 #include <armnn/Deprecated.hpp>
10 #include <armnn/Descriptors.hpp>
11 #include <armnn/Exceptions.hpp>
12 #include <armnn/Types.hpp>
13 #include <armnn/Tensor.hpp>
14 #include <common/include/ProfilingGuid.hpp>
15 
16 namespace armnn
17 {
18 
19 //A helper function that returns the bias data type required for given input data type.
20 DataType GetBiasDataType(DataType inputDataType);
21 
22 struct WorkloadInfo;
23 
25 {
26  std::vector<ITensorHandle*> m_Inputs;
27  std::vector<ITensorHandle*> m_Outputs;
29 
30  virtual ~QueueDescriptor() = default;
31 
32  void ValidateInputsOutputs(const std::string& descName,
33  unsigned int numExpectedIn,
34  unsigned int numExpectedOut) const;
35 
36  template<typename T>
37  const T* GetAdditionalInformation() const
38  {
39  return static_cast<T*>(m_AdditionalInfoObject);
40  }
41 
42 protected:
44  : m_AdditionalInfoObject(nullptr)
45  {}
46  QueueDescriptor(QueueDescriptor const&) = default;
47  QueueDescriptor& operator=(QueueDescriptor const&) = default;
48 };
49 
50 // Base class for queue descriptors which contain parameters.
51 template <typename LayerDescriptor>
53 {
54  LayerDescriptor m_Parameters;
55 
56  virtual ~QueueDescriptorWithParameters() = default;
57 
58 protected:
62 };
63 
65 {
66  void Validate(const WorkloadInfo& workloadInfo) const;
67 };
68 
70 {
71  void Validate(const WorkloadInfo& workloadInfo) const;
72 };
73 
75 {
76  void Validate(const WorkloadInfo& workloadInfo) const;
77 };
78 
81 
83 {
84  void Validate(const WorkloadInfo& workloadInfo) const;
85 };
86 
88 {
89  void Validate(const WorkloadInfo& workloadInfo) const;
90 };
91 
92 // Softmax layer workload data.
94 {
95  void Validate(const WorkloadInfo& workloadInfo) const;
96 };
97 
98 // Splitter layer workload data.
100 {
101  struct ViewOrigin
102  {
104  ViewOrigin(std::vector<unsigned int> const& origin) : m_Origin(origin) {}
105 
106  //View origin (size of the vector is the same as number of dimensions of the view).
107  std::vector<unsigned int> m_Origin;
108  };
109 
110  //View defines a tensor that will be carved from the input tensor.
111  //View origins are stored here, the extents are defined by sizes of the output tensors.
112  std::vector<ViewOrigin> m_ViewOrigins;
113 
114  void Validate(const WorkloadInfo& workloadInfo) const;
115 };
116 
117 // Concat layer workload data.
119 {
120  struct ViewOrigin
121  {
123  ViewOrigin(const std::vector<unsigned int>& origin) : m_Origin(origin) {}
124 
125  //View origin (size of the vector is the same as number of dimensions of the view).
126  std::vector<unsigned int> m_Origin;
127  };
128 
129  //View defines a sub-area of the output tensor that will be filled with the corresponding input tensor.
130  //View origins are stored here, the extents are defined by sizes of the input tensors.
131  std::vector<ViewOrigin> m_ViewOrigins;
132 
133  void Validate(const WorkloadInfo& workloadInfo) const;
134 };
135 
136 // Deprecated. Use ConcatQueueDescriptor instead
138 
139 // Stack layer workload data.
141 {
142  void Validate(const WorkloadInfo& workloadInfo) const;
143 };
144 
145 // Activation layer workload data.
147 {
148  void Validate(const WorkloadInfo& workloadInfo) const;
149 };
150 
152 {
153  void Validate(const WorkloadInfo& workloadInfo) const;
154 };
155 
157 {
158  void Validate(const WorkloadInfo& workloadInfo) const;
159 };
160 
161 // Fill layer workload data.
163 {
164  void Validate(const WorkloadInfo& workloadInfo) const;
165 };
166 
167 // Fully connected layer workload data.
169 {
171  : m_Weight(nullptr)
172  , m_Bias(nullptr)
173  {
174  }
175 
178 
179  void Validate(const WorkloadInfo& workloadInfo) const;
180 };
181 
182 // Permute layer workload data.
184 {
185  void Validate(const WorkloadInfo& workloadInfo) const;
186 };
187 
188 // Pooling 2D layer workload data.
190 {
191  void Validate(const WorkloadInfo& workloadInfo) const;
192 };
193 
194 // Pooling 3D layer workload data.
196 {
197  void Validate(const WorkloadInfo& workloadInfo) const;
198 };
199 
200 
201 // Convolution 2D layer workload data.
203 {
205  : m_Weight(nullptr)
206  , m_Bias(nullptr)
207  {
208  }
209 
212 
213  void Validate(const WorkloadInfo& workloadInfo) const;
214 };
215 
216 // Convolution 3D layer workload data.
218 {
219  void Validate(const WorkloadInfo& workloadInfo) const;
220 };
221 
222 /// Depthwise Convolution 2D layer workload data.
223 ///
224 /// @note
225 /// The weights are in the format [1, H, W, I*M]. Where I is the input channel size, M the depthwise mutliplier and
226 /// H, W is the height and width of the filter kernel. If per channel quantization is applied
227 /// the weights will be quantized along the last dimension/axis (I*M) which corresponds to the output channel size.
228 /// If per channel quantization is applied the weights tensor will have I*M scales, one for each dimension
229 /// of the quantization axis. You have to be aware of this when reshaping the weights tensor.
230 /// Splitting the I*M axis, e.g. [1, H, W, I*M] --> [H, W, I, M], won't work without taking care of the
231 /// corresponding quantization scales.
232 /// If there is no per channel quantization applied reshaping the weights tensor won't cause any issues. There are
233 /// preconfigured permutation functions available @link WorkloadUtils.hpp here.
234 ///
236 {
238  : m_Weight(nullptr)
239  , m_Bias(nullptr)
240  {
241  }
242 
245 
246  void Validate(const WorkloadInfo& workloadInfo) const;
247 };
248 
250 {
252  : m_Anchors(nullptr)
253  {
254  }
255 
257 
258  void Validate(const WorkloadInfo& workloadInfo) const;
259 };
260 
261 // Normalization layer workload data.
263 {
264  void Validate(const WorkloadInfo& workloadInfo) const;
265 };
266 
267 // Add layer workload data.
269 {
270  void Validate(const WorkloadInfo& workloadInfo) const;
271 };
272 
273 // Multiplication layer workload data.
275 {
276  void Validate(const WorkloadInfo& workloadInfo) const;
277 };
278 
279 // Division layer workload data.
281 {
282  void Validate(const WorkloadInfo& workloadInfo) const;
283 };
284 
285 // Subtraction layer workload data.
287 {
288  void Validate(const WorkloadInfo& workloadInfo) const;
289 };
290 
291 // Maximum layer workload data.
293 {
294  void Validate(const WorkloadInfo& workloadInfo) const;
295 };
296 
297 // Mean layer workload data.
299 {
300  void Validate(const WorkloadInfo& workloadInfo) const;
301 };
302 
303 // Pad layer workload data
305 {
306  void Validate(const WorkloadInfo& workloadInfo) const;
307 };
308 
310 {
311  void Validate(const WorkloadInfo& workloadInfo) const;
312 };
313 
314 // Deprecated use ComparisonQueueDescriptor instead
316 {
317  void Validate(const WorkloadInfo& workloadInfo) const;
318 };
319 
320 // Batch norm layer workload data.
322 {
324  : m_Mean(nullptr)
325  , m_Variance(nullptr)
326  , m_Beta(nullptr)
327  , m_Gamma(nullptr)
328  {
329  }
330 
335 
336  void Validate(const WorkloadInfo& workloadInfo) const;
337 };
338 
340 {
341  void Validate(const WorkloadInfo& workloadInfo) const;
342 };
343 
345 struct
346 ARMNN_DEPRECATED_MSG_REMOVAL_DATE("ResizeBilinearQueueDescriptor is deprecated use ResizeQueueDescriptor instead",
347  "22.08")
348 ResizeBilinearQueueDescriptor : QueueDescriptorWithParameters<ResizeBilinearDescriptor>
349 {
350  void Validate(const WorkloadInfo& workloadInfo) const;
351 };
353 
355 {
356  void Validate(const WorkloadInfo& workloadInfo) const;
357 };
358 
360 {
362  : m_Min(nullptr)
363  , m_Max(nullptr)
364  {
365  }
366 
369 
370  void Validate(const WorkloadInfo& workloadInfo) const;
371 };
372 
374 {
375  void Validate(const WorkloadInfo& workloadInfo) const;
376 };
377 
379 {
380  void Validate(const WorkloadInfo& workloadInfo) const;
381 };
382 
384 {
385  void Validate(const WorkloadInfo& workloadInfo) const;
386 };
387 
389 {
391  : m_LayerOutput(nullptr)
392  {
393  }
394 
396 
397  void Validate(const WorkloadInfo& workloadInfo) const;
398 };
399 
401 {
402  void Validate(const WorkloadInfo& workloadInfo) const;
403 };
404 
406 {
407  void Validate(const WorkloadInfo& workloadInfo) const;
408 };
409 
411 {
412  void Validate(const WorkloadInfo& workloadInfo) const;
413 };
414 
416 {
417  void Validate(const WorkloadInfo& workloadInfo) const;
418 };
419 
421 {
423  : m_InputToInputWeights(nullptr)
424  , m_InputToForgetWeights(nullptr)
425  , m_InputToCellWeights(nullptr)
426  , m_InputToOutputWeights(nullptr)
427  , m_RecurrentToInputWeights(nullptr)
428  , m_RecurrentToForgetWeights(nullptr)
429  , m_RecurrentToCellWeights(nullptr)
430  , m_RecurrentToOutputWeights(nullptr)
431  , m_CellToInputWeights(nullptr)
432  , m_CellToForgetWeights(nullptr)
433  , m_CellToOutputWeights(nullptr)
434  , m_InputGateBias(nullptr)
435  , m_ForgetGateBias(nullptr)
436  , m_CellBias(nullptr)
437  , m_OutputGateBias(nullptr)
438  , m_ProjectionWeights(nullptr)
439  , m_ProjectionBias(nullptr)
440  , m_InputLayerNormWeights(nullptr)
441  , m_ForgetLayerNormWeights(nullptr)
442  , m_CellLayerNormWeights(nullptr)
443  , m_OutputLayerNormWeights(nullptr)
444  {
445  }
446 
468 
469  void Validate(const WorkloadInfo& workloadInfo) const;
470 };
471 
473 {
474  void Validate(const WorkloadInfo& workloadInfo) const;
475 };
476 
478 {
479  void Validate(const WorkloadInfo& workloadInfo) const;
480 };
481 
483 {
484  void Validate(const WorkloadInfo& workloadInfo) const;
485 };
486 
488 {
489  void Validate(const WorkloadInfo& workloadInfo) const;
490 };
491 
493 {
494  void Validate(const WorkloadInfo& workloadInfo) const;
495 };
496 
498 {
499  void Validate(const WorkloadInfo& workloadInfo) const;
500 };
501 
502 // Minimum layer workload data.
504 {
505  void Validate(const WorkloadInfo& workloadInfo) const;
506 };
507 
508 // Deprecated use ComparisonQueueDescriptor instead
510 {
511  void Validate(const WorkloadInfo& workloadInfo) const;
512 };
513 
515 {
516  DebugQueueDescriptor() : m_Guid(0) {}
517 
518  void Validate(const WorkloadInfo& workloadInfo) const;
519 
521  std::string m_LayerName;
522  unsigned int m_SlotIndex;
523 };
524 
526 {
527  void Validate(const WorkloadInfo& workloadInfo) const;
528 };
529 
531 {
532  void Validate(const WorkloadInfo& workloadInfo) const;
533 };
534 
536 {
538  : m_PreCompiledObject(nullptr)
539  {
540  }
541 
543 
544  void Validate(const WorkloadInfo& workloadInfo) const;
545 };
546 
548 {
549  void Validate(const WorkloadInfo& workloadInfo) const;
550 };
551 
553 {
554  void Validate(const WorkloadInfo& workloadInfo) const;
555 };
556 
558 {
559  void Validate(const WorkloadInfo& workloadInfo) const;
560 };
561 
563 {
564  void Validate(const WorkloadInfo& workloadInfo) const;
565 };
566 
568 {
570  m_Weight(nullptr),
571  m_Bias(nullptr)
572  {}
573 
576 
577  void Validate(const WorkloadInfo& workloadInfo) const;
578 };
579 
581 {
582  void Validate(const WorkloadInfo& workloadInfo) const;
583 };
584 
586 {
588  : m_InputToInputWeights(nullptr)
589  , m_InputToForgetWeights(nullptr)
590  , m_InputToCellWeights(nullptr)
591  , m_InputToOutputWeights(nullptr)
592  , m_RecurrentToInputWeights(nullptr)
593  , m_RecurrentToForgetWeights(nullptr)
594  , m_RecurrentToCellWeights(nullptr)
595  , m_RecurrentToOutputWeights(nullptr)
596  , m_CellToInputWeights(nullptr)
597  , m_CellToForgetWeights(nullptr)
598  , m_CellToOutputWeights(nullptr)
599  , m_InputGateBias(nullptr)
600  , m_ForgetGateBias(nullptr)
601  , m_CellBias(nullptr)
602  , m_OutputGateBias(nullptr)
603  , m_ProjectionWeights(nullptr)
604  , m_ProjectionBias(nullptr)
605  , m_InputLayerNormWeights(nullptr)
606  , m_ForgetLayerNormWeights(nullptr)
607  , m_CellLayerNormWeights(nullptr)
608  , m_OutputLayerNormWeights(nullptr)
609  {
610  }
611 
633 
634  void Validate(const WorkloadInfo& workloadInfo) const;
635 };
636 
638 {
640  : m_InputToInputWeights(nullptr)
641  , m_InputToForgetWeights(nullptr)
642  , m_InputToCellWeights(nullptr)
643  , m_InputToOutputWeights(nullptr)
644 
645  , m_RecurrentToInputWeights(nullptr)
646  , m_RecurrentToForgetWeights(nullptr)
647  , m_RecurrentToCellWeights(nullptr)
648  , m_RecurrentToOutputWeights(nullptr)
649 
650  , m_InputGateBias(nullptr)
651  , m_ForgetGateBias(nullptr)
652  , m_CellBias(nullptr)
653  , m_OutputGateBias(nullptr)
654  {}
655 
660 
665 
670 
671  void Validate(const WorkloadInfo& workloadInfo) const;
672 };
673 
675 {
676  void Validate(const WorkloadInfo& workloadInfo) const;
677 };
678 
680 {
681  void Validate(const WorkloadInfo& workloadInfo) const;
682 };
683 
685 {
686  void Validate(const WorkloadInfo& workloadInfo) const;
687 };
688 
690 {
691  void Validate(const WorkloadInfo& workloadInfo) const;
692 };
693 
695 {
696  void Validate(const WorkloadInfo& workloadInfo) const;
697 };
698 
700 {
701  void Validate(const WorkloadInfo& workloadInfo) const;
702 };
703 
705 {
706  void Validate(const WorkloadInfo& workloadInfo) const;
707 };
708 
710 {
711  void Validate(const WorkloadInfo& workloadInfo) const;
712 };
713 
715 {
717  : m_InputToInputWeights(nullptr)
718  , m_InputToForgetWeights(nullptr)
719  , m_InputToCellWeights(nullptr)
720  , m_InputToOutputWeights(nullptr)
721  , m_RecurrentToInputWeights(nullptr)
722  , m_RecurrentToForgetWeights(nullptr)
723  , m_RecurrentToCellWeights(nullptr)
724  , m_RecurrentToOutputWeights(nullptr)
725  , m_CellToInputWeights(nullptr)
726  , m_CellToForgetWeights(nullptr)
727  , m_CellToOutputWeights(nullptr)
728  , m_InputGateBias(nullptr)
729  , m_ForgetGateBias(nullptr)
730  , m_CellBias(nullptr)
731  , m_OutputGateBias(nullptr)
732  , m_ProjectionWeights(nullptr)
733  , m_ProjectionBias(nullptr)
734  , m_InputLayerNormWeights(nullptr)
735  , m_ForgetLayerNormWeights(nullptr)
736  , m_CellLayerNormWeights(nullptr)
737  , m_OutputLayerNormWeights(nullptr)
738  {
739  }
740 
762 
763  void Validate(const WorkloadInfo& workloadInfo) const;
764 };
765 
767 {
768  void Validate(const WorkloadInfo& workloadInfo) const;
769 };
770 
771 } // namespace armnn
const ConstTensorHandle * m_CellLayerNormWeights
const ConstTensorHandle * m_ProjectionWeights
const ConstTensorHandle * m_ProjectionWeights
const ConstTensorHandle * m_RecurrentToForgetWeights
const ConstTensorHandle * m_ForgetGateBias
QueueDescriptor & operator=(QueueDescriptor const &)=default
const ConstTensorHandle * m_InputToOutputWeights
std::vector< unsigned int > m_Origin
const ConstTensorHandle * m_LayerOutput
const ConstTensorHandle * m_InputGateBias
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
const ConstTensorHandle * m_RecurrentToCellWeights
ViewOrigin(const std::vector< unsigned int > &origin)
const ConstTensorHandle * m_CellBias
const ConstTensorHandle * m_InputToInputWeights
const ConstTensorHandle * m_CellToOutputWeights
const ConstTensorHandle * m_Variance
const ConstTensorHandle * m_CellToInputWeights
const ConstTensorHandle * m_Weight
const ConstTensorHandle * m_InputGateBias
const ConstTensorHandle * m_Bias
const ConstTensorHandle * m_InputToOutputWeights
DetectionPostProcessQueueDescriptor()
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
const ConstTensorHandle * m_OutputLayerNormWeights
ViewOrigin(std::vector< unsigned int > const &origin)
Copyright (c) 2021 ARM Limited and Contributors.
const ConstTensorHandle * m_RecurrentToInputWeights
const ConstTensorHandle * m_Bias
const ConstTensorHandle * m_ForgetLayerNormWeights
const ConstTensorHandle * m_OutputGateBias
const ConstTensorHandle * m_InputToForgetWeights
const ConstTensorHandle * m_CellLayerNormWeights
DataType
Definition: Types.hpp:35
std::vector< ViewOrigin > m_ViewOrigins
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
const ConstTensorHandle * m_InputToForgetWeights
const ConstTensorHandle * m_RecurrentToCellWeights
const ConstTensorHandle * m_ForgetGateBias
const ConstTensorHandle * m_CellBias
ARMNN_NO_DEPRECATE_WARN_BEGIN struct ARMNN_DEPRECATED_MSG_REMOVAL_DATE("ResizeBilinearQueueDescriptor is deprecated use ResizeQueueDescriptor instead", "22.08") ResizeBilinearQueueDescriptor
const ConstTensorHandle * m_CellToOutputWeights
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_InputLayerNormWeights
const ConstTensorHandle * m_InputToCellWeights
const ConstTensorHandle * m_Weight
const ConstTensorHandle * m_OutputGateBias
const ConstTensorHandle * m_InputToForgetWeights
std::vector< ViewOrigin > m_ViewOrigins
const ConstTensorHandle * m_RecurrentToForgetWeights
DataType GetBiasDataType(DataType inputDataType)
const ConstTensorHandle * m_RecurrentToInputWeights
const ConstTensorHandle * m_InputToCellWeights
const ConstTensorHandle * m_ForgetGateBias
const T * GetAdditionalInformation() const
const ConstTensorHandle * m_CellToForgetWeights
const ConstTensorHandle * m_InputToOutputWeights
const ConstTensorHandle * m_ProjectionBias
const ConstTensorHandle * m_CellToForgetWeights
std::vector< ITensorHandle * > m_Outputs
virtual ~QueueDescriptor()=default
const ConstTensorHandle * m_RecurrentToCellWeights
const ConstTensorHandle * m_InputGateBias
const ConstTensorHandle * m_InputToInputWeights
const ConstTensorHandle * m_CellBias
profiling::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:363
const ConstTensorHandle * m_ProjectionBias
const ConstTensorHandle * m_ForgetLayerNormWeights
Contains information about TensorInfos of a layer.
const ConstTensorHandle * m_InputLayerNormWeights
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_Anchors
const ConstTensorHandle * m_OutputGateBias
std::vector< ITensorHandle * > m_Inputs
const ConstTensorHandle * m_OutputLayerNormWeights
const ConstTensorHandle * m_InputToCellWeights
const ConstTensorHandle * m_CellToInputWeights
const ConstTensorHandle * m_InputToInputWeights
const ConstTensorHandle * m_RecurrentToOutputWeights
const ConstTensorHandle * m_RecurrentToInputWeights
const ConstTensorHandle * m_RecurrentToForgetWeights
Depthwise Convolution 2D layer workload data.
const ConstTensorHandle * m_RecurrentToForgetWeights
std::vector< unsigned int > m_Origin
const ConstTensorHandle * m_RecurrentToOutputWeights