ArmNN
 20.02
ClSoftmaxUint8Workload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 #include "ClWorkloadUtils.hpp"
8 
10 #include <cl/ClTensorHandle.hpp>
12 
13 namespace armnn
14 {
15 
17  std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
18  : Uint8Workload<SoftmaxQueueDescriptor>(descriptor, info)
19  , m_SoftmaxLayer(memoryManager)
20 {
21  m_Data.ValidateInputsOutputs("ClSoftmaxUint8Workload", 1, 1);
22 
23  arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
24  arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
25 
26  const auto outputQuantization = output.info()->quantization_info();
27 
28  if ((!outputQuantization.scale().empty() && outputQuantization.scale()[0] != (1.0f / 256.0f)) ||
29  (!outputQuantization.offset().empty() && outputQuantization.offset()[0] != 0) ||
30  outputQuantization.scale().empty() || outputQuantization.offset().empty())
31  {
33  "Invalid quantization for output. Only scale = 1.0f / 256.0f and offset = 0 supported");
34  }
35 
36  unsigned int aclAxis = ComputeSoftmaxAclAxis(m_Data.m_Parameters, info.m_InputTensorInfos[0]);
37  m_SoftmaxLayer.configure(&input, &output, descriptor.m_Parameters.m_Beta, aclAxis);
38 }
39 
41 {
42  ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxUint8Workload_Execute");
43  RunClFunction(m_SoftmaxLayer, CHECK_LOCATION());
44 }
45 
46 } //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_CL(name)
void RunClFunction(arm_compute::IFunction &function, const CheckLocation &location)
const QueueDescriptor 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.
ClSoftmaxUint8Workload(const SoftmaxQueueDescriptor &descriptor, const WorkloadInfo &info, std::shared_ptr< arm_compute::MemoryManagerOnDemand > &memoryManager)
std::vector< TensorInfo > m_InputTensorInfos
#define CHECK_LOCATION()
Definition: Exceptions.hpp:192
unsigned int ComputeSoftmaxAclAxis(const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)
std::vector< ITensorHandle * > m_Outputs
Contains information about inputs and outputs to a layer.
std::vector< ITensorHandle * > m_Inputs