blob: cbaac9d2264762bc46f9a7ceb5b2c1598ca3126a [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
arovir019e53a352018-08-31 15:26:35 +01006#include "ClActivationFloatWorkload.hpp"
David Beckac42efd2018-09-26 17:41:13 +01007#include <backends/cl/ClTensorHandle.hpp>
David Beck711fa312018-09-24 10:46:38 +01008#include <backends/aclCommon/ArmComputeUtils.hpp>
telsoa014fcda012018-03-09 14:13:49 +00009
Matthew Bentham14e46692018-09-20 15:35:30 +010010#include "ClWorkloadUtils.hpp"
11
telsoa014fcda012018-03-09 14:13:49 +000012namespace armnn
13{
telsoa01c577f2c2018-08-31 09:22:23 +010014arm_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}
telsoa014fcda012018-03-09 14:13:49 +000035
arovir019e53a352018-08-31 15:26:35 +010036ClActivationFloatWorkload::ClActivationFloatWorkload(const ActivationQueueDescriptor& descriptor,
telsoa014fcda012018-03-09 14:13:49 +000037 const WorkloadInfo& info)
telsoa01c577f2c2018-08-31 09:22:23 +010038 : FloatWorkload<ActivationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000039{
arovir019e53a352018-08-31 15:26:35 +010040 m_Data.ValidateInputsOutputs("ClActivationFloatWorkload", 1, 1);
telsoa014fcda012018-03-09 14:13:49 +000041
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
arovir019e53a352018-08-31 15:26:35 +010050void ClActivationFloatWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000051{
arovir019e53a352018-08-31 15:26:35 +010052 ARMNN_SCOPED_PROFILING_EVENT_CL("ClActivationFloatWorkload_Execute");
telsoa014fcda012018-03-09 14:13:49 +000053 m_ActivationLayer.run();
54}
55
Matthew Bentham14e46692018-09-20 15:35:30 +010056} //namespace armnn