ArmNN
 22.05.01
NeonSoftmaxWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include "NeonWorkloadUtils.hpp"
8 
10 
13 
14 #include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h>
15 
16 namespace armnn
17 {
18 
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)
35  : NeonBaseWorkload<SoftmaxQueueDescriptor>(descriptor, info)
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);
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_GUID("NeonSoftmaxWorkload_Execute", this->GetGuid());
58  m_SoftmaxLayer->run();
59 }
60 
61 } //namespace armnn
62 
virtual void Execute() const override
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...
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...
float m_Beta
Exponentiation value.
arm::pipe::ProfilingGuid GetGuid() const final
Definition: Workload.hpp:59
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< TensorInfo > m_InputTensorInfos
Status
enumeration
Definition: Types.hpp:42
NeonSoftmaxWorkload(const SoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
std::vector< ITensorHandle * > m_Outputs
arm_compute::Status NeonSoftmaxWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
#define ARMNN_REPORT_PROFILING_WORKLOAD_DESC(name, desc, infos, guid)
Definition: Profiling.hpp:227
Contains information about TensorInfos of a layer.
std::vector< ITensorHandle * > m_Inputs
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID(name, guid)
A SoftmaxDescriptor for the SoftmaxLayer.