ArmNN
 20.11
ClSoftmaxWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClSoftmaxWorkload.hpp"
7 #include "ClWorkloadUtils.hpp"
8 
11 
12 #include <cl/ClTensorHandle.hpp>
13 
14 namespace armnn
15 {
16 
18  const TensorInfo& output,
19  const SoftmaxDescriptor& descriptor)
20 {
21  const arm_compute::TensorInfo aclInputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22  const arm_compute::TensorInfo aclOutputInfo = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23 
24  int aclAxis = ComputeAclAxis(descriptor.m_Axis, input);
25  return arm_compute::CLSoftmaxLayer::validate(&aclInputInfo, &aclOutputInfo, descriptor.m_Beta, aclAxis);
26 }
27 
29  std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
30  : BaseWorkload<SoftmaxQueueDescriptor>(descriptor, info)
31  , m_SoftmaxLayer(memoryManager)
32 {
33  m_Data.ValidateInputsOutputs("ClSoftmaxWorkload", 1, 1);
34 
35  arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
36  arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
37 
39  m_SoftmaxLayer.configure(&input, &output, m_Data.m_Parameters.m_Beta, aclAxis);
40 }
41 
43 {
44  ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxWorkload_Execute");
45  RunClFunction(m_SoftmaxLayer, CHECK_LOCATION());
46 }
47 
48 } // namespace armnn
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...
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
void Execute() const override
const SoftmaxQueueDescriptor m_Data
Definition: Workload.hpp:46
float m_Beta
Exponentiation value.
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Copyright (c) 2020 ARM Limited.
arm_compute::Status ClSoftmaxWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const SoftmaxDescriptor &descriptor)
std::vector< TensorInfo > m_InputTensorInfos
Status
enumeration
Definition: Types.hpp:26
ClSoftmaxWorkload(const SoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs
A SoftmaxDescriptor for the SoftmaxLayer.