ArmNN
 22.11
ClMeanWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClMeanWorkload.hpp"
7 
8 #include <cl/ClTensorHandle.hpp>
10 
11 #include "ClWorkloadUtils.hpp"
12 
13 namespace armnn
14 {
15 using namespace armcomputetensorutils;
16 
18  const TensorInfo& output,
19  const MeanDescriptor& descriptor)
20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclInputInfo.num_dimensions(),
25  input.GetNumDimensions(),
26  descriptor.m_Axis);
27 
28  return arm_compute::CLReduceMean::validate(&aclInputInfo, coords, descriptor.m_KeepDims, &aclOutputInfo);
29 }
30 
32  const WorkloadInfo& info,
33  const arm_compute::CLCompileContext& clCompileContext)
34  : ClBaseWorkload<MeanQueueDescriptor>(descriptor, info)
35 {
36  // Report Profiling Details
37  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClMeanWorkload_Construct",
38  descriptor.m_Parameters,
39  info,
40  this->GetGuid());
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 
46  arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(input.info()->num_dimensions(),
47  info.m_InputTensorInfos[0].GetNumDimensions(),
49 
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  }
54 }
55 
57 {
58  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClMeanWorkload_Execute", this->GetGuid());
59  m_Layer.run();
60 }
61 
62 } //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
void Execute() const override
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
arm_compute::Status ClMeanValidate(const TensorInfo &input, const TensorInfo &output, const MeanDescriptor &descriptor)
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
std::vector< TensorInfo > m_InputTensorInfos
bool m_KeepDims
Enable/disable keep dimensions. If true, then the reduced dimensions that are of length 1 are kept...
Status
enumeration
Definition: Types.hpp:42
std::vector< ITensorHandle * > m_Outputs
A MeanDescriptor for the MeanLayer.
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
ClMeanWorkload(const MeanQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:195