ArmNN
 24.02
NeonStackWorkload.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 #include "NeonStackWorkload.hpp"
6 #include "NeonWorkloadUtils.hpp"
7 
13 
14 namespace armnn
15 {
16 using namespace armcomputetensorutils;
17 
18 namespace
19 {
20 int CalcAxis(const unsigned int axis, const unsigned int inputDimensions)
21 {
22  const int intAxis = armnn::numeric_cast<int>(axis);
23  return armnn::numeric_cast<int>(inputDimensions) - intAxis;
24 }
25 } //namespace
26 
27 arm_compute::Status NeonStackWorkloadValidate(const std::vector<const TensorInfo*>& inputs,
28  const TensorInfo& output,
29  const StackDescriptor& descriptor)
30 {
31  std::vector<arm_compute::TensorInfo> aclInputs;
32  for (const TensorInfo* input : inputs)
33  {
34  arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(*input, armnn::DataLayout::NCHW);
35  aclInputs.emplace_back(aclInputInfo);
36  }
37 
38  std::vector<arm_compute::ITensorInfo*> aclInputPtrs;
39  for (arm_compute::ITensorInfo& input : aclInputs)
40  {
41  aclInputPtrs.emplace_back(&input);
42  }
43 
44  const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output);
45  int aclAxis = CalcAxis(descriptor.m_Axis, descriptor.m_InputShape.GetNumDimensions());
46  return arm_compute::NEStackLayer::validate(aclInputPtrs, aclAxis, &aclOutputInfo);
47 }
48 
51 {
52  // Report Profiling Details
53  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonStackWorkload_Construct",
54  descriptor.m_Parameters,
55  info,
56  this->GetGuid());
57 
58  std::vector<arm_compute::ITensor*> aclInputs;
59  for (auto input : m_Data.m_Inputs)
60  {
61  arm_compute::ITensor& aclInput = PolymorphicPointerDowncast<IAclTensorHandle>(input)->GetTensor();
62  aclInputs.emplace_back(&aclInput);
63  }
64  arm_compute::ITensor& output = PolymorphicPointerDowncast<IAclTensorHandle>(
65  m_Data.m_Outputs[0])->GetTensor();
66 
67  m_Layer.reset(new arm_compute::NEStackLayer());
68  int aclAxis = CalcAxis(descriptor.m_Parameters.m_Axis, descriptor.m_Parameters.m_InputShape.GetNumDimensions());
69  m_Layer->configure(aclInputs, aclAxis, &output);
70 }
71 
73 {
74  if (m_Layer)
75  {
76  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonStackWorkload_Execute");
77  m_Layer->run();
78  }
79 }
80 
81 } //namespace armnn
armnn::NeonStackWorkloadValidate
arm_compute::Status NeonStackWorkloadValidate(const std::vector< const TensorInfo * > &inputs, const TensorInfo &output, const StackDescriptor &descriptor)
Definition: NeonStackWorkload.cpp:27
armnn::StackQueueDescriptor
Definition: WorkloadData.hpp:152
armnn::TensorInfo
Definition: Tensor.hpp:152
NeonTensorHandle.hpp
armnn::NeonStackWorkload::Execute
void Execute() const override
Definition: NeonStackWorkload.cpp:72
armnn::StackDescriptor
A StackDescriptor for the StackLayer.
Definition: Descriptors.hpp:1251
NumericCast.hpp
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::TensorShape::GetNumDimensions
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
PolymorphicDowncast.hpp
armnn::StackDescriptor::m_Axis
uint32_t m_Axis
0-based axis along which to stack the input tensors.
Definition: Descriptors.hpp:1273
armnn::BoostLogSeverityMapping::info
@ info
armnn::StackDescriptor::m_InputShape
TensorShape m_InputShape
Required shape of all input tensors.
Definition: Descriptors.hpp:1277
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
TensorHandle.hpp
armnn::Status
Status
Definition: Types.hpp:42
armnn::BaseWorkload< StackQueueDescriptor >::m_Data
StackQueueDescriptor m_Data
Definition: Workload.hpp:89
NeonWorkloadUtils.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
NeonStackWorkload.hpp
ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: NeonWorkloadUtils.hpp:32
armnn::NeonStackWorkload::NeonStackWorkload
NeonStackWorkload(const StackQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonStackWorkload.cpp:49
armnn::NeonBaseWorkload
Definition: NeonBaseWorkload.hpp:13
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::DataLayout::NCHW
@ NCHW