Nikhil Raj | 9b46148 | 2019-07-03 15:58:31 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonPreluWorkload.hpp" |
| 7 | #include "NeonWorkloadUtils.hpp" |
| 8 | #include <aclCommon/ArmComputeUtils.hpp> |
| 9 | |
| 10 | #include <arm_compute/runtime/NEON/functions/NEPReluLayer.h> |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | arm_compute::Status NeonPreluWorkloadValidate(const TensorInfo& input, |
| 16 | const TensorInfo& alpha, |
| 17 | const TensorInfo& output) |
| 18 | { |
| 19 | const arm_compute::TensorInfo aclInput = armcomputetensorutils::BuildArmComputeTensorInfo(input); |
| 20 | const arm_compute::TensorInfo aclAlpha = armcomputetensorutils::BuildArmComputeTensorInfo(alpha); |
| 21 | const arm_compute::TensorInfo aclOutput = armcomputetensorutils::BuildArmComputeTensorInfo(output); |
| 22 | |
| 23 | return arm_compute::NEPReluLayer::validate(&aclInput, |
| 24 | &aclAlpha, |
| 25 | &aclOutput); |
| 26 | } |
| 27 | |
| 28 | NeonPreluWorkload::NeonPreluWorkload(const PreluQueueDescriptor& descriptor, |
| 29 | const WorkloadInfo& info) |
| 30 | : BaseWorkload<PreluQueueDescriptor>(descriptor, info) |
| 31 | { |
| 32 | m_Data.ValidateInputsOutputs("NeonPreluWorkload", 1, 1); |
| 33 | |
| 34 | arm_compute::ITensor& input = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 35 | arm_compute::ITensor& alpha = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[1])->GetTensor(); |
| 36 | arm_compute::ITensor& output = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 37 | |
| 38 | auto layer = std::make_unique<arm_compute::NEPReluLayer>(); |
| 39 | layer->configure(&input, &alpha, &output); |
| 40 | |
| 41 | m_PreluLayer.reset(layer.release()); |
| 42 | } |
| 43 | |
| 44 | void NeonPreluWorkload::Execute() const |
| 45 | { |
| 46 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonPreluWorkload_Execute"); |
| 47 | m_PreluLayer->run(); |
| 48 | } |
| 49 | |
| 50 | } //namespace armnn |