ArmNN
 21.02
NeonLogSoftmaxWorkload.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 LogSoftmaxDescriptor& 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::NELogSoftmaxLayer::validate(&aclInputInfo,
28  &aclOutputInfo,
29  descriptor.m_Beta,
30  aclAxis);
31 }
32 
34  const WorkloadInfo& info,
35  std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
36  : BaseWorkload<LogSoftmaxQueueDescriptor>(descriptor, info)
37 {
38  m_Data.ValidateInputsOutputs("NeonLogSoftmaxWorkload", 1, 1);
39 
40  arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
41  arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
42 
43  auto layer = std::make_unique<arm_compute::NELogSoftmaxLayer>(memoryManager);
45  layer->configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis);
46  m_LogSoftmaxLayer.reset(layer.release());
47 }
48 
50 {
51  ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonLogSoftmaxWorkload_Execute");
52  m_LogSoftmaxLayer->run();
53 }
54 
55 } //namespace armnn
56 
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...
NeonLogSoftmaxWorkload(const LogSoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
arm_compute::Status NeonLogSoftmaxWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const LogSoftmaxDescriptor &descriptor)
const LogSoftmaxQueueDescriptor m_Data
Definition: Workload.hpp:46
#define ARMNN_SCOPED_PROFILING_EVENT_NEON(name)
float m_Beta
Exponentiation value.
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:26
virtual void Execute() const override
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs
A SoftmaxDescriptor for the SoftmaxLayer.