Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 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 | |
| 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 11 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 12 | |
| 13 | #include <cl/ClTensorHandle.hpp> |
| 14 | |
| 15 | #include <boost/cast.hpp> |
| 16 | |
| 17 | namespace armnn |
| 18 | { |
| 19 | |
| 20 | arm_compute::Status ClSliceWorkloadValidate(const TensorInfo& input, |
| 21 | const TensorInfo& output, |
| 22 | const SliceDescriptor& descriptor) |
| 23 | { |
| 24 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 25 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 26 | |
| 27 | arm_compute::Coordinates starts; |
| 28 | arm_compute::Coordinates ends; |
| 29 | |
| 30 | std::tie(starts, ends) = SetClSliceData(descriptor.m_Begin, descriptor.m_Size); |
| 31 | |
| 32 | return arm_compute::CLSlice::validate(&aclInput, &aclOutput, starts, ends); |
| 33 | } |
| 34 | |
| 35 | ClSliceWorkload::ClSliceWorkload(const SliceQueueDescriptor& descriptor, const WorkloadInfo& info) |
| 36 | : BaseWorkload<SliceQueueDescriptor>(descriptor, info) |
| 37 | { |
| 38 | m_Data.ValidateInputsOutputs("ClSliceWorkload", 1, 1); |
| 39 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 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(); |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 42 | |
| 43 | arm_compute::Coordinates starts; |
| 44 | arm_compute::Coordinates ends; |
| 45 | |
| 46 | std::tie(starts, ends) = SetClSliceData(m_Data.m_Parameters.m_Begin, m_Data.m_Parameters.m_Size); |
| 47 | |
| 48 | m_SliceFunction.configure(&input, &output, starts, ends); |
| 49 | } |
| 50 | |
| 51 | void ClSliceWorkload::Execute() const |
| 52 | { |
| 53 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClSliceWorkload_Execute"); |
| 54 | RunClFunction(m_SliceFunction, CHECK_LOCATION()); |
| 55 | } |
| 56 | |
| 57 | } // namespace armnn |