blob: 01b216f70fdf8cda6b354ca08e9a4a3ae833fb89 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
Mike Kelly7cbe7812023-07-25 17:37:33 +01002// Copyright © 2017-2023 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
Nattapat Chaimanowongd4b70592018-10-12 11:21:49 +01006#include "NeonActivationWorkload.hpp"
Matthew Benthamd80a7122019-01-08 17:52:37 +00007#include "NeonWorkloadUtils.hpp"
Jan Eilersbb446e52020-04-02 13:56:54 +01008
Aron Virginas-Tarc9cc8042018-11-01 16:15:57 +00009#include <aclCommon/ArmComputeUtils.hpp>
Jan Eilersbb446e52020-04-02 13:56:54 +010010#include <armnn/utility/PolymorphicDowncast.hpp>
telsoa014fcda012018-03-09 14:13:49 +000011
Matthew Benthamd80a7122019-01-08 17:52:37 +000012#include <arm_compute/runtime/NEON/functions/NEActivationLayer.h>
13
telsoa014fcda012018-03-09 14:13:49 +000014namespace armnn
15{
telsoa01c577f2c2018-08-31 09:22:23 +010016
17arm_compute::Status NeonActivationWorkloadValidate(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
telsoa01c577f2c2018-08-31 09:22:23 +010027 return arm_compute::NEActivationLayer::validate(&aclInput,
28 &aclOutput,
29 activationLayerInfo);
30}
31
Nattapat Chaimanowongd4b70592018-10-12 11:21:49 +010032NeonActivationWorkload::NeonActivationWorkload(const ActivationQueueDescriptor& descriptor,
33 const WorkloadInfo& info)
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000034 : NeonBaseWorkload<ActivationQueueDescriptor>(descriptor, info)
telsoa014fcda012018-03-09 14:13:49 +000035{
Keith Davis2d0679f2021-08-05 11:35:00 +010036 // Report Profiling Details
37 ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonActivationWorkload_Construct",
38 descriptor.m_Parameters,
39 info,
40 this->GetGuid());
41
Nattapat Chaimanowongd4b70592018-10-12 11:21:49 +010042 m_Data.ValidateInputsOutputs("NeonActivationWorkload", 1, 1);
telsoa014fcda012018-03-09 14:13:49 +000043
44 const arm_compute::ActivationLayerInfo activationLayerInfo =
45 ConvertActivationDescriptorToAclActivationLayerInfo(m_Data.m_Parameters);
46
Jan Eilersbb446e52020-04-02 13:56:54 +010047 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
48 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor();
telsoa014fcda012018-03-09 14:13:49 +000049
Matthew Benthamd80a7122019-01-08 17:52:37 +000050 auto layer = std::make_unique<arm_compute::NEActivationLayer>();
51 layer->configure(&input, &output, activationLayerInfo);
52
53 m_ActivationLayer.reset(layer.release());
telsoa014fcda012018-03-09 14:13:49 +000054}
55
Nattapat Chaimanowongd4b70592018-10-12 11:21:49 +010056void NeonActivationWorkload::Execute() const
telsoa014fcda012018-03-09 14:13:49 +000057{
Mike Kelly7cbe7812023-07-25 17:37:33 +010058 ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID("NeonActivationWorkload_Execute");
Matthew Benthamd80a7122019-01-08 17:52:37 +000059 m_ActivationLayer->run();
telsoa014fcda012018-03-09 14:13:49 +000060}
61
62} //namespace armnn