blob: f78058907521c33b2ea0cf75c7daf922cc89ceff [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 "NeonSoftmaxUint8Workload.hpp"
7
Matthew Benthamd80a7122019-01-08 17:52:37 +00008#include "NeonWorkloadUtils.hpp"
9
10#include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h>
11
telsoa014fcda012018-03-09 14:13:49 +000012namespace armnn
13{
surmeh013537c2c2018-05-18 16:31:43 +010014
15NeonSoftmaxUint8Workload::NeonSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor,
16 const WorkloadInfo& info,
17 std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager)
telsoa014fcda012018-03-09 14:13:49 +000018 : Uint8Workload<SoftmaxQueueDescriptor>(descriptor, info)
19{
20 m_Data.ValidateInputsOutputs("NeonSoftmaxUint8Workload", 1, 1);
21
22 arm_compute::ITensor& input = boost::polymorphic_downcast<INeonTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
23 arm_compute::ITensor& output = boost::polymorphic_downcast<INeonTensorHandle*>(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
Matthew Benthamd80a7122019-01-08 17:52:37 +000033 auto layer = std::make_unique<arm_compute::NESoftmaxLayer>(memoryManager);
34 layer->configure(&input, &output, descriptor.m_Parameters.m_Beta);
35 m_SoftmaxLayer.reset(layer.release());
telsoa014fcda012018-03-09 14:13:49 +000036}
37
38void NeonSoftmaxUint8Workload::Execute() const
39{
telsoa01c577f2c2018-08-31 09:22:23 +010040 ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxUint8Workload_Execute");
telsoa014fcda012018-03-09 14:13:49 +000041
Matthew Benthamd80a7122019-01-08 17:52:37 +000042 m_SoftmaxLayer->run();
telsoa014fcda012018-03-09 14:13:49 +000043}
surmeh013537c2c2018-05-18 16:31:43 +010044
telsoa014fcda012018-03-09 14:13:49 +000045} //namespace armnn
46