ArmNN
 21.02
NeonSpaceToBatchNdWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "NeonWorkloadUtils.hpp"
9 
12 
13 #include <ResolveType.hpp>
14 
15 namespace armnn
16 {
17 
18 using namespace armcomputetensorutils;
19 
21  const TensorInfo& output,
22  const SpaceToBatchNdDescriptor& descriptor)
23 {
24  const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
25  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
26 
27  // ArmNN blockShape is [H, W] Cl asks for W, H
28  int32_t blockHeight = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[0]);
29  int32_t blockWidth = armnn::numeric_cast<int32_t>(descriptor.m_BlockShape[1]);
30 
31  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(
32  descriptor.m_PadList[1].first, descriptor.m_PadList[0].first);
33  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(
34  descriptor.m_PadList[1].second, descriptor.m_PadList[0].second);
35 
36  return arm_compute::NESpaceToBatchLayer::validate(&aclInputInfo,
37  blockWidth,
38  blockHeight,
39  paddingLeftTop,
40  paddingRightBottom,
41  &aclOutputInfo);
42 }
43 
45  const WorkloadInfo& info)
47 {
48  m_Data.ValidateInputsOutputs("NESpaceToBatchNdWorkload", 1, 1);
49 
50  arm_compute::ITensor& input =
51  PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Inputs[0])->GetTensor();
52  arm_compute::ITensor& output =
53  PolymorphicPointerDowncast<IAclTensorHandle>(m_Data.m_Outputs[0])->GetTensor();
54 
55  // ArmNN blockShape is [H, W] Cl asks for W, H
56  int32_t blockHeight = armnn::numeric_cast<int32_t>(m_Data.m_Parameters.m_BlockShape[0]);
57  int32_t blockWidth = armnn::numeric_cast<int32_t>(m_Data.m_Parameters.m_BlockShape[1]);
58 
59  arm_compute::Size2D paddingLeftTop = BuildArmComputeSize2D(
61  arm_compute::Size2D paddingRightBottom = BuildArmComputeSize2D(
63 
64  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
65  input.info()->set_data_layout(aclDataLayout);
66  output.info()->set_data_layout(aclDataLayout);
67 
68  m_Layer.reset(new arm_compute::NESpaceToBatchLayer());
69  m_Layer->configure(&input,
70  blockWidth,
71  blockHeight,
72  paddingLeftTop,
73  paddingRightBottom,
74  &output);
75  m_Layer->prepare();
76 }
77 
79 {
80  if (m_Layer)
81  {
82  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSpaceToBatchNdWorkload_Execute");
83  m_Layer->run();
84  }
85 }
86 
87 } //namespace armnn
DataLayout
Definition: Types.hpp:50
const SpaceToBatchNdQueueDescriptor m_Data
Definition: Workload.hpp:46
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding values for the input dimension: heightPad{top, bottom} widthPad{left, right}.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
arm_compute::Status NeonSpaceToBatchNdWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const SpaceToBatchNdDescriptor &descriptor)
NeonSpaceToBatchNdWorkload(const SpaceToBatchNdQueueDescriptor &descriptor, const WorkloadInfo &info)
Status
enumeration
Definition: Types.hpp:26
std::vector< unsigned int > m_BlockShape
Block shape value.
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
std::vector< ITensorHandle * > m_Outputs
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs