Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClMeanWorkload.hpp" |
| 7 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <cl/ClTensorHandle.hpp> |
| 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 10 | |
| 11 | #include "ClWorkloadUtils.hpp" |
| 12 | |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 13 | namespace armnn |
| 14 | { |
| 15 | using namespace armcomputetensorutils; |
| 16 | |
| 17 | arm_compute::Status ClMeanValidate(const TensorInfo& input, |
| 18 | const TensorInfo& output, |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 19 | const MeanDescriptor& descriptor) |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 20 | { |
| 21 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 22 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 23 | |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 24 | arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(), |
| 25 | input.GetNumDimensions(), |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 26 | descriptor.m_Axis); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 27 | |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 28 | return arm_compute::CLReduceMean::validate(&aclInputInfo, coords, descriptor.m_KeepDims, &aclOutputInfo); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 29 | } |
| 30 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 31 | ClMeanWorkload::ClMeanWorkload(const MeanQueueDescriptor& descriptor, |
| 32 | const WorkloadInfo& info, |
| 33 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 34 | : ClBaseWorkload<MeanQueueDescriptor>(descriptor, info) |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 35 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 36 | // Report Profiling Details |
| 37 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClMeanWorkload_Construct", |
| 38 | descriptor.m_Parameters, |
| 39 | info, |
| 40 | this->GetGuid()); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 41 | m_Data.ValidateInputsOutputs("ClMeanWorkload", 1, 1); |
| 42 | |
| 43 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 44 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 45 | |
Matthew Bentham | fd89996 | 2018-12-31 15:49:42 +0000 | [diff] [blame] | 46 | arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(input.info()->num_dimensions(), |
| 47 | info.m_InputTensorInfos[0].GetNumDimensions(), |
| 48 | m_Data.m_Parameters.m_Axis); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 49 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 50 | { |
| 51 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClMeanWorkload_configure"); |
| 52 | m_Layer.configure(clCompileContext, &input, coords, m_Data.m_Parameters.m_KeepDims, &output); |
| 53 | } |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | void ClMeanWorkload::Execute() const |
| 57 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 58 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClMeanWorkload_Execute", this->GetGuid()); |
Matteo Martincigh | 28dcab6 | 2018-10-19 16:40:03 +0100 | [diff] [blame] | 59 | m_Layer.run(); |
| 60 | } |
| 61 | |
| 62 | } //namespace armnn |