Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonMeanWorkload.hpp" |
| 7 | |
| 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 9 | |
| 10 | #include <neon/NeonTensorHandle.hpp> |
| 11 | |
| 12 | #include "NeonWorkloadUtils.hpp" |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | using namespace armcomputetensorutils; |
| 17 | |
| 18 | arm_compute::Status NeonMeanWorkloadValidate(const TensorInfo& input, |
| 19 | const TensorInfo& output, |
| 20 | const MeanDescriptor& desc) |
| 21 | { |
| 22 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 23 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 24 | |
| 25 | arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(), |
| 26 | input.GetNumDimensions(), |
| 27 | desc.m_Axis); |
| 28 | |
| 29 | return arm_compute::NEReduceMean::validate(&aclInputInfo, coords, desc.m_KeepDims, &aclOutputInfo); |
| 30 | } |
| 31 | |
| 32 | NeonMeanWorkload::NeonMeanWorkload(const MeanQueueDescriptor& descriptor, const WorkloadInfo& info) |
| 33 | : BaseWorkload<MeanQueueDescriptor>(descriptor, info) |
| 34 | { |
| 35 | m_Data.ValidateInputsOutputs("NeonMeanWorkload", 1, 1); |
| 36 | |
Derek Lamberti | c81855f | 2019-06-13 17:34:19 +0100 | [diff] [blame] | 37 | arm_compute::ITensor& input = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 38 | arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 39 | |
| 40 | arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(input.info()->num_dimensions(), |
| 41 | info.m_InputTensorInfos[0].GetNumDimensions(), |
| 42 | m_Data.m_Parameters.m_Axis); |
| 43 | |
| 44 | m_Layer.configure(&input, coords, m_Data.m_Parameters.m_KeepDims, &output); |
| 45 | } |
| 46 | |
| 47 | void NeonMeanWorkload::Execute() const |
| 48 | { |
| 49 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonMeanWorkload_Execute"); |
| 50 | m_Layer.run(); |
| 51 | } |
| 52 | |
| 53 | } //namespace armnn |