ArmNN
 24.08
ClPooling3dWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include <cl/ClLayerSupport.hpp>
8 #include <cl/ClTensorHandle.hpp>
11 
12 #include "ClWorkloadUtils.hpp"
13 
14 namespace armnn
15 {
16  using namespace armcomputetensorutils;
17 
19  const TensorInfo& output,
20  const Pooling3dDescriptor& descriptor)
21  {
22  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
23  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
24 
25  arm_compute::Pooling3dLayerInfo layerInfo = BuildArmComputePooling3dLayerInfo(descriptor);
26 
27  return arm_compute::CLPooling3dLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo);
28  }
29 
31  const WorkloadInfo& info,
32  const arm_compute::CLCompileContext& clCompileContext)
34  {
35  // Report Profiling Details
36  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClPooling3dWorkload_Construct",
37  descriptor.m_Parameters,
38  info,
39  this->GetGuid());
40 
41  m_Data.ValidateInputsOutputs("ClPooling3dWorkload", 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::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
47  input.info()->set_data_layout(aclDataLayout);
48  output.info()->set_data_layout(aclDataLayout);
49 
50  // flag to use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy
51  // enable fp_mixed_precision for the the FP16 cases that
52  // accumulation reaches a limit beyond which there is no more increment of the value
53  bool fpMixedPrecision = false;
54 
55  arm_compute::Pooling3dLayerInfo layerInfo = BuildArmComputePooling3dLayerInfo(m_Data.m_Parameters,
56  fpMixedPrecision);
57 
58  {
59  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClPooling3dWorkload_configure");
60  // Run the layer.
61  m_PoolingLayer.configure(clCompileContext, &input, &output, layerInfo);
62  }
63  }
64 
66  {
67  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClPooling3dWorkload_Execute");
68  RunClFunction(m_PoolingLayer, CHECK_LOCATION());
69  }
70 
71 }
72 
73 
ClPooling3dWorkload.hpp
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::Pooling3dDescriptor
A Pooling3dDescriptor for the Pooling3dLayer.
Definition: Descriptors.hpp:431
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:447
armnn::TensorInfo
Definition: Tensor.hpp:152
ClLayerSupport.hpp
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::ClBaseWorkload
Definition: ClBaseWorkload.hpp:13
armnn::Pooling3dDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCDHW, NDHWC).
Definition: Descriptors.hpp:503
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: ClWorkloadUtils.hpp:36
armnn::ClPooling3dWorkloadValidate
arm_compute::Status ClPooling3dWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const Pooling3dDescriptor &descriptor)
Definition: ClPooling3dWorkload.cpp:18
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::Pooling3dQueueDescriptor
Definition: WorkloadData.hpp:203
ClWorkloadUtils.hpp
ArmComputeUtils.hpp
armnn::ClPooling3dWorkload::ClPooling3dWorkload
ClPooling3dWorkload(const Pooling3dQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: ClPooling3dWorkload.cpp:30
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::IClTensorHandle
Definition: IClTensorHandle.hpp:13
armnn::Status
Status
Definition: Types.hpp:42
ClTensorHandle.hpp
armnn::BaseWorkload< Pooling3dQueueDescriptor >::m_Data
Pooling3dQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:167
armnn::ClPooling3dWorkload::Execute
void Execute() const override
Definition: ClPooling3dWorkload.cpp:65
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26