ArmNN
 25.11
Loading...
Searching...
No Matches
NeonSoftmaxWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2020-2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
8
10
13
14#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h>
15
16namespace armnn
17{
18
19arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo& input,
20 const TensorInfo& output,
21 const SoftmaxDescriptor& descriptor)
22{
23 const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
24 const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
25
26 int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
27 return arm_compute::NESoftmaxLayer::validate(&aclInputInfo,
28 &aclOutputInfo,
29 descriptor.m_Beta,
30 aclAxis);
31}
32
34 const WorkloadInfo& info, std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
36{
37 // Report Profiling Details
38 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonSoftmaxWorkload_Construct",
39 descriptor.m_Parameters,
40 info,
41 this->GetGuid());
42
43 m_Data.ValidateInputsOutputs("NeonSoftmaxWorkload", 1, 1);
44
45 // The ArmCompute softmax layer uses 2D input/output tensors, so flatten the first three dimensions.
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::NESoftmaxLayer>(memoryManager);
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);
52 m_SoftmaxLayer.reset(layer.release());
53}
54
56{
57 ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonSoftmaxWorkload_Execute");
58 m_SoftmaxLayer->run();
59}
60
61} //namespace armnn
62
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
NeonBaseWorkload(const SoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info)
NeonSoftmaxWorkload(const SoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
virtual void Execute() const override
Copyright (c) 2021 ARM Limited and Contributors.
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank,...
arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
DestType PolymorphicDowncast(SourceType *value)
Polymorphic downcast for build in pointers only.
A SoftmaxDescriptor for the SoftmaxLayer.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
float m_Beta
Exponentiation value.
Contains information about TensorInfos of a layer.