Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 1 | // |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 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 | |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 15 | namespace armnn |
| 16 | { |
| 17 | |
| 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 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 33 | ClSliceWorkload::ClSliceWorkload(const SliceQueueDescriptor& descriptor, |
| 34 | const WorkloadInfo& info, |
| 35 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 36 | : ClBaseWorkload<SliceQueueDescriptor>(descriptor, info) |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 37 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 38 | // Report Profiling Details |
| 39 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClSliceWorkload_Construct", |
| 40 | descriptor.m_Parameters, |
| 41 | info, |
| 42 | this->GetGuid()); |
| 43 | |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 44 | m_Data.ValidateInputsOutputs("ClSliceWorkload", 1, 1); |
| 45 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 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(); |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 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 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 54 | { |
| 55 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClSliceWorkload_configure"); |
| 56 | m_SliceFunction.configure(clCompileContext, &input, &output, starts, ends); |
| 57 | } |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void ClSliceWorkload::Execute() const |
| 61 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 62 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClSliceWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | 94c4fef | 2019-11-25 15:37:08 +0000 | [diff] [blame] | 63 | RunClFunction(m_SliceFunction, CHECK_LOCATION()); |
| 64 | } |
| 65 | |
| 66 | } // namespace armnn |