ArmNN
 23.05
ClDepthToSpaceWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 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(Compute::Undefined, "ClDepthToSpaceWorkload_configure");
66  m_Layer.configure(clCompileContext, &input, &output, blockSize);
67  }
68 }
69 
71 {
72  ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClDepthToSpaceWorkload_Execute", this->GetGuid());
73  RunClFunction(m_Layer, CHECK_LOCATION());
74 }
75 
76 } // namespace armnn
armnn::BaseWorkload< DepthToSpaceQueueDescriptor >::GetGuid
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:61
armnn::QueueDescriptor::ValidateInputsOutputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Definition: WorkloadData.cpp:472
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnn::ClDepthToSpaceWorkload::Execute
void Execute() const override
Definition: ClDepthToSpaceWorkload.cpp:70
PolymorphicDowncast.hpp
armnn::ClDepthToSpaceWorkload::ClDepthToSpaceWorkload
ClDepthToSpaceWorkload(const DepthToSpaceQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Definition: ClDepthToSpaceWorkload.cpp:39
armnn::DepthToSpaceQueueDescriptor
Definition: WorkloadData.hpp:656
armnn::BaseWorkload< DepthToSpaceQueueDescriptor >::m_Data
DepthToSpaceQueueDescriptor m_Data
Definition: Workload.hpp:83
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::SpaceToDepthDescriptor
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
Definition: Descriptors.hpp:1042
armnn::SpaceToDepthDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1062
ArmComputeTensorUtils.hpp
ARMNN_SCOPED_PROFILING_EVENT
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
armnn::ClDepthToSpaceWorkloadValidate
arm_compute::Status ClDepthToSpaceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const DepthToSpaceDescriptor &descriptor)
Definition: ClDepthToSpaceWorkload.cpp:22
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::SpaceToDepthDescriptor::m_BlockSize
unsigned int m_BlockSize
Scalar specifying the input block size. It must be >= 1.
Definition: Descriptors.hpp:1059
armnn::RunClFunction
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
Definition: ClWorkloadUtils.hpp:160
armnn::Status
Status
Definition: Types.hpp:42
armnn::ClBaseWorkload
Definition: ClBaseWorkload.hpp:13
armnn::Compute::Undefined
@ Undefined
ClDepthToSpaceWorkload.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
ClWorkloadUtils.hpp
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
NumericCast.hpp
ARMNN_SCOPED_PROFILING_EVENT_CL_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_CL_GUID(name, guid)
Definition: ClWorkloadUtils.hpp:28
ClTensorHandle.hpp
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::BoostLogSeverityMapping::info
@ info