telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "NeonSoftmaxUint8Workload.hpp" |
| 7 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 8 | #include "NeonWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <arm_compute/runtime/NEON/functions/NESoftmaxLayer.h> |
| 11 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | namespace armnn |
| 13 | { |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 14 | |
| 15 | NeonSoftmaxUint8Workload::NeonSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, |
| 16 | const WorkloadInfo& info, |
| 17 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | : 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 Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 33 | 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()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void NeonSoftmaxUint8Workload::Execute() const |
| 39 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 40 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonSoftmaxUint8Workload_Execute"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
Matthew Bentham | d80a712 | 2019-01-08 17:52:37 +0000 | [diff] [blame] | 42 | m_SoftmaxLayer->run(); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 43 | } |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 44 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | } //namespace armnn |
| 46 | |