Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonLogSoftmaxWorkload.hpp" |
| 7 | #include "NeonWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <armnn/utility/PolymorphicDowncast.hpp> |
| 10 | |
| 11 | #include <aclCommon/ArmComputeUtils.hpp> |
| 12 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 13 | |
| 14 | #include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> |
| 15 | |
| 16 | namespace armnn |
| 17 | { |
| 18 | |
| 19 | arm_compute::Status NeonLogSoftmaxWorkloadValidate(const TensorInfo& input, |
| 20 | const TensorInfo& output, |
| 21 | const LogSoftmaxDescriptor& descriptor) |
| 22 | { |
| 23 | const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 24 | const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 25 | |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 26 | int aclAxis = ComputeAclAxis(descriptor.m_Axis, input); |
Teresa Charlin | 9cf7f88 | 2020-08-07 16:00:38 +0100 | [diff] [blame] | 27 | return arm_compute::NELogSoftmaxLayer::validate(&aclInputInfo, |
| 28 | &aclOutputInfo, |
| 29 | descriptor.m_Beta, |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 30 | aclAxis); |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | NeonLogSoftmaxWorkload::NeonLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor& descriptor, |
| 34 | const WorkloadInfo& info, |
| 35 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
Teresa Charlin | 588cbdf | 2022-01-19 15:55:37 +0000 | [diff] [blame] | 36 | : NeonBaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info) |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 37 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 38 | // Report Profiling Details |
| 39 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonLogSoftmaxWorkload_Construct", |
| 40 | descriptor.m_Parameters, |
| 41 | info, |
| 42 | this->GetGuid()); |
| 43 | |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 44 | m_Data.ValidateInputsOutputs("NeonLogSoftmaxWorkload", 1, 1); |
| 45 | |
| 46 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 47 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 48 | |
| 49 | auto layer = std::make_unique<arm_compute::NELogSoftmaxLayer>(memoryManager); |
Teresa Charlin | e386676 | 2020-08-28 15:13:05 +0100 | [diff] [blame] | 50 | int aclAxis = ComputeAclAxis(m_Data.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
| 51 | layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 52 | m_LogSoftmaxLayer.reset(layer.release()); |
| 53 | } |
| 54 | |
| 55 | void NeonLogSoftmaxWorkload::Execute() const |
| 56 | { |
Keith Davis | 2d0679f | 2021-08-05 11:35:00 +0100 | [diff] [blame] | 57 | ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonLogSoftmaxWorkload_Execute", this->GetGuid()); |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 58 | m_LogSoftmaxLayer->run(); |
| 59 | } |
| 60 | |
| 61 | } //namespace armnn |
| 62 | |