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 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 28 | ClLogSoftmaxWorkload::ClLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor& descriptor, |
| 29 | const WorkloadInfo& info, |
| 30 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager, |
| 31 | const arm_compute::CLCompileContext& clCompileContext) |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 32 | : BaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info) |
| 33 | , m_LogSoftmaxLayer(memoryManager) |
| 34 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 35 | // Report Profiling Details |
| 36 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClLogSoftmaxWorkload_Construct", |
| 37 | descriptor.m_Parameters, |
| 38 | info, |
| 39 | this->GetGuid()); |
| 40 | |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 41 | m_Data.ValidateInputsOutputs("ClLogSoftmaxWorkload", 1, 1); |
| 42 | |
| 43 | arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 44 | arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 45 | |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 46 | int aclAxis = ComputeAclAxis(m_Data.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
Kevin May | 9f6862d | 2021-10-22 15:42:28 +0100 | [diff] [blame] | 47 | |
| 48 | { |
| 49 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClLogSoftmaxWorkload_configure"); |
| 50 | m_LogSoftmaxLayer.configure(clCompileContext, &input, &output, m_Data.m_Parameters.m_Beta, aclAxis); |
| 51 | } |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void ClLogSoftmaxWorkload::Execute() const |
| 55 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 56 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClLogSoftmaxWorkload_Execute", this->GetGuid()); |
Teresa Charlin | 8398edc | 2020-07-20 14:23:02 +0100 | [diff] [blame] | 57 | RunClFunction(m_LogSoftmaxLayer, CHECK_LOCATION()); |
| 58 | } |
| 59 | |
| 60 | } // namespace armnn |