1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "ClSliceWorkload.hpp"
7
8 #include "ClWorkloadUtils.hpp"
9
10 #include <aclCommon/ArmComputeTensorUtils.hpp>
11 #include <armnn/utility/PolymorphicDowncast.hpp>
12
13 #include <cl/ClTensorHandle.hpp>
14
15 namespace armnn
16 {
17
ClSliceWorkloadValidate(const TensorInfo & input,const TensorInfo & output,const SliceDescriptor & descriptor)18 arm_compute::Status ClSliceWorkloadValidate(const TensorInfo& input,
19 const TensorInfo& output,
20 const SliceDescriptor& descriptor)
21 {
22 const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
23 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
24
25 arm_compute::Coordinates starts;
26 arm_compute::Coordinates ends;
27
28 std::tie(starts, ends) = SetClSliceData(descriptor.m_Begin, descriptor.m_Size);
29
30 return arm_compute::CLSlice::validate(&aclInput, &aclOutput, starts, ends);
31 }
32
ClSliceWorkload(const SliceQueueDescriptor & descriptor,const WorkloadInfo & info,const arm_compute::CLCompileContext & clCompileContext)33 ClSliceWorkload::ClSliceWorkload(const SliceQueueDescriptor& descriptor,
34 const WorkloadInfo& info,
35 const arm_compute::CLCompileContext& clCompileContext)
36 : ClBaseWorkload<SliceQueueDescriptor>(descriptor, info)
37 {
38 // Report Profiling Details
39 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSliceWorkload_Construct",
40 descriptor.m_Parameters,
41 info,
42 this->GetGuid());
43
44 m_Data.ValidateInputsOutputs("ClSliceWorkload", 1, 1);
45
46 arm_compute::ICLTensor& input = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
47 arm_compute::ICLTensor& output = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
48
49 arm_compute::Coordinates starts;
50 arm_compute::Coordinates ends;
51
52 std::tie(starts, ends) = SetClSliceData(m_Data.m_Parameters.m_Begin, m_Data.m_Parameters.m_Size);
53
54 {
55 ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClSliceWorkload_configure");
56 m_SliceFunction.configure(clCompileContext, &input, &output, starts, ends);
57 }
58 }
59
Execute() const60 void ClSliceWorkload::Execute() const
61 {
62 ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClSliceWorkload_Execute", this->GetGuid());
63 RunClFunction(m_SliceFunction, CHECK_LOCATION());
64 }
65
66 } // namespace armnn
67