diff options
Diffstat (limited to 'src/backends/neon/workloads')
10 files changed, 92 insertions, 206 deletions
diff --git a/src/backends/neon/workloads/CMakeLists.txt b/src/backends/neon/workloads/CMakeLists.txt index 0c02b5cf22..c5548bf28f 100644 --- a/src/backends/neon/workloads/CMakeLists.txt +++ b/src/backends/neon/workloads/CMakeLists.txt @@ -86,12 +86,8 @@ list(APPEND armnnNeonBackendWorkloads_sources NeonRsqrtWorkload.hpp NeonSliceWorkload.cpp NeonSliceWorkload.hpp - NeonSoftmaxBaseWorkload.cpp - NeonSoftmaxBaseWorkload.hpp - NeonSoftmaxFloatWorkload.cpp - NeonSoftmaxFloatWorkload.hpp - NeonSoftmaxUint8Workload.cpp - NeonSoftmaxUint8Workload.hpp + NeonSoftmaxWorkload.cpp + NeonSoftmaxWorkload.hpp NeonSpaceToBatchNdWorkload.cpp NeonSpaceToBatchNdWorkload.hpp NeonSpaceToDepthWorkload.cpp diff --git a/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.cpp b/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.cpp deleted file mode 100644 index 41ebfb9fd3..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "NeonSoftmaxBaseWorkload.hpp" - -#include <aclCommon/ArmComputeTensorUtils.hpp> -#include <aclCommon/ArmComputeUtils.hpp> - -#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> - -namespace armnn -{ - -arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo& input, - const TensorInfo& output, - const SoftmaxDescriptor& descriptor) -{ - const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); - const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); - - unsigned int aclAxis = ComputeSoftmaxAclAxis(descriptor, input); - return arm_compute::NESoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); -} - -} //namespace armnn - diff --git a/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.hpp b/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.hpp deleted file mode 100644 index 6eecb9787d..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxBaseWorkload.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include <armnn/Descriptors.hpp> -#include <arm_compute/core/Error.h> - -namespace armnn -{ - -arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo& input, - const TensorInfo& output, - const SoftmaxDescriptor& descriptor); - -} //namespace armnn diff --git a/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.cpp b/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.cpp deleted file mode 100644 index a4690a7985..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "NeonSoftmaxFloatWorkload.hpp" - -#include "NeonWorkloadUtils.hpp" - -#include <aclCommon/ArmComputeUtils.hpp> -#include <armnn/utility/PolymorphicDowncast.hpp> - -#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> - -namespace armnn -{ - -NeonSoftmaxFloatWorkload::NeonSoftmaxFloatWorkload(const SoftmaxQueueDescriptor& descriptor, - const WorkloadInfo& info, std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) - : FloatWorkload<SoftmaxQueueDescriptor>(descriptor, info) -{ - m_Data.ValidateInputsOutputs("NeonSoftmaxFloatWorkload", 1, 1); - - // The ArmCompute softmax layer uses 2D input/output tensors, so flatten the first three dimensions. - 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::NESoftmaxLayer>(memoryManager); - unsigned int aclAxis = ComputeSoftmaxAclAxis(m_Data.m_Parameters, info.m_InputTensorInfos[0]); - layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); - m_SoftmaxLayer.reset(layer.release()); -} - -void NeonSoftmaxFloatWorkload::Execute() const -{ - ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxFloatWorkload_Execute"); - m_SoftmaxLayer->run(); -} - -} //namespace armnn - diff --git a/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.hpp b/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.hpp deleted file mode 100644 index 77f2cc3d01..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxFloatWorkload.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include <backendsCommon/Workload.hpp> - -#include <arm_compute/runtime/IFunction.h> -#include <arm_compute/runtime/MemoryManagerOnDemand.h> - -#include <memory> - -namespace armnn -{ - -class NeonSoftmaxFloatWorkload : public FloatWorkload<SoftmaxQueueDescriptor> -{ -public: - NeonSoftmaxFloatWorkload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, - std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager); - virtual void Execute() const override; - -private: - std::unique_ptr<arm_compute::IFunction> m_SoftmaxLayer; -}; - -} //namespace armnn - diff --git a/src/backends/neon/workloads/NeonSoftmaxUint8Workload.cpp b/src/backends/neon/workloads/NeonSoftmaxUint8Workload.cpp deleted file mode 100644 index 05d93b963c..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxUint8Workload.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "NeonSoftmaxUint8Workload.hpp" -#include "NeonWorkloadUtils.hpp" - -#include <aclCommon/ArmComputeUtils.hpp> -#include <armnn/utility/PolymorphicDowncast.hpp> - -#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> - -namespace armnn -{ - -NeonSoftmaxUint8Workload::NeonSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, - const WorkloadInfo& info, - std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) - : Uint8Workload<SoftmaxQueueDescriptor>(descriptor, info) -{ - m_Data.ValidateInputsOutputs("NeonSoftmaxUint8Workload", 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(); - - const auto outputQuantization = output.info()->quantization_info(); - - if ((!outputQuantization.scale().empty() && outputQuantization.scale()[0] != (1.0f / 256.0f)) || - (!outputQuantization.offset().empty() && outputQuantization.offset()[0] != 0) || - outputQuantization.scale().empty() || outputQuantization.offset().empty()) - { - throw InvalidArgumentException( - "Invalid quantization for output. Only scale = 1.0f / 256.0f and offset = 0 supported"); - } - - auto layer = std::make_unique<arm_compute::NESoftmaxLayer>(memoryManager); - unsigned int aclAxis = ComputeSoftmaxAclAxis(m_Data.m_Parameters, info.m_InputTensorInfos[0]); - layer->configure(&input, &output, descriptor.m_Parameters.m_Beta, aclAxis); - m_SoftmaxLayer.reset(layer.release()); -} - -void NeonSoftmaxUint8Workload::Execute() const -{ - ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxUint8Workload_Execute"); - - m_SoftmaxLayer->run(); -} - -} //namespace armnn - diff --git a/src/backends/neon/workloads/NeonSoftmaxUint8Workload.hpp b/src/backends/neon/workloads/NeonSoftmaxUint8Workload.hpp deleted file mode 100644 index c5692084c9..0000000000 --- a/src/backends/neon/workloads/NeonSoftmaxUint8Workload.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include <backendsCommon/Workload.hpp> - -#include <arm_compute/runtime/IFunction.h> -#include <arm_compute/runtime/MemoryManagerOnDemand.h> - -#include <memory> - -namespace armnn -{ - -class NeonSoftmaxUint8Workload : public Uint8Workload<SoftmaxQueueDescriptor> -{ -public: - NeonSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, - std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager); - virtual void Execute() const override; - -private: - std::unique_ptr<arm_compute::IFunction> m_SoftmaxLayer; -}; - -} //namespace armnn - diff --git a/src/backends/neon/workloads/NeonSoftmaxWorkload.cpp b/src/backends/neon/workloads/NeonSoftmaxWorkload.cpp new file mode 100644 index 0000000000..149804bdd6 --- /dev/null +++ b/src/backends/neon/workloads/NeonSoftmaxWorkload.cpp @@ -0,0 +1,53 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "NeonSoftmaxWorkload.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 NeonSoftmaxWorkloadValidate(const TensorInfo& input, + const TensorInfo& output, + const SoftmaxDescriptor& descriptor) +{ + const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input); + const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output); + + unsigned int aclAxis = ComputeSoftmaxAclAxis(descriptor, input); + return arm_compute::NESoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis); +} + +NeonSoftmaxWorkload::NeonSoftmaxWorkload(const SoftmaxQueueDescriptor& descriptor, + const WorkloadInfo& info, std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) + : BaseWorkload<SoftmaxQueueDescriptor>(descriptor, info) +{ + m_Data.ValidateInputsOutputs("NeonSoftmaxWorkload", 1, 1); + + // The ArmCompute softmax layer uses 2D input/output tensors, so flatten the first three dimensions. + 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::NESoftmaxLayer>(memoryManager); + unsigned int aclAxis = ComputeSoftmaxAclAxis(m_Data.m_Parameters, info.m_InputTensorInfos[0]); + layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis); + m_SoftmaxLayer.reset(layer.release()); +} + +void NeonSoftmaxWorkload::Execute() const +{ + ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxWorkload_Execute"); + m_SoftmaxLayer->run(); +} + +} //namespace armnn + diff --git a/src/backends/neon/workloads/NeonSoftmaxWorkload.hpp b/src/backends/neon/workloads/NeonSoftmaxWorkload.hpp new file mode 100644 index 0000000000..26081e10fb --- /dev/null +++ b/src/backends/neon/workloads/NeonSoftmaxWorkload.hpp @@ -0,0 +1,36 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <armnn/Descriptors.hpp> +#include <backendsCommon/Workload.hpp> + +#include <arm_compute/core/Error.h> +#include <arm_compute/runtime/IFunction.h> +#include <arm_compute/runtime/MemoryManagerOnDemand.h> + +#include <memory> + +namespace armnn +{ + +arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo& input, + const TensorInfo& output, + const SoftmaxDescriptor& descriptor); + +class NeonSoftmaxWorkload : public BaseWorkload<SoftmaxQueueDescriptor> +{ +public: + NeonSoftmaxWorkload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, + std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager); + virtual void Execute() const override; + +private: + std::unique_ptr<arm_compute::IFunction> m_SoftmaxLayer; +}; + +} //namespace armnn + diff --git a/src/backends/neon/workloads/NeonWorkloads.hpp b/src/backends/neon/workloads/NeonWorkloads.hpp index 4117a3dd8c..9da698fc8c 100644 --- a/src/backends/neon/workloads/NeonWorkloads.hpp +++ b/src/backends/neon/workloads/NeonWorkloads.hpp @@ -45,8 +45,7 @@ #include "NeonResizeWorkload.hpp" #include "NeonRsqrtWorkload.hpp" #include "NeonSliceWorkload.hpp" -#include "NeonSoftmaxFloatWorkload.hpp" -#include "NeonSoftmaxUint8Workload.hpp" +#include "NeonSoftmaxWorkload.hpp" #include "NeonSpaceToBatchNdWorkload.hpp" #include "NeonSpaceToDepthWorkload.hpp" #include "NeonSplitterWorkload.hpp" |