ArmNN
 24.08
NeonStridedSliceWorkload.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 "NeonWorkloadUtils.hpp"
15 
16 namespace armnn
17 {
18 
20  const TensorInfo& output,
21  const StridedSliceDescriptor& descriptor)
22 {
23  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input,
24  descriptor.m_DataLayout);
25  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output,
26  descriptor.m_DataLayout);
27 
31 
32  std::tie(starts, ends, strides) = SetNeonStridedSliceData(descriptor.m_Begin,
33  descriptor.m_End,
34  descriptor.m_Stride);
35 
36  auto numDimensions = armnn::numeric_cast<int>(input.GetNumDimensions());
37  int32_t begin_mask = ConvertMaskToACLFormat(descriptor.m_BeginMask, numDimensions);
38  int32_t end_mask = ConvertMaskToACLFormat(descriptor.m_EndMask, numDimensions);
39  int32_t shrink_axis_mask = ConvertMaskToACLFormat(descriptor.m_ShrinkAxisMask, numDimensions);
40 
41  return arm_compute::NEStridedSlice::validate(&aclInput,
42  &aclOutput,
43  starts,
44  ends,
45  strides,
46  begin_mask,
47  end_mask,
48  shrink_axis_mask);
49 }
50 
52  const WorkloadInfo& info)
54 {
55  // Report Profiling Details
56  ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonStridedSliceWorkload_Construct",
57  descriptor.m_Parameters,
58  info,
59  this->GetGuid());
60 
61  m_Data.ValidateInputsOutputs("NeonStridedSliceWorkload", 1, 1);
62 
63  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
64  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
65 
69 
70  std::tie(starts, ends, strides) = SetNeonStridedSliceData(m_Data.m_Parameters.m_Begin,
73 
74  auto numDimensions = armnn::numeric_cast<int>(info.m_InputTensorInfos[0].GetNumDimensions());
75  int32_t begin_mask = ConvertMaskToACLFormat(m_Data.m_Parameters.m_BeginMask, numDimensions);
76  int32_t end_mask = ConvertMaskToACLFormat(m_Data.m_Parameters.m_EndMask, numDimensions);
77  int32_t shrink_axis_mask = ConvertMaskToACLFormat(m_Data.m_Parameters.m_ShrinkAxisMask, numDimensions);
78 
79  arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout);
80  input.info()->set_data_layout(aclDataLayout);
81  output.info()->set_data_layout(aclDataLayout);
82 
83  auto layer = std::make_unique<arm_compute::NEStridedSlice>();
84 
85  layer->configure(&input,
86  &output,
87  starts,
88  ends,
89  strides,
90  begin_mask,
91  end_mask,
92  shrink_axis_mask);
93  m_Layer.reset(layer.release());
94 }
95 
97 {
98  ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonStridedSliceWorkload_Execute");
99  m_Layer->run();
100 }
101 
102 } //namespace armnn
NeonStridedSliceWorkload.hpp
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::StridedSliceDescriptor::m_Begin
std::vector< int > m_Begin
Begin values for the input that will be sliced.
Definition: Descriptors.hpp:1342
WorkloadUtils.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
NeonTensorHandle.hpp
armnn::SetNeonStridedSliceData
auto SetNeonStridedSliceData(const std::vector< int > &m_begin, const std::vector< int > &m_end, const std::vector< int > &m_stride)
Definition: NeonWorkloadUtils.hpp:138
armnn::TensorInfo::GetNumDimensions
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:197
armnn::StridedSliceDescriptor::m_BeginMask
int32_t m_BeginMask
Begin mask value.
Definition: Descriptors.hpp:1350
armnn::Coordinates
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
Definition: InternalTypes.hpp:15
NumericCast.hpp
armnn::StridedSliceDescriptor::m_DataLayout
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
Definition: Descriptors.hpp:1363
armnn::QueueDescriptorWithParameters::m_Parameters
LayerDescriptor m_Parameters
Definition: WorkloadData.hpp:66
armnn::StridedSliceQueueDescriptor
Definition: WorkloadData.hpp:467
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
PolymorphicDowncast.hpp
armnn::NeonStridedSliceWorkload::Execute
virtual void Execute() const override
Definition: NeonStridedSliceWorkload.cpp:96
armnn::NeonStridedSliceWorkload::NeonStridedSliceWorkload
NeonStridedSliceWorkload(const StridedSliceQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: NeonStridedSliceWorkload.cpp:51
ArmComputeUtils.hpp
armnn::StridedSliceDescriptor::m_EndMask
int32_t m_EndMask
End mask value.
Definition: Descriptors.hpp:1353
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::StridedSliceDescriptor::m_ShrinkAxisMask
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1.
Definition: Descriptors.hpp:1355
ARMNN_REPORT_PROFILING_WORKLOAD_DESC
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
armnn::StridedSliceDescriptor::m_Stride
std::vector< int > m_Stride
Stride values for the input that will be sliced.
Definition: Descriptors.hpp:1346
armnn::StridedSliceDescriptor
A StridedSliceDescriptor for the StridedSliceLayer.
Definition: Descriptors.hpp:1303
armnn::Status
Status
Definition: Types.hpp:42
armnn::BaseWorkload< StridedSliceQueueDescriptor >::m_Data
StridedSliceQueueDescriptor m_Data
Definition: Workload.hpp:89
NeonWorkloadUtils.hpp
armnn::ConvertMaskToACLFormat
int32_t ConvertMaskToACLFormat(int32_t mask, int32_t numDim)
Definition: WorkloadUtils.cpp:299
armnn::NeonStridedSliceWorkloadValidate
arm_compute::Status NeonStridedSliceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const StridedSliceDescriptor &descriptor)
Definition: NeonStridedSliceWorkload.cpp:19
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
ArmComputeTensorUtils.hpp
armnn::StridedSliceDescriptor::m_End
std::vector< int > m_End
End values for the input that will be sliced.
Definition: Descriptors.hpp:1344
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:33
armnn::NeonBaseWorkload
Definition: NeonBaseWorkload.hpp:13
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26