1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "NeonSliceWorkload.hpp"
7
8 #include "NeonWorkloadUtils.hpp"
9
10 #include <armnn/utility/PolymorphicDowncast.hpp>
11
12 #include <aclCommon/ArmComputeTensorUtils.hpp>
13
14 #include <neon/NeonTensorHandle.hpp>
15
16 #include <arm_compute/core/Error.h>
17
18 namespace armnn
19 {
20
NeonSliceWorkloadValidate(const TensorInfo & input,const TensorInfo & output,const SliceDescriptor & descriptor)21 arm_compute::Status NeonSliceWorkloadValidate(const TensorInfo& input,
22 const TensorInfo& output,
23 const SliceDescriptor& descriptor)
24 {
25 const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
26 const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
27
28 arm_compute::Coordinates starts;
29 arm_compute::Coordinates ends;
30
31 std::tie(starts, ends) = SetNeonSliceData(descriptor.m_Begin, descriptor.m_Size);
32
33 return arm_compute::NESlice::validate(&aclInputInfo, &aclOutputInfo, starts, ends);
34 }
35
NeonSliceWorkload(const SliceQueueDescriptor & descriptor,const WorkloadInfo & info)36 NeonSliceWorkload::NeonSliceWorkload(const SliceQueueDescriptor& descriptor,
37 const WorkloadInfo& info)
38 : NeonBaseWorkload<SliceQueueDescriptor>(descriptor, info)
39 {
40 // Report Profiling Details
41 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonSliceWorkload_Construct",
42 descriptor.m_Parameters,
43 info,
44 this->GetGuid());
45
46
47 m_Data.ValidateInputsOutputs("NeonSliceWorkload", 1, 1);
48
49 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
50 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
51
52 arm_compute::Coordinates starts;
53 arm_compute::Coordinates ends;
54
55 std::tie(starts, ends) = SetNeonSliceData(m_Data.m_Parameters.m_Begin, m_Data.m_Parameters.m_Size);
56
57 m_SliceFunction.configure(&input, &output, starts, ends);
58 }
59
Execute() const60 void NeonSliceWorkload::Execute() const
61 {
62 ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonSliceWorkload_Execute", this->GetGuid());
63 m_SliceFunction.run();
64 }
65
66 } // namespace armnn
67