24 template <
typename F32Workload,
typename U8Workload,
typename QueueDescriptorType>
25 std::unique_ptr<IWorkload> RefWorkloadFactory::MakeWorkload(
const QueueDescriptorType& descriptor,
26 const WorkloadInfo& info)
const
28 return MakeWorkloadHelper<NullWorkload, F32Workload, U8Workload, NullWorkload, NullWorkload, NullWorkload>
32 template <DataType ArmnnType>
35 auto checkType = [](
const TensorInfo& tensorInfo) {
return tensorInfo.GetDataType() == ArmnnType;};
36 auto it = std::find_if(std::begin(
info.m_InputTensorInfos), std::end(
info.m_InputTensorInfos), checkType);
37 if (it != std::end(
info.m_InputTensorInfos))
41 it = std::find_if(std::begin(
info.m_OutputTensorInfos), std::end(
info.m_OutputTensorInfos), checkType);
42 if (it != std::end(
info.m_OutputTensorInfos))
50 return IsDataType<DataType::Signed64>(
info);
54 return IsDataType<DataType::Signed32>(
info);
58 return IsDataType<DataType::BFloat16>(
info);
62 return IsDataType<DataType::Float16>(
info);
66 return IsDataType<DataType::QSymmS16>(
info);
70 return IsDataType<DataType::QSymmS8>(
info);
74 return IsDataType<DataType::QAsymmS8>(
info);
78 return IsDataType<DataType::QAsymmU8>(
info);
82 return IsDataType<DataType::Boolean>(
info);
86 : m_MemoryManager(memoryManager)
102 std::string& outReasonIfUnsupported)
109 std::string& outReasonIfUnsupported,
116 const bool isMemoryManaged)
const
120 return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager);
124 return std::make_unique<RefTensorHandle>(tensorInfo);
130 const bool isMemoryManaged)
const
138 return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager);
142 return std::make_unique<RefTensorHandle>(tensorInfo);
154 auto activationQueueDescriptor = PolymorphicDowncast<const ActivationQueueDescriptor*>(&descriptor);
155 return std::make_unique<RefActivationWorkload>(*activationQueueDescriptor,
info);
159 auto additionQueueDescriptor = PolymorphicDowncast<const AdditionQueueDescriptor*>(&descriptor);
162 return std::make_unique<RefAdditionWorkload<int32_t>>(*additionQueueDescriptor,
info);
166 return std::make_unique<RefAdditionWorkload<float>>(*additionQueueDescriptor,
info);
171 auto argMinMaxQueueDescriptor = PolymorphicDowncast<const ArgMinMaxQueueDescriptor*>(&descriptor);
172 return std::make_unique<RefArgMinMaxWorkload>(*argMinMaxQueueDescriptor,
info);
176 auto batchMatMulQueueDescriptor = PolymorphicDowncast<const BatchMatMulQueueDescriptor*>(&descriptor);
177 return std::make_unique<RefBatchMatMulWorkload>(*batchMatMulQueueDescriptor,
info);
181 auto batchNormQueueDescriptor = PolymorphicDowncast<const BatchNormalizationQueueDescriptor*>(&descriptor);
182 return std::make_unique<RefBatchNormalizationWorkload>(*batchNormQueueDescriptor,
info);
186 auto batchToSpaceNdQueueDescriptor
187 = PolymorphicDowncast<const BatchToSpaceNdQueueDescriptor*>(&descriptor);
188 return std::make_unique<RefBatchToSpaceNdWorkload>(*batchToSpaceNdQueueDescriptor,
info);
192 auto broadcastToQueueDescriptor = PolymorphicDowncast<const BroadcastToQueueDescriptor*>(&descriptor);
193 return std::make_unique<RefBroadcastToWorkload>(*broadcastToQueueDescriptor,
info);
197 auto castQueueDescriptor = PolymorphicDowncast<const CastQueueDescriptor*>(&descriptor);
198 return std::make_unique<RefCastWorkload>(*castQueueDescriptor,
info);
202 auto channelShuffleQueueDescriptor
203 = PolymorphicDowncast<const ChannelShuffleQueueDescriptor*>(&descriptor);
204 return std::make_unique<RefChannelShuffleWorkload>(*channelShuffleQueueDescriptor,
info);
208 auto comparisonQueueDescriptor = PolymorphicDowncast<const ComparisonQueueDescriptor*>(&descriptor);
209 return std::make_unique<RefComparisonWorkload>(*comparisonQueueDescriptor,
info);
213 auto concatQueueDescriptor = PolymorphicDowncast<const ConcatQueueDescriptor*>(&descriptor);
214 return std::make_unique<RefConcatWorkload>(*concatQueueDescriptor,
info);
218 auto constantQueueDescriptor = PolymorphicDowncast<const ConstantQueueDescriptor*>(&descriptor);
219 return std::make_unique<RefConstantWorkload>(*constantQueueDescriptor,
info);
223 auto convertFp16ToFp32QueueDescriptor
224 = PolymorphicDowncast<const ConvertFp16ToFp32QueueDescriptor*>(&descriptor);
225 return std::make_unique<RefConvertFp16ToFp32Workload>(*convertFp16ToFp32QueueDescriptor,
info);
229 auto convertFp32ToFp16QueueDescriptor
230 = PolymorphicDowncast<const ConvertFp32ToFp16QueueDescriptor*>(&descriptor);
231 return std::make_unique<RefConvertFp32ToFp16Workload>(*convertFp32ToFp16QueueDescriptor,
info);
235 auto convolution2dQueueDescriptor = PolymorphicDowncast<const Convolution2dQueueDescriptor*>(&descriptor);
236 return std::make_unique<RefConvolution2dWorkload>(*convolution2dQueueDescriptor,
info);
240 auto convolution3dQueueDescriptor = PolymorphicDowncast<const Convolution3dQueueDescriptor*>(&descriptor);
241 return std::make_unique<RefConvolution3dWorkload>(*convolution3dQueueDescriptor,
info);
245 auto debugQueueDescriptor = PolymorphicDowncast<const DebugQueueDescriptor*>(&descriptor);
248 return std::make_unique<RefDebugBFloat16Workload>(*debugQueueDescriptor,
info);
252 return std::make_unique<RefDebugFloat16Workload>(*debugQueueDescriptor,
info);
256 return std::make_unique<RefDebugQSymmS16Workload>(*debugQueueDescriptor,
info);
260 return std::make_unique<RefDebugQSymmS8Workload>(*debugQueueDescriptor,
info);
264 return std::make_unique<RefDebugQAsymmU8Workload>(*debugQueueDescriptor,
info);
268 return std::make_unique<RefDebugQAsymmS8Workload>(*debugQueueDescriptor,
info);
272 return std::make_unique<RefDebugSigned32Workload>(*debugQueueDescriptor,
info);
276 return std::make_unique<RefDebugSigned64Workload>(*debugQueueDescriptor,
info);
280 return std::make_unique<RefDebugBooleanWorkload>(*debugQueueDescriptor,
info);
282 return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(*debugQueueDescriptor,
info);
286 auto depthToSpaceQueueDescriptor = PolymorphicDowncast<const DepthToSpaceQueueDescriptor*>(&descriptor);
287 return std::make_unique<RefDepthToSpaceWorkload>(*depthToSpaceQueueDescriptor,
info);
291 auto depthwiseConvolution2DQueueDescriptor
292 = PolymorphicDowncast<const DepthwiseConvolution2dQueueDescriptor*>(&descriptor);
293 return std::make_unique<RefDepthwiseConvolution2dWorkload>(*depthwiseConvolution2DQueueDescriptor,
info);
297 auto dequantizeQueueDescriptor = PolymorphicDowncast<const DequantizeQueueDescriptor*>(&descriptor);
298 return std::make_unique<RefDequantizeWorkload>(*dequantizeQueueDescriptor,
info);
302 auto detectionPostProcessQueueDescriptor
303 = PolymorphicDowncast<const DetectionPostProcessQueueDescriptor*>(&descriptor);
304 return std::make_unique<RefDetectionPostProcessWorkload>(*detectionPostProcessQueueDescriptor,
info);
308 auto divisionQueueDescriptor = PolymorphicDowncast<const DivisionQueueDescriptor*>(&descriptor);
311 return std::make_unique<RefDivisionWorkload<int32_t>>(*divisionQueueDescriptor,
info);
315 return std::make_unique<RefDivisionWorkload<float>>(*divisionQueueDescriptor,
info);
320 auto elementwiseBinaryQueueDescriptor
321 = PolymorphicDowncast<const ElementwiseBinaryQueueDescriptor*>(&descriptor);
322 return std::make_unique<RefElementwiseBinaryWorkload>(*elementwiseBinaryQueueDescriptor,
info);
326 auto elementwiseUnaryQueueDescriptor
327 = PolymorphicDowncast<const ElementwiseUnaryQueueDescriptor*>(&descriptor);
330 return std::make_unique<RefLogicalUnaryWorkload>(*elementwiseUnaryQueueDescriptor,
info);
332 return std::make_unique<RefElementwiseUnaryWorkload>(*elementwiseUnaryQueueDescriptor,
info);
336 auto fakeQuantizationQueueDescriptor
337 = PolymorphicDowncast<const FakeQuantizationQueueDescriptor*>(&descriptor);
338 return std::make_unique<RefFakeQuantizationFloat32Workload>(*fakeQuantizationQueueDescriptor,
info);
342 auto fillQueueDescriptor = PolymorphicDowncast<const FillQueueDescriptor*>(&descriptor);
343 return std::make_unique<RefFillWorkload>(*fillQueueDescriptor,
info);
347 auto floorQueueDescriptor = PolymorphicDowncast<const FloorQueueDescriptor*>(&descriptor);
354 return std::make_unique<RefFloorWorkload>(*floorQueueDescriptor,
info);
359 auto fullyConnectedQueueDescriptor
360 = PolymorphicDowncast<const FullyConnectedQueueDescriptor*>(&descriptor);
361 return std::make_unique<RefFullyConnectedWorkload>(*fullyConnectedQueueDescriptor,
info);
365 auto gatherQueueDescriptor = PolymorphicDowncast<const GatherQueueDescriptor*>(&descriptor);
366 return std::make_unique<RefGatherWorkload>(*gatherQueueDescriptor,
info);
370 auto gatherNdQueueDescriptor = PolymorphicDowncast<const GatherNdQueueDescriptor*>(&descriptor);
371 return std::make_unique<RefGatherNdWorkload>(*gatherNdQueueDescriptor,
info);
375 auto inputQueueDescriptor = PolymorphicDowncast<const InputQueueDescriptor*>(&descriptor);
376 if (
info.m_InputTensorInfos.empty() )
380 if (
info.m_OutputTensorInfos.empty())
384 if (
info.m_InputTensorInfos[0].GetNumBytes() !=
info.m_OutputTensorInfos[0].GetNumBytes())
387 "data input and output differ in byte count.");
389 return std::make_unique<CopyMemGenericWorkload>(*inputQueueDescriptor,
info);
393 auto instanceNormalizationQueueDescriptor
394 = PolymorphicDowncast<const InstanceNormalizationQueueDescriptor*>(&descriptor);
395 return std::make_unique<RefInstanceNormalizationWorkload>(*instanceNormalizationQueueDescriptor,
info);
399 auto l2NormalizationQueueDescriptor
400 = PolymorphicDowncast<const L2NormalizationQueueDescriptor*>(&descriptor);
401 return std::make_unique<RefL2NormalizationWorkload>(*l2NormalizationQueueDescriptor,
info);
405 auto logicalBinaryQueueDescriptor = PolymorphicDowncast<const LogicalBinaryQueueDescriptor*>(&descriptor);
406 return std::make_unique<RefLogicalBinaryWorkload>(*logicalBinaryQueueDescriptor,
info);
410 auto logSoftmaxQueueDescriptor = PolymorphicDowncast<const LogSoftmaxQueueDescriptor*>(&descriptor);
411 return std::make_unique<RefLogSoftmaxWorkload>(*logSoftmaxQueueDescriptor,
info);
415 auto lstmQueueDescriptor = PolymorphicDowncast<const LstmQueueDescriptor*>(&descriptor);
416 return std::make_unique<RefLstmWorkload>(*lstmQueueDescriptor,
info);
420 auto maximumQueueDescriptor = PolymorphicDowncast<const MaximumQueueDescriptor*>(&descriptor);
423 return std::make_unique<RefMaximumWorkload<int32_t>>(*maximumQueueDescriptor,
info);
427 return std::make_unique<RefMaximumWorkload<float>>(*maximumQueueDescriptor,
info);
432 auto meanQueueDescriptor = PolymorphicDowncast<const MeanQueueDescriptor*>(&descriptor);
433 return std::make_unique<RefMeanWorkload>(*meanQueueDescriptor,
info);
437 auto memCopyQueueDescriptor = PolymorphicDowncast<const MemCopyQueueDescriptor*>(&descriptor);
442 return std::make_unique<CopyMemGenericWorkload>(*memCopyQueueDescriptor,
info);
446 auto memImportQueueDescriptor = PolymorphicDowncast<const MemImportQueueDescriptor*>(&descriptor);
451 return std::make_unique<ImportMemGenericWorkload>(*memImportQueueDescriptor,
info);
455 auto minimumQueueDescriptor = PolymorphicDowncast<const MinimumQueueDescriptor*>(&descriptor);
458 return std::make_unique<RefMinimumWorkload<int32_t>>(*minimumQueueDescriptor,
info);
462 return std::make_unique<RefMinimumWorkload<float>>(*minimumQueueDescriptor,
info);
467 auto multiplicationQueueDescriptor
468 = PolymorphicDowncast<const MultiplicationQueueDescriptor*>(&descriptor);
471 return std::make_unique<RefMultiplicationWorkload<int32_t>>(*multiplicationQueueDescriptor,
info);
475 return std::make_unique<RefMultiplicationWorkload<float>>(*multiplicationQueueDescriptor,
info);
480 auto normalizationQueueDescriptor = PolymorphicDowncast<const NormalizationQueueDescriptor*>(&descriptor);
481 return std::make_unique<RefNormalizationWorkload>(*normalizationQueueDescriptor,
info);
485 auto outputQueueDescriptor = PolymorphicDowncast<const OutputQueueDescriptor*>(&descriptor);
486 if (
info.m_InputTensorInfos.empty() )
490 if (
info.m_OutputTensorInfos.empty())
494 if (
info.m_InputTensorInfos[0].GetNumBytes() !=
info.m_OutputTensorInfos[0].GetNumBytes())
497 "differ in byte count.");
499 return std::make_unique<CopyMemGenericWorkload>(*outputQueueDescriptor,
info);
503 auto padQueueDescriptor = PolymorphicDowncast<const PadQueueDescriptor*>(&descriptor);
504 return std::make_unique<RefPadWorkload>(*padQueueDescriptor,
info);
508 auto permuteQueueDescriptor = PolymorphicDowncast<const PermuteQueueDescriptor*>(&descriptor);
511 return std::make_unique<RefPermuteQSymm16Workload>(*permuteQueueDescriptor,
info);
515 return std::make_unique<RefPermuteBFloat16Workload>(*permuteQueueDescriptor,
info);
519 return std::make_unique<RefPermuteQAsymmS8Workload>(*permuteQueueDescriptor,
info);
526 auto pooling2dQueueDescriptor = PolymorphicDowncast<const Pooling2dQueueDescriptor*>(&descriptor);
527 return std::make_unique<RefPooling2dWorkload>(*pooling2dQueueDescriptor,
info);
531 auto pooling3dQueueDescriptor = PolymorphicDowncast<const Pooling3dQueueDescriptor*>(&descriptor);
532 return std::make_unique<RefPooling3dWorkload>(*pooling3dQueueDescriptor,
info);
540 auto preluQueueDescriptor = PolymorphicDowncast<const PreluQueueDescriptor*>(&descriptor);
541 return std::make_unique<RefPreluWorkload>(*preluQueueDescriptor,
info);
545 auto qlstmQueueDescriptor = PolymorphicDowncast<const QLstmQueueDescriptor*>(&descriptor);
546 return std::make_unique<RefQLstmWorkload>(*qlstmQueueDescriptor,
info);
550 auto quantizeQueueDescriptor = PolymorphicDowncast<const QuantizeQueueDescriptor*>(&descriptor);
551 return std::make_unique<RefQuantizeWorkload>(*quantizeQueueDescriptor,
info);
555 auto rankQueueDescriptor = PolymorphicDowncast<const RankQueueDescriptor*>(&descriptor);
556 return std::make_unique<RefRankWorkload>(*rankQueueDescriptor,
info);
560 auto reduceQueueDescriptor = PolymorphicDowncast<const ReduceQueueDescriptor*>(&descriptor);
561 return std::make_unique<RefReduceWorkload>(*reduceQueueDescriptor,
info);
565 auto reshapeQueueDescriptor = PolymorphicDowncast<const ReshapeQueueDescriptor*>(&descriptor);
566 return std::make_unique<RefReshapeWorkload>(*reshapeQueueDescriptor,
info);
570 auto resizeQueueDescriptor = PolymorphicDowncast<const ResizeQueueDescriptor*>(&descriptor);
571 return std::make_unique<RefResizeWorkload>(*resizeQueueDescriptor,
info);
575 auto reverseV2QueueDescriptor = PolymorphicDowncast<const ReverseV2QueueDescriptor*>(&descriptor);
576 return std::make_unique<RefReverseV2Workload>(*reverseV2QueueDescriptor,
info);
580 auto scatterQueueDescriptor = PolymorphicDowncast<const ScatterNdQueueDescriptor*>(&descriptor);
581 return std::make_unique<RefScatterNdWorkload>(*scatterQueueDescriptor,
info);
585 auto shapeQueueDescriptor = PolymorphicDowncast<const ShapeQueueDescriptor*>(&descriptor);
586 return std::make_unique<RefShapeWorkload>(*shapeQueueDescriptor,
info);
590 auto sliceQueueDescriptor = PolymorphicDowncast<const SliceQueueDescriptor*>(&descriptor);
591 return std::make_unique<RefSliceWorkload>(*sliceQueueDescriptor,
info);
595 auto softmaxQueueDescriptor = PolymorphicDowncast<const SoftmaxQueueDescriptor*>(&descriptor);
596 return std::make_unique<RefSoftmaxWorkload>(*softmaxQueueDescriptor,
info);
600 auto spaceToBatchNdQueueDescriptor
601 = PolymorphicDowncast<const SpaceToBatchNdQueueDescriptor*>(&descriptor);
602 return std::make_unique<RefSpaceToBatchNdWorkload>(*spaceToBatchNdQueueDescriptor,
info);
606 auto spaceToDepthQueueDescriptor = PolymorphicDowncast<const SpaceToDepthQueueDescriptor*>(&descriptor);
607 return std::make_unique<RefSpaceToDepthWorkload>(*spaceToDepthQueueDescriptor,
info);
611 auto splitterQueueDescriptor = PolymorphicDowncast<const SplitterQueueDescriptor*>(&descriptor);
612 return std::make_unique<RefSplitterWorkload>(*splitterQueueDescriptor,
info);
616 auto stackQueueDescriptor = PolymorphicDowncast<const StackQueueDescriptor*>(&descriptor);
617 return std::make_unique<RefStackWorkload>(*stackQueueDescriptor,
info);
621 auto stridedSliceQueueDescriptor = PolymorphicDowncast<const StridedSliceQueueDescriptor*>(&descriptor);
622 return std::make_unique<RefStridedSliceWorkload>(*stridedSliceQueueDescriptor,
info);
626 auto subtractionQueueDescriptor = PolymorphicDowncast<const SubtractionQueueDescriptor*>(&descriptor);
629 return std::make_unique<RefSubtractionWorkload<int32_t>>(*subtractionQueueDescriptor,
info);
633 return std::make_unique<RefSubtractionWorkload<float>>(*subtractionQueueDescriptor,
info);
638 auto tileQueueDescriptor = PolymorphicDowncast<const TileQueueDescriptor*>(&descriptor);
639 return std::make_unique<RefTileWorkload>(*tileQueueDescriptor,
info);
643 auto transposeQueueDescriptor = PolymorphicDowncast<const TransposeQueueDescriptor*>(&descriptor);
646 return std::make_unique<RefTransposeQSymm16Workload>(*transposeQueueDescriptor,
info);
650 return std::make_unique<RefTransposeBFloat16Workload>(*transposeQueueDescriptor,
info);
654 return std::make_unique<RefTransposeQAsymmS8Workload>(*transposeQueueDescriptor,
info);
658 (*transposeQueueDescriptor,
info);
662 auto transposeConvolution2dQueueDescriptor
663 = PolymorphicDowncast<const TransposeConvolution2dQueueDescriptor*>(&descriptor);
664 return std::make_unique<RefTransposeConvolution2dWorkload>(*transposeConvolution2dQueueDescriptor,
info);
668 auto unidirectionalSequenceLstmQueueDescriptor
669 = PolymorphicDowncast<const UnidirectionalSequenceLstmQueueDescriptor*>(&descriptor);
670 return std::make_unique<RefUnidirectionalSequenceLstmWorkload>(*unidirectionalSequenceLstmQueueDescriptor,