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 : m_MemoryManager(memoryManager)
98 std::string& outReasonIfUnsupported)
105 std::string& outReasonIfUnsupported,
112 const bool isMemoryManaged)
const
116 return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager);
120 return std::make_unique<RefTensorHandle>(tensorInfo);
126 const bool isMemoryManaged)
const
134 return std::make_unique<RefTensorHandle>(tensorInfo, m_MemoryManager);
138 return std::make_unique<RefTensorHandle>(tensorInfo);
150 auto activationQueueDescriptor = PolymorphicDowncast<const ActivationQueueDescriptor*>(&descriptor);
151 return std::make_unique<RefActivationWorkload>(*activationQueueDescriptor,
info);
155 auto additionQueueDescriptor = PolymorphicDowncast<const AdditionQueueDescriptor*>(&descriptor);
158 return std::make_unique<RefAdditionWorkload<int32_t>>(*additionQueueDescriptor,
info);
162 return std::make_unique<RefAdditionWorkload<float>>(*additionQueueDescriptor,
info);
167 auto argMinMaxQueueDescriptor = PolymorphicDowncast<const ArgMinMaxQueueDescriptor*>(&descriptor);
168 return std::make_unique<RefArgMinMaxWorkload>(*argMinMaxQueueDescriptor,
info);
172 auto batchMatMulQueueDescriptor = PolymorphicDowncast<const BatchMatMulQueueDescriptor*>(&descriptor);
173 return std::make_unique<RefBatchMatMulWorkload>(*batchMatMulQueueDescriptor,
info);
177 auto batchNormQueueDescriptor = PolymorphicDowncast<const BatchNormalizationQueueDescriptor*>(&descriptor);
178 return std::make_unique<RefBatchNormalizationWorkload>(*batchNormQueueDescriptor,
info);
182 auto batchToSpaceNdQueueDescriptor
183 = PolymorphicDowncast<const BatchToSpaceNdQueueDescriptor*>(&descriptor);
184 return std::make_unique<RefBatchToSpaceNdWorkload>(*batchToSpaceNdQueueDescriptor,
info);
188 auto broadcastToQueueDescriptor = PolymorphicDowncast<const BroadcastToQueueDescriptor*>(&descriptor);
189 return std::make_unique<RefBroadcastToWorkload>(*broadcastToQueueDescriptor,
info);
193 auto castQueueDescriptor = PolymorphicDowncast<const CastQueueDescriptor*>(&descriptor);
194 return std::make_unique<RefCastWorkload>(*castQueueDescriptor,
info);
198 auto channelShuffleQueueDescriptor
199 = PolymorphicDowncast<const ChannelShuffleQueueDescriptor*>(&descriptor);
200 return std::make_unique<RefChannelShuffleWorkload>(*channelShuffleQueueDescriptor,
info);
204 auto comparisonQueueDescriptor = PolymorphicDowncast<const ComparisonQueueDescriptor*>(&descriptor);
205 return std::make_unique<RefComparisonWorkload>(*comparisonQueueDescriptor,
info);
209 auto concatQueueDescriptor = PolymorphicDowncast<const ConcatQueueDescriptor*>(&descriptor);
210 return std::make_unique<RefConcatWorkload>(*concatQueueDescriptor,
info);
214 auto constantQueueDescriptor = PolymorphicDowncast<const ConstantQueueDescriptor*>(&descriptor);
215 return std::make_unique<RefConstantWorkload>(*constantQueueDescriptor,
info);
219 auto convertFp16ToFp32QueueDescriptor
220 = PolymorphicDowncast<const ConvertFp16ToFp32QueueDescriptor*>(&descriptor);
221 return std::make_unique<RefConvertFp16ToFp32Workload>(*convertFp16ToFp32QueueDescriptor,
info);
225 auto convertFp32ToFp16QueueDescriptor
226 = PolymorphicDowncast<const ConvertFp32ToFp16QueueDescriptor*>(&descriptor);
227 return std::make_unique<RefConvertFp32ToFp16Workload>(*convertFp32ToFp16QueueDescriptor,
info);
231 auto convolution2dQueueDescriptor = PolymorphicDowncast<const Convolution2dQueueDescriptor*>(&descriptor);
232 return std::make_unique<RefConvolution2dWorkload>(*convolution2dQueueDescriptor,
info);
236 auto convolution3dQueueDescriptor = PolymorphicDowncast<const Convolution3dQueueDescriptor*>(&descriptor);
237 return std::make_unique<RefConvolution3dWorkload>(*convolution3dQueueDescriptor,
info);
241 auto debugQueueDescriptor = PolymorphicDowncast<const DebugQueueDescriptor*>(&descriptor);
244 return std::make_unique<RefDebugBFloat16Workload>(*debugQueueDescriptor,
info);
248 return std::make_unique<RefDebugFloat16Workload>(*debugQueueDescriptor,
info);
252 return std::make_unique<RefDebugQSymmS16Workload>(*debugQueueDescriptor,
info);
256 return std::make_unique<RefDebugQSymmS8Workload>(*debugQueueDescriptor,
info);
260 return std::make_unique<RefDebugQAsymmU8Workload>(*debugQueueDescriptor,
info);
264 return std::make_unique<RefDebugQAsymmS8Workload>(*debugQueueDescriptor,
info);
268 return std::make_unique<RefDebugSigned32Workload>(*debugQueueDescriptor,
info);
272 return std::make_unique<RefDebugSigned64Workload>(*debugQueueDescriptor,
info);
274 return MakeWorkload<RefDebugFloat32Workload, RefDebugQAsymmU8Workload>(*debugQueueDescriptor,
info);
278 auto depthToSpaceQueueDescriptor = PolymorphicDowncast<const DepthToSpaceQueueDescriptor*>(&descriptor);
279 return std::make_unique<RefDepthToSpaceWorkload>(*depthToSpaceQueueDescriptor,
info);
283 auto depthwiseConvolution2DQueueDescriptor
284 = PolymorphicDowncast<const DepthwiseConvolution2dQueueDescriptor*>(&descriptor);
285 return std::make_unique<RefDepthwiseConvolution2dWorkload>(*depthwiseConvolution2DQueueDescriptor,
info);
289 auto dequantizeQueueDescriptor = PolymorphicDowncast<const DequantizeQueueDescriptor*>(&descriptor);
290 return std::make_unique<RefDequantizeWorkload>(*dequantizeQueueDescriptor,
info);
294 auto detectionPostProcessQueueDescriptor
295 = PolymorphicDowncast<const DetectionPostProcessQueueDescriptor*>(&descriptor);
296 return std::make_unique<RefDetectionPostProcessWorkload>(*detectionPostProcessQueueDescriptor,
info);
300 auto divisionQueueDescriptor = PolymorphicDowncast<const DivisionQueueDescriptor*>(&descriptor);
303 return std::make_unique<RefDivisionWorkload<int32_t>>(*divisionQueueDescriptor,
info);
307 return std::make_unique<RefDivisionWorkload<float>>(*divisionQueueDescriptor,
info);
312 auto elementwiseBinaryQueueDescriptor
313 = PolymorphicDowncast<const ElementwiseBinaryQueueDescriptor*>(&descriptor);
314 return std::make_unique<RefElementwiseBinaryWorkload>(*elementwiseBinaryQueueDescriptor,
info);
318 auto elementwiseUnaryQueueDescriptor
319 = PolymorphicDowncast<const ElementwiseUnaryQueueDescriptor*>(&descriptor);
322 return std::make_unique<RefLogicalUnaryWorkload>(*elementwiseUnaryQueueDescriptor,
info);
324 return std::make_unique<RefElementwiseUnaryWorkload>(*elementwiseUnaryQueueDescriptor,
info);
328 auto fakeQuantizationQueueDescriptor
329 = PolymorphicDowncast<const FakeQuantizationQueueDescriptor*>(&descriptor);
330 return std::make_unique<RefFakeQuantizationFloat32Workload>(*fakeQuantizationQueueDescriptor,
info);
334 auto fillQueueDescriptor = PolymorphicDowncast<const FillQueueDescriptor*>(&descriptor);
335 return std::make_unique<RefFillWorkload>(*fillQueueDescriptor,
info);
339 auto floorQueueDescriptor = PolymorphicDowncast<const FloorQueueDescriptor*>(&descriptor);
346 return std::make_unique<RefFloorWorkload>(*floorQueueDescriptor,
info);
351 auto fullyConnectedQueueDescriptor
352 = PolymorphicDowncast<const FullyConnectedQueueDescriptor*>(&descriptor);
353 return std::make_unique<RefFullyConnectedWorkload>(*fullyConnectedQueueDescriptor,
info);
357 auto gatherQueueDescriptor = PolymorphicDowncast<const GatherQueueDescriptor*>(&descriptor);
358 return std::make_unique<RefGatherWorkload>(*gatherQueueDescriptor,
info);
362 auto gatherNdQueueDescriptor = PolymorphicDowncast<const GatherNdQueueDescriptor*>(&descriptor);
363 return std::make_unique<RefGatherNdWorkload>(*gatherNdQueueDescriptor,
info);
367 auto inputQueueDescriptor = PolymorphicDowncast<const InputQueueDescriptor*>(&descriptor);
368 if (
info.m_InputTensorInfos.empty() )
372 if (
info.m_OutputTensorInfos.empty())
376 if (
info.m_InputTensorInfos[0].GetNumBytes() !=
info.m_OutputTensorInfos[0].GetNumBytes())
379 "data input and output differ in byte count.");
381 return std::make_unique<CopyMemGenericWorkload>(*inputQueueDescriptor,
info);
385 auto instanceNormalizationQueueDescriptor
386 = PolymorphicDowncast<const InstanceNormalizationQueueDescriptor*>(&descriptor);
387 return std::make_unique<RefInstanceNormalizationWorkload>(*instanceNormalizationQueueDescriptor,
info);
391 auto l2NormalizationQueueDescriptor
392 = PolymorphicDowncast<const L2NormalizationQueueDescriptor*>(&descriptor);
393 return std::make_unique<RefL2NormalizationWorkload>(*l2NormalizationQueueDescriptor,
info);
397 auto logicalBinaryQueueDescriptor = PolymorphicDowncast<const LogicalBinaryQueueDescriptor*>(&descriptor);
398 return std::make_unique<RefLogicalBinaryWorkload>(*logicalBinaryQueueDescriptor,
info);
402 auto logSoftmaxQueueDescriptor = PolymorphicDowncast<const LogSoftmaxQueueDescriptor*>(&descriptor);
403 return std::make_unique<RefLogSoftmaxWorkload>(*logSoftmaxQueueDescriptor,
info);
407 auto lstmQueueDescriptor = PolymorphicDowncast<const LstmQueueDescriptor*>(&descriptor);
408 return std::make_unique<RefLstmWorkload>(*lstmQueueDescriptor,
info);
412 auto maximumQueueDescriptor = PolymorphicDowncast<const MaximumQueueDescriptor*>(&descriptor);
415 return std::make_unique<RefMaximumWorkload<int32_t>>(*maximumQueueDescriptor,
info);
419 return std::make_unique<RefMaximumWorkload<float>>(*maximumQueueDescriptor,
info);
424 auto meanQueueDescriptor = PolymorphicDowncast<const MeanQueueDescriptor*>(&descriptor);
425 return std::make_unique<RefMeanWorkload>(*meanQueueDescriptor,
info);
429 auto memCopyQueueDescriptor = PolymorphicDowncast<const MemCopyQueueDescriptor*>(&descriptor);
434 return std::make_unique<CopyMemGenericWorkload>(*memCopyQueueDescriptor,
info);
438 auto memImportQueueDescriptor = PolymorphicDowncast<const MemImportQueueDescriptor*>(&descriptor);
443 return std::make_unique<ImportMemGenericWorkload>(*memImportQueueDescriptor,
info);
447 auto minimumQueueDescriptor = PolymorphicDowncast<const MinimumQueueDescriptor*>(&descriptor);
450 return std::make_unique<RefMinimumWorkload<int32_t>>(*minimumQueueDescriptor,
info);
454 return std::make_unique<RefMinimumWorkload<float>>(*minimumQueueDescriptor,
info);
459 auto multiplicationQueueDescriptor
460 = PolymorphicDowncast<const MultiplicationQueueDescriptor*>(&descriptor);
463 return std::make_unique<RefMultiplicationWorkload<int32_t>>(*multiplicationQueueDescriptor,
info);
467 return std::make_unique<RefMultiplicationWorkload<float>>(*multiplicationQueueDescriptor,
info);
472 auto normalizationQueueDescriptor = PolymorphicDowncast<const NormalizationQueueDescriptor*>(&descriptor);
473 return std::make_unique<RefNormalizationWorkload>(*normalizationQueueDescriptor,
info);
477 auto outputQueueDescriptor = PolymorphicDowncast<const OutputQueueDescriptor*>(&descriptor);
478 if (
info.m_InputTensorInfos.empty() )
482 if (
info.m_OutputTensorInfos.empty())
486 if (
info.m_InputTensorInfos[0].GetNumBytes() !=
info.m_OutputTensorInfos[0].GetNumBytes())
489 "differ in byte count.");
491 return std::make_unique<CopyMemGenericWorkload>(*outputQueueDescriptor,
info);
495 auto padQueueDescriptor = PolymorphicDowncast<const PadQueueDescriptor*>(&descriptor);
496 return std::make_unique<RefPadWorkload>(*padQueueDescriptor,
info);
500 auto permuteQueueDescriptor = PolymorphicDowncast<const PermuteQueueDescriptor*>(&descriptor);
503 return std::make_unique<RefPermuteQSymm16Workload>(*permuteQueueDescriptor,
info);
507 return std::make_unique<RefPermuteBFloat16Workload>(*permuteQueueDescriptor,
info);
511 return std::make_unique<RefPermuteQAsymmS8Workload>(*permuteQueueDescriptor,
info);
518 auto pooling2dQueueDescriptor = PolymorphicDowncast<const Pooling2dQueueDescriptor*>(&descriptor);
519 return std::make_unique<RefPooling2dWorkload>(*pooling2dQueueDescriptor,
info);
523 auto pooling3dQueueDescriptor = PolymorphicDowncast<const Pooling3dQueueDescriptor*>(&descriptor);
524 return std::make_unique<RefPooling3dWorkload>(*pooling3dQueueDescriptor,
info);
532 auto preluQueueDescriptor = PolymorphicDowncast<const PreluQueueDescriptor*>(&descriptor);
533 return std::make_unique<RefPreluWorkload>(*preluQueueDescriptor,
info);
537 auto qlstmQueueDescriptor = PolymorphicDowncast<const QLstmQueueDescriptor*>(&descriptor);
538 return std::make_unique<RefQLstmWorkload>(*qlstmQueueDescriptor,
info);
542 auto quantizeQueueDescriptor = PolymorphicDowncast<const QuantizeQueueDescriptor*>(&descriptor);
543 return std::make_unique<RefQuantizeWorkload>(*quantizeQueueDescriptor,
info);
547 auto rankQueueDescriptor = PolymorphicDowncast<const RankQueueDescriptor*>(&descriptor);
548 return std::make_unique<RefRankWorkload>(*rankQueueDescriptor,
info);
552 auto reduceQueueDescriptor = PolymorphicDowncast<const ReduceQueueDescriptor*>(&descriptor);
553 return std::make_unique<RefReduceWorkload>(*reduceQueueDescriptor,
info);
557 auto reshapeQueueDescriptor = PolymorphicDowncast<const ReshapeQueueDescriptor*>(&descriptor);
558 return std::make_unique<RefReshapeWorkload>(*reshapeQueueDescriptor,
info);
562 auto resizeQueueDescriptor = PolymorphicDowncast<const ResizeQueueDescriptor*>(&descriptor);
563 return std::make_unique<RefResizeWorkload>(*resizeQueueDescriptor,
info);
567 auto reverseV2QueueDescriptor = PolymorphicDowncast<const ReverseV2QueueDescriptor*>(&descriptor);
568 return std::make_unique<RefReverseV2Workload>(*reverseV2QueueDescriptor,
info);
572 auto shapeQueueDescriptor = PolymorphicDowncast<const ShapeQueueDescriptor*>(&descriptor);
573 return std::make_unique<RefShapeWorkload>(*shapeQueueDescriptor,
info);
577 auto sliceQueueDescriptor = PolymorphicDowncast<const SliceQueueDescriptor*>(&descriptor);
578 return std::make_unique<RefSliceWorkload>(*sliceQueueDescriptor,
info);
582 auto softmaxQueueDescriptor = PolymorphicDowncast<const SoftmaxQueueDescriptor*>(&descriptor);
583 return std::make_unique<RefSoftmaxWorkload>(*softmaxQueueDescriptor,
info);
587 auto spaceToBatchNdQueueDescriptor
588 = PolymorphicDowncast<const SpaceToBatchNdQueueDescriptor*>(&descriptor);
589 return std::make_unique<RefSpaceToBatchNdWorkload>(*spaceToBatchNdQueueDescriptor,
info);
593 auto spaceToDepthQueueDescriptor = PolymorphicDowncast<const SpaceToDepthQueueDescriptor*>(&descriptor);
594 return std::make_unique<RefSpaceToDepthWorkload>(*spaceToDepthQueueDescriptor,
info);
598 auto splitterQueueDescriptor = PolymorphicDowncast<const SplitterQueueDescriptor*>(&descriptor);
599 return std::make_unique<RefSplitterWorkload>(*splitterQueueDescriptor,
info);
603 auto stackQueueDescriptor = PolymorphicDowncast<const StackQueueDescriptor*>(&descriptor);
604 return std::make_unique<RefStackWorkload>(*stackQueueDescriptor,
info);
608 auto stridedSliceQueueDescriptor = PolymorphicDowncast<const StridedSliceQueueDescriptor*>(&descriptor);
609 return std::make_unique<RefStridedSliceWorkload>(*stridedSliceQueueDescriptor,
info);
613 auto subtractionQueueDescriptor = PolymorphicDowncast<const SubtractionQueueDescriptor*>(&descriptor);
616 return std::make_unique<RefSubtractionWorkload<int32_t>>(*subtractionQueueDescriptor,
info);
620 return std::make_unique<RefSubtractionWorkload<float>>(*subtractionQueueDescriptor,
info);
625 auto tileQueueDescriptor = PolymorphicDowncast<const TileQueueDescriptor*>(&descriptor);
626 return std::make_unique<RefTileWorkload>(*tileQueueDescriptor,
info);
630 auto transposeQueueDescriptor = PolymorphicDowncast<const TransposeQueueDescriptor*>(&descriptor);
633 return std::make_unique<RefTransposeQSymm16Workload>(*transposeQueueDescriptor,
info);
637 return std::make_unique<RefTransposeBFloat16Workload>(*transposeQueueDescriptor,
info);
641 return std::make_unique<RefTransposeQAsymmS8Workload>(*transposeQueueDescriptor,
info);
645 (*transposeQueueDescriptor,
info);
649 auto transposeConvolution2dQueueDescriptor
650 = PolymorphicDowncast<const TransposeConvolution2dQueueDescriptor*>(&descriptor);
651 return std::make_unique<RefTransposeConvolution2dWorkload>(*transposeConvolution2dQueueDescriptor,
info);
655 auto unidirectionalSequenceLstmQueueDescriptor
656 = PolymorphicDowncast<const UnidirectionalSequenceLstmQueueDescriptor*>(&descriptor);
657 return std::make_unique<RefUnidirectionalSequenceLstmWorkload>(*unidirectionalSequenceLstmQueueDescriptor,