blob: 9b658569c1515ce0f5242795e14565169b403b57 [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
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +01006#include "ClActivationWorkload.hpp"
telsoa014fcda012018-03-09 14:13:49 +00007
Matthew Bentham14e46692018-09-20 15:35:30 +01008#include "ClWorkloadUtils.hpp"
9
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +000010#include <backendsCommon/CpuTensorHandle.hpp>
11#include <cl/ClLayerSupport.hpp>
12#include <cl/ClTensorHandle.hpp>
13#include <aclCommon/ArmComputeUtils.hpp>
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +010014
telsoa014fcda012018-03-09 14:13:49 +000015namespace armnn
16{
telsoa01c577f2c2018-08-31 09:22:23 +010017arm_compute::Status ClActivationWorkloadValidate(const TensorInfo& input,
18 const TensorInfo& output,
19 const ActivationDescriptor& descriptor)
20{
21 const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input);
22 const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output);
23
24 const arm_compute::ActivationLayerInfo activationLayerInfo =
25 ConvertActivationDescriptorToAclActivationLayerInfo(descriptor);
26
27 if (input.GetDataType() == DataType::QuantisedAsymm8 &&
28 activationLayerInfo.activation() == arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC)
29 {
30 return arm_compute::Status{arm_compute::ErrorCode::RUNTIME_ERROR,
31 "CL: Logistic Activations unsupported with QAsymm8 data type."};
32 }
33
34 return arm_compute::CLActivationLayer::validate(&aclInput,
35 &aclOutput,
36 activationLayerInfo);
37}
telsoa014fcda012018-03-09 14:13:49 +000038
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +010039ClActivationWorkload::ClActivationWorkload(const ActivationQueueDescriptor& descriptor,
40 const WorkloadInfo& info)
41 : BaseWorkload<ActivationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000042{
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +010043 m_Data.ValidateInputsOutputs("ClActivationWorkload", 1, 1);
telsoa014fcda012018-03-09 14:13:49 +000044
45 const arm_compute::ActivationLayerInfo activationLayerInfo =
46 ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters);
47
48 arm_compute::ICLTensor& input = static_cast<ClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
49 arm_compute::ICLTensor& output = static_cast<ClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
50 m_ActivationLayer.configure(&input, &output, activationLayerInfo);
51}
52
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +010053void ClActivationWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000054{
Nattapat Chaimanowonge06757e2018-10-11 15:39:18 +010055 ARMNN_SCOPED_PROFILING_EVENT_CL("ClActivationWorkload_Execute");
Aron Virginas-Tara8e06ed2018-10-19 16:46:15 +010056 RunClFunction(m_ActivationLayer, CHECK_LOCATION());
telsoa014fcda012018-03-09 14:13:49 +000057}
58
Matthew Bentham14e46692018-09-20 15:35:30 +010059} //namespace armnn