blob: f072549cbcd7820def083862375d3a6c93107acb [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// See LICENSE file in the project root for full license information.
4//
5
6#include "ClActivationFloat32Workload.hpp"
7#include "backends/ClTensorHandle.hpp"
8#include "backends/ArmComputeUtils.hpp"
9
10namespace armnn
11{
telsoa01c577f2c2018-08-31 09:22:23 +010012arm_compute::Status ClActivationWorkloadValidate(const TensorInfo& input,
13 const TensorInfo& output,
14 const ActivationDescriptor& descriptor)
15{
16 const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
17 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
18
19 const arm_compute::ActivationLayerInfo activationLayerInfo =
20 ConvertActivationDescriptorToAclActivationLayerInfo(descriptor);
21
22 if (input.GetDataType() == DataType::QuantisedAsymm8 &&
23 activationLayerInfo.activation() == arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC)
24 {
25 return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR,
26 "CL: Logistic Activations unsupported with QAsymm8 data type."};
27 }
28
29 return arm_compute::CLActivationLayer::validate(&aclInput,
30 &aclOutput,
31 activationLayerInfo);
32}
telsoa014fcda012018-03-09 14:13:49 +000033
34ClActivationFloat32Workload::ClActivationFloat32Workload(const ActivationQueueDescriptor& descriptor,
35 const WorkloadInfo& info)
telsoa01c577f2c2018-08-31 09:22:23 +010036 : FloatWorkload<ActivationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000037{
38 m_Data.ValidateInputsOutputs("ClActivationFloat32Workload", 1, 1);
39
40 const arm_compute::ActivationLayerInfo activationLayerInfo =
41 ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters);
42
43 arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
44 arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
45 m_ActivationLayer.configure(&input, &output, activationLayerInfo);
46}
47
48void ClActivationFloat32Workload::Execute() const
49{
telsoa01c577f2c2018-08-31 09:22:23 +010050 ARMNN_SCOPED_PROFILING_EVENT_CL("ClActivationFloat32Workload_Execute");
telsoa014fcda012018-03-09 14:13:49 +000051 m_ActivationLayer.run();
52}
53
54} //namespace armnn