Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClLogSoftmaxWorkload.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 ClLogSoftmaxWorkloadValidate(const TensorInfo& input, |
| 18 | const TensorInfo& output, |
| 19 | const LogSoftmaxDescriptor& descriptor) |
| 20 | { |
| 21 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 22 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 23 | |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 24 | int aclAxis = ComputeAclAxis(descriptor.m_Axis, input); |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 25 | return arm_compute::CLLogSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); |
| 26 | } |
| 27 | |
| 28 | ClLogSoftmaxWorkload::ClLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, |
| 29 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
| 30 | : BaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info) |
| 31 | , m_LogSoftmaxLayer(memoryManager) |
| 32 | { |
| 33 | m_Data.ValidateInputsOutputs("ClLogSoftmaxWorkload", 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 | |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 38 | int aclAxis = ComputeAclAxis(m_Data.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 39 | m_LogSoftmaxLayer.configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); |
| 40 | } |
| 41 | |
| 42 | void ClLogSoftmaxWorkload::Execute() const |
| 43 | { |
| 44 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClLogSoftmaxWorkload_Execute"); |
| 45 | RunClFunction(m_LogSoftmaxLayer, CHECK_LOCATION()); |
| 46 | } |
| 47 | |
| 48 | } // namespace armnn |