diff options
author | Keith Davis <keith.davis@arm.com> | 2020-07-02 11:49:26 +0100 |
---|---|---|
committer | Teresa Charlin <teresa.charlinreyes@arm.com> | 2020-07-24 11:16:06 +0100 |
commit | 69e653f9b2a7c8a2ab0cd3556b246a9df21b81d6 (patch) | |
tree | 1866252e0c459ee9f1564ea1d0feceb7f882ad14 /src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp | |
parent | 686f45c6641e87b6bc50c6274d0430c01a8b2bcf (diff) | |
download | armnn-69e653f9b2a7c8a2ab0cd3556b246a9df21b81d6.tar.gz |
IVGCVSW-3897 Add NEON LOG_SOFTMAX Workload
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: I632b5ac7f188853de68e232e81568b3fca238d42
Diffstat (limited to 'src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp')
-rw-r--r-- | src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp b/src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp new file mode 100644 index 0000000000..058756e9af --- /dev/null +++ b/src/backends/neon/workloads/NeonLogSoftmaxWorkload.cpp @@ -0,0 +1,53 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "NeonLogSoftmaxWorkload.hpp" +#include "NeonWorkloadUtils.hpp" + +#include <armnn/utility/PolymorphicDowncast.hpp> + +#include <aclCommon/ArmComputeUtils.hpp> +#include <aclCommon/ArmComputeTensorUtils.hpp> + +#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> + +namespace armnn +{ + +arm_compute::Status NeonLogSoftmaxWorkloadValidate(const TensorInfo& input, + const TensorInfo& output, + const LogSoftmaxDescriptor& descriptor) +{ + const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); + const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); + + int aclAxis = ComputeSoftmaxAclAxis<int>(descriptor, input); + return arm_compute::NELogSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); +} + +NeonLogSoftmaxWorkload::NeonLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor& descriptor, + const WorkloadInfo& info, + std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) + : BaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info) +{ + m_Data.ValidateInputsOutputs("NeonLogSoftmaxWorkload", 1, 1); + + arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); + arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); + + auto layer = std::make_unique<arm_compute::NELogSoftmaxLayer>(memoryManager); + int aclAxis = ComputeSoftmaxAclAxis<int>(m_Data.m_Parameters, info.m_InputTensorInfos[0]); + layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); + m_LogSoftmaxLayer.reset(layer.release()); +} + +void NeonLogSoftmaxWorkload::Execute() const +{ + ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonLogSoftmaxWorkload_Execute"); + m_LogSoftmaxLayer->run(); +} + +} //namespace armnn + |