ArmNN
 24.08
ClDepthToSpaceWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "ClWorkloadUtils.hpp"
9 
11 
14 
15 #include <cl/ClTensorHandle.hpp>
16 
17 namespace armnn
18 {
19 
20 using namespace armcomputetensorutils;
21 
23  const TensorInfo& output,
24  const DepthToSpaceDescriptor& descriptor)
25 {
26  DataLayout dataLayout = descriptor.m_DataLayout;
27  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, dataLayout);
28 
29  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_BlockSize);
30 
31  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, dataLayout);
32 
33  const arm_compute::Status aclStatus = arm_compute::CLDepthToSpaceLayer::validate(&aclInputInfo,
34  &aclOutputInfo,
35  blockSize);
36  return aclStatus;
37 }
38 
40  const WorkloadInfo& info,
41  const arm_compute::CLCompileContext& clCompileContext)
43 {
44  // Report Profiling Details
45  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClDepthToSpaceWorkload_Construct",
46  descriptor.m_Parameters,
47  info,
48  this->GetGuid());
49 
50  m_Data.ValidateInputsOutputs("ClDepthToSpaceWorkload", 1, 1);
51 
52  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
53 
54  arm_compute::ICLTensor& input =
55  PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Inputs[0])->GetTensor();
56  input.info()->set_data_layout(aclDataLayout);
57 
58  int32_t blockSize = armnn::numeric_cast<int32_t>(descriptor.m_Parameters.m_BlockSize);
59 
60  arm_compute::ICLTensor& output =
61  PolymorphicPointerDowncast<IClTensorHandle>(m_Data.m_Outputs[0])->GetTensor();
62  output.info()->set_data_layout(aclDataLayout);
63 
64  {
65  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClDepthToSpaceWorkload_configure");
66  m_Layer.configure(clCompileContext, &input, &output, blockSize);
67  }
68 }
69 
71 {
72  ARMNN_SCOPED_PROFILING_EVENT_CL_NAME_GUID("ClDepthToSpaceWorkload_Execute");
73  RunClFunction(m_Layer, CHECK_LOCATION());
74 }
75 
76 } // namespace armnn
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
ClDepthToSpaceWorkload.hpp
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
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::ClDepthToSpaceWorkloadValidate
arm_compute::Status ClDepthToSpaceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &descriptor)
Definition: ClDepthToSpaceWorkload.cpp:22
armnn::ClBaseWorkload
Definition: ClBaseWorkload.hpp:13
NumericCast.hpp
armnn::ClDepthToSpaceWorkload::Execute
void Execute() const override
Definition: ClDepthToSpaceWorkload.cpp:70
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::ClDepthToSpaceWorkload::ClDepthToSpaceWorkload
ClDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: ClDepthToSpaceWorkload.cpp:39
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::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
PolymorphicDowncast.hpp
ClWorkloadUtils.hpp
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::SpaceToDepthDescriptor::m_BlockSize
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
Definition: Descriptors.hpp:1092
armnn::Status
Status
Definition: Types.hpp:42
ClTensorHandle.hpp
armnn::BaseWorkload< DepthToSpaceQueueDescriptor >::m_Data
DepthToSpaceQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:167
armnn::DepthToSpaceQueueDescriptor
Definition: WorkloadData.hpp:661
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
armnn::SpaceToDepthDescriptor
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
Definition: Descriptors.hpp:1075
armnn::SpaceToDepthDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1095