ArmNN
 20.02
ClSliceWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClSliceWorkload.hpp"
7 
8 #include "ClWorkloadUtils.hpp"
9 
11 
12 #include <cl/ClTensorHandle.hpp>
13 
14 #include <boost/cast.hpp>
15 
16 namespace armnn
17 {
18 
20  const TensorInfo& output,
21  const SliceDescriptor& descriptor)
22 {
23  const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24  const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25 
28 
29  std::tie(starts, ends) = SetClSliceData(descriptor.m_Begin, descriptor.m_Size);
30 
31  return arm_compute::CLSlice::validate(&aclInput, &aclOutput, starts, ends);
32 }
33 
35  : BaseWorkload<SliceQueueDescriptor>(descriptor, info)
36 {
37  m_Data.ValidateInputsOutputs("ClSliceWorkload", 1, 1);
38 
39  arm_compute::ICLTensor& input = boost::polymorphic_downcast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
40  arm_compute::ICLTensor& output = boost::polymorphic_downcast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
41 
44 
46 
47  m_SliceFunction.configure(&input, &output, starts, ends);
48 }
49 
51 {
52  ARMNN_SCOPED_PROFILING_EVENT_CL("ClSliceWorkload_Execute");
53  RunClFunction(m_SliceFunction, CHECK_LOCATION());
54 }
55 
56 } // namespace armnn
virtual void Execute() const override
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
arm_compute::Status ClSliceWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const SliceDescriptor &descriptor)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
const SliceQueueDescriptor m_Data
Definition: Workload.hpp:46
std::vector< unsigned int > m_Size
Size of the slice in each dimension.
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2020 ARM Limited.
ClSliceWorkload(const SliceQueueDescriptor &descriptor, const WorkloadInfo &info)
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
Status
enumeration
Definition: Types.hpp:26
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
A SliceDescriptor for the SliceLayer.
auto SetClSliceData(const std::vector< unsigned int > &m_begin, const std::vector< unsigned int > &m_size)
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs