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 "ClSoftmaxUint8Workload.hpp" |
Narumol Prangnawarat | 65d3096 | 2019-03-14 11:55:03 +0000 | [diff] [blame] | 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <aclCommon/ArmComputeUtils.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <cl/ClTensorHandle.hpp> |
| 11 | #include <backendsCommon/CpuTensorHandle.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 16 | ClSoftmaxUint8Workload::ClSoftmaxUint8Workload(const SoftmaxQueueDescriptor& descriptor, 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) |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 19 | , m_SoftmaxLayer(memoryManager) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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 | |
Ferran Balaguer | b2b5a26 | 2019-06-24 12:43:38 +0100 | [diff] [blame^] | 28 | if (((!outputQuantization.scale.empty()) && (outputQuantization.scale[0] != (1.0f / 256.0f))) || |
| 29 | ((!outputQuantization.offset.empty()) && (outputQuantization.offset[0] != 0)) || |
| 30 | (outputQuantization.scale.empty()) || |
| 31 | (outputQuantization.offset.empty())) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 32 | { |
| 33 | throw InvalidArgumentException( |
| 34 | "Invalid quantization for output. Only scale = 1.0f / 256.0f and offset = 0 supported"); |
| 35 | } |
| 36 | |
Narumol Prangnawarat | 65d3096 | 2019-03-14 11:55:03 +0000 | [diff] [blame] | 37 | unsigned int aclAxis = ComputeSoftmaxAclAxis(info.m_InputTensorInfos[0]); |
| 38 | m_SoftmaxLayer.configure(&input, &output, descriptor.m_Parameters.m_Beta, aclAxis); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void ClSoftmaxUint8Workload::Execute() const |
| 42 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 43 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClSoftmaxUint8Workload_Execute"); |
Aron Virginas-Tar | a8e06ed | 2018-10-19 16:46:15 +0100 | [diff] [blame] | 44 | RunClFunction(m_SoftmaxLayer, CHECK_LOCATION()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } //namespace armnn |