blob: c386e3837b12a4112202ccf5ee9eb1352b626f55 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "ClSoftmaxUint8Workload.hpp"
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00007#include <cl/ClTensorHandle.hpp>
8#include <backendsCommon/CpuTensorHandle.hpp>
telsoa014fcda012018-03-09 14:13:49 +00009
Matthew Bentham14e46692018-09-20 15:35:30 +010010#include "ClWorkloadUtils.hpp"
11
telsoa014fcda012018-03-09 14:13:49 +000012namespace armnn
13{
14
surmeh013537c2c2018-05-18 16:31:43 +010015ClSoftmaxUint8Workload::ClSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info,
16 std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +000017 : Uint8Workload<SoftmaxQueueDescriptor>(descriptor, info)
surmeh013537c2c2018-05-18 16:31:43 +010018 , m_SoftmaxLayer(memoryManager)
telsoa014fcda012018-03-09 14:13:49 +000019{
20 m_Data.ValidateInputsOutputs("ClSoftmaxUint8Workload", 1, 1);
21
22 arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
23 arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
24
25 const auto outputQuantization = output.info()->quantization_info();
26
27 if ((outputQuantization.scale != (1.0f / 256.0f)) || (outputQuantization.offset != 0))
28 {
29 throw InvalidArgumentException(
30 "Invalid quantization for output. Only scale = 1.0f / 256.0f and offset = 0 supported");
31 }
32
33 m_SoftmaxLayer.configure(&input, &output, descriptor.m_Parameters.m_Beta);
34}
35
36void ClSoftmaxUint8Workload::Execute() const
37{
telsoa01c577f2c2018-08-31 09:22:23 +010038 ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxUint8Workload_Execute");
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010039 RunClFunction(m_SoftmaxLayer, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000040}
41
42} //namespace armnn