telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | |
| 6 | #include "ClSoftmaxUint8Workload.hpp" |
| 7 | #include "backends/ClTensorHandle.hpp" |
| 8 | #include "backends/CpuTensorHandle.hpp" |
| 9 | |
| 10 | namespace armnn |
| 11 | { |
| 12 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 13 | ClSoftmaxUint8Workload::ClSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, const WorkloadInfo& info, |
| 14 | std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | : Uint8Workload<SoftmaxQueueDescriptor>(descriptor, info) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 16 | , m_SoftmaxLayer(memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | { |
| 18 | m_Data.ValidateInputsOutputs("ClSoftmaxUint8Workload", 1, 1); |
| 19 | |
| 20 | arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 21 | arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 22 | |
| 23 | const auto outputQuantization = output.info()->quantization_info(); |
| 24 | |
| 25 | if ((outputQuantization.scale != (1.0f / 256.0f)) || (outputQuantization.offset != 0)) |
| 26 | { |
| 27 | throw InvalidArgumentException( |
| 28 | "Invalid quantization for output. Only scale = 1.0f / 256.0f and offset = 0 supported"); |
| 29 | } |
| 30 | |
| 31 | m_SoftmaxLayer.configure(&input, &output, descriptor.m_Parameters.m_Beta); |
| 32 | } |
| 33 | |
| 34 | void ClSoftmaxUint8Workload::Execute() const |
| 35 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame^] | 36 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxUint8Workload_Execute"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | |
| 38 | m_SoftmaxLayer.run(); |
| 39 | } |
| 40 | |
| 41 | } //namespace armnn |