Teresa Charlin | c1f6b09 | 2020-05-11 16:10:38 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClSoftmaxWorkload.hpp" |
| 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 10 | #include <aclCommon/ArmComputeUtils.hpp> |
| 11 | |
| 12 | #include <cl/ClTensorHandle.hpp> |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | arm_compute::Status ClSoftmaxWorkloadValidate(const TensorInfo& input, |
| 18 | const TensorInfo& output, |
| 19 | const SoftmaxDescriptor& descriptor) |
| 20 | { |
| 21 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 22 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 23 | |
| 24 | unsigned int aclAxis = ComputeSoftmaxAclAxis<unsigned int>(descriptor, input); |
| 25 | return arm_compute::CLSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); |
| 26 | } |
| 27 | |
| 28 | ClSoftmaxWorkload::ClSoftmaxWorkload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, |
| 29 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
| 30 | : BaseWorkload<SoftmaxQueueDescriptor>(descriptor, info) |
| 31 | , m_SoftmaxLayer(memoryManager) |
| 32 | { |
| 33 | m_Data.ValidateInputsOutputs("ClSoftmaxWorkload", 1, 1); |
| 34 | |
| 35 | arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 36 | arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 37 | |
| 38 | unsigned int aclAxis = ComputeSoftmaxAclAxis<unsigned int>(m_Data.m_Parameters, info.m_InputTensorInfos[0]); |
| 39 | m_SoftmaxLayer.configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); |
| 40 | } |
| 41 | |
| 42 | void ClSoftmaxWorkload::Execute() const |
| 43 | { |
| 44 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxWorkload_Execute"); |
| 45 | RunClFunction(m_SoftmaxLayer, CHECK_LOCATION()); |
| 46 | } |
| 47 | |
| 48 | } // namespace armnn |