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 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 6 | #include "ClActivationFloatWorkload.hpp" |
David Beck | ac42efd | 2018-09-26 17:41:13 +0100 | [diff] [blame] | 7 | #include <backends/cl/ClTensorHandle.hpp> |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame] | 8 | #include <backends/aclCommon/ArmComputeUtils.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 9 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 10 | #include "ClWorkloadUtils.hpp" |
| 11 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 12 | namespace armnn |
| 13 | { |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 14 | arm_compute::Status ClActivationWorkloadValidate(const TensorInfo& input, |
| 15 | const TensorInfo& output, |
| 16 | const ActivationDescriptor& descriptor) |
| 17 | { |
| 18 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 19 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 20 | |
| 21 | const arm_compute::ActivationLayerInfo activationLayerInfo = |
| 22 | ConvertActivationDescriptorToAclActivationLayerInfo(descriptor); |
| 23 | |
| 24 | if (input.GetDataType() == DataType::QuantisedAsymm8 && |
| 25 | activationLayerInfo.activation() == arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC) |
| 26 | { |
| 27 | return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR, |
| 28 | "CL: Logistic Activations unsupported with QAsymm8 data type."}; |
| 29 | } |
| 30 | |
| 31 | return arm_compute::CLActivationLayer::validate(&aclInput, |
| 32 | &aclOutput, |
| 33 | activationLayerInfo); |
| 34 | } |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 35 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 36 | ClActivationFloatWorkload::ClActivationFloatWorkload(const ActivationQueueDescriptor& descriptor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | const WorkloadInfo& info) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 38 | : FloatWorkload<ActivationQueueDescriptor>(descriptor, info) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 40 | m_Data.ValidateInputsOutputs("ClActivationFloatWorkload", 1, 1); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 41 | |
| 42 | const arm_compute::ActivationLayerInfo activationLayerInfo = |
| 43 | ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters); |
| 44 | |
| 45 | arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 46 | arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 47 | m_ActivationLayer.configure(&input, &output, activationLayerInfo); |
| 48 | } |
| 49 | |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 50 | void ClActivationFloatWorkload::Execute() const |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | { |
arovir01 | 9e53a35 | 2018-08-31 15:26:35 +0100 | [diff] [blame] | 52 | ARMNN_SCOPED_PROFILING_EVENT_CL("ClActivationFloatWorkload_Execute"); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 53 | m_ActivationLayer.run(); |
| 54 | } |
| 55 | |
Matthew Bentham | 14e4669 | 2018-09-20 15:35:30 +0100 | [diff] [blame] | 56 | } //namespace armnn |