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 | 7ac3ca6 | 2020-07-28 15:17:12 +0100 | [diff] [blame^] | 26 | int aclAxis = ComputeAclAxis(descriptor.m_Axis, input); |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 27 | return arm_compute::NELogSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); |
| 28 | } |
| 29 | |
| 30 | NeonLogSoftmaxWorkload::NeonLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor& descriptor, |
| 31 | const WorkloadInfo& info, |
| 32 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
| 33 | : BaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info) |
| 34 | { |
| 35 | m_Data.ValidateInputsOutputs("NeonLogSoftmaxWorkload", 1, 1); |
| 36 | |
| 37 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 38 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 39 | |
| 40 | auto layer = std::make_unique<arm_compute::NELogSoftmaxLayer>(memoryManager); |
Teresa Charlin | 7ac3ca6 | 2020-07-28 15:17:12 +0100 | [diff] [blame^] | 41 | int aclAxis = ComputeAclAxis(m_Data.m_Parameters.m_Axis, info.m_InputTensorInfos[0]); |
Keith Davis | 69e653f | 2020-07-02 11:49:26 +0100 | [diff] [blame] | 42 | layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); |
| 43 | m_LogSoftmaxLayer.reset(layer.release()); |
| 44 | } |
| 45 | |
| 46 | void NeonLogSoftmaxWorkload::Execute() const |
| 47 | { |
| 48 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonLogSoftmaxWorkload_Execute"); |
| 49 | m_LogSoftmaxLayer->run(); |
| 50 | } |
| 51 | |
| 52 | } //namespace armnn |
| 53 | |