ArmNN
 21.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 
12 
13 #include <cl/ClTensorHandle.hpp>
14 
15 namespace armnn
16 {
17 
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 
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 
34  const WorkloadInfo& info,
35  const arm_compute::CLCompileContext& clCompileContext)
36  : BaseWorkload<SliceQueueDescriptor>(descriptor, info)
37 {
38  m_Data.ValidateInputsOutputs("ClSliceWorkload", 1, 1);
39 
40  arm_compute::ICLTensor& input = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
41  arm_compute::ICLTensor& output = PolymorphicDowncast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
42 
45 
47 
48  m_SliceFunction.configure(clCompileContext, &input, &output, starts, ends);
49 }
50 
52 {
53  ARMNN_SCOPED_PROFILING_EVENT_CL("ClSliceWorkload_Execute");
54  RunClFunction(m_SliceFunction, CHECK_LOCATION());
55 }
56 
57 } // 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) 2021 ARM Limited and Contributors.
std::vector< unsigned int > m_Begin
Beginning indices of the slice in each dimension.
ClSliceWorkload(const SliceQueueDescriptor &descriptor, const WorkloadInfo &info, const arm_compute::CLCompileContext &clCompileContext)
Status
enumeration
Definition: Types.hpp:26
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
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