Sadik Armagan | f40d6d4 | 2021-04-22 09:12:11 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2021 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClCastWorkload.hpp" |
| 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 10 | |
| 11 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 12 | |
| 13 | #include <cl/ClTensorHandle.hpp> |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | static constexpr arm_compute::ConvertPolicy g_AclConvertPolicy = arm_compute::ConvertPolicy::SATURATE; |
| 19 | |
| 20 | arm_compute::Status ClCastValidate(const TensorInfo& input, const TensorInfo& output) |
| 21 | { |
| 22 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 23 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 24 | |
| 25 | return arm_compute::CLCast::validate(&aclInput, &aclOutput, g_AclConvertPolicy); |
| 26 | } |
| 27 | |
| 28 | ClCastWorkload::ClCastWorkload(const CastQueueDescriptor& descriptor, |
| 29 | const WorkloadInfo& info, |
| 30 | const arm_compute::CLCompileContext& clCompileContext) |
| 31 | : BaseWorkload<CastQueueDescriptor>(descriptor, info) |
| 32 | { |
| 33 | m_Data.ValidateInputsOutputs("ClCastWorkload", 1, 1); |
| 34 | |
| 35 | arm_compute::ICLTensor& input = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 36 | arm_compute::ICLTensor& output = PolymorphicDowncast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 37 | |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 38 | { |
| 39 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClCastWorkload_configure"); |
| 40 | m_CastLayer.configure(clCompileContext, &input, &output, g_AclConvertPolicy); |
| 41 | } |
Sadik Armagan | f40d6d4 | 2021-04-22 09:12:11 +0100 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void ClCastWorkload::Execute() const |
| 45 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 46 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClCastWorkload_Execute", this->GetGuid()); |
Sadik Armagan | f40d6d4 | 2021-04-22 09:12:11 +0100 | [diff] [blame] | 47 | RunClFunction(m_CastLayer, CHECK_LOCATION()); |
| 48 | } |
| 49 | |
| 50 | } // namespace armnn |