Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 1 | // |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefDetectionPostProcessWorkload.hpp" |
| 7 | |
| 8 | #include "Decoders.hpp" |
| 9 | #include "DetectionPostProcess.hpp" |
| 10 | #include "Profiling.hpp" |
| 11 | #include "RefWorkloadUtils.hpp" |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | RefDetectionPostProcessWorkload::RefDetectionPostProcessWorkload( |
| 17 | const DetectionPostProcessQueueDescriptor& descriptor, const WorkloadInfo& info) |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 18 | : RefBaseWorkload<DetectionPostProcessQueueDescriptor>(descriptor, info), |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 19 | m_Anchors(std::make_unique<ScopedTensorHandle>(*(descriptor.m_Anchors))) {} |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 20 | |
| 21 | void RefDetectionPostProcessWorkload::Execute() const |
| 22 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 23 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 24 | } |
| 25 | |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 26 | void RefDetectionPostProcessWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 27 | { |
Matthew Sloyan | 21a6a1a | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 28 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 29 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | void RefDetectionPostProcessWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 33 | std::vector<ITensorHandle*> outputs) const |
| 34 | { |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 35 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefDetectionPostProcessWorkload_Execute"); |
| 36 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 37 | const TensorInfo& boxEncodingsInfo = GetTensorInfo(inputs[0]); |
| 38 | const TensorInfo& scoresInfo = GetTensorInfo(inputs[1]); |
Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame] | 39 | const TensorInfo& anchorsInfo = m_Anchors->GetTensorInfo(); |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 40 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 41 | const TensorInfo& detectionBoxesInfo = GetTensorInfo(outputs[0]); |
| 42 | const TensorInfo& detectionClassesInfo = GetTensorInfo(outputs[1]); |
| 43 | const TensorInfo& detectionScoresInfo = GetTensorInfo(outputs[2]); |
| 44 | const TensorInfo& numDetectionsInfo = GetTensorInfo(outputs[3]); |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 45 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 46 | auto boxEncodings = MakeDecoder<float>(boxEncodingsInfo, inputs[0]->Map()); |
| 47 | auto scores = MakeDecoder<float>(scoresInfo, inputs[1]->Map()); |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 48 | auto anchors = MakeDecoder<float>(anchorsInfo, m_Anchors->Map(false)); |
| 49 | |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 50 | float* detectionBoxes = reinterpret_cast<float*>(outputs[0]->Map()); |
| 51 | float* detectionClasses = reinterpret_cast<float*>(outputs[1]->Map()); |
| 52 | float* detectionScores = reinterpret_cast<float*>(outputs[2]->Map()); |
| 53 | float* numDetections = reinterpret_cast<float*>(outputs[3]->Map()); |
Aron Virginas-Tar | 6331f91 | 2019-06-03 17:10:02 +0100 | [diff] [blame] | 54 | |
| 55 | DetectionPostProcess(boxEncodingsInfo, scoresInfo, anchorsInfo, |
| 56 | detectionBoxesInfo, detectionClassesInfo, |
| 57 | detectionScoresInfo, numDetectionsInfo, m_Data.m_Parameters, |
| 58 | *boxEncodings, *scores, *anchors, detectionBoxes, |
| 59 | detectionClasses, detectionScores, numDetections); |
| 60 | } |
| 61 | |
| 62 | } //namespace armnn |