Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "NeonResizeWorkload.hpp" |
| 7 | |
| 8 | #include "NeonWorkloadUtils.hpp" |
| 9 | |
| 10 | #include <aclCommon/ArmComputeUtils.hpp> |
| 11 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 12 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 13 | #include <neon/NeonTensorHandle.hpp> |
| 14 | |
| 15 | using namespace armnn::armcomputetensorutils; |
| 16 | |
| 17 | namespace armnn |
| 18 | { |
| 19 | |
| 20 | arm_compute::Status NeonResizeWorkloadValidate(const TensorInfo& input, |
| 21 | const TensorInfo& output, |
| 22 | const ResizeDescriptor& descriptor) |
| 23 | { |
| 24 | arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input); |
| 25 | arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 26 | |
| 27 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout); |
| 28 | aclInputInfo.set_data_layout(aclDataLayout); |
| 29 | aclOutputInfo.set_data_layout(aclDataLayout); |
| 30 | |
| 31 | arm_compute::InterpolationPolicy aclInterpolationPolicy = |
| 32 | ConvertResizeMethodToAclInterpolationPolicy(descriptor.m_Method); |
| 33 | |
| 34 | return arm_compute::NEScale::validate(&aclInputInfo, |
| 35 | &aclOutputInfo, |
| 36 | aclInterpolationPolicy, |
| 37 | arm_compute::BorderMode::REPLICATE, |
| 38 | arm_compute::PixelValue(0.f), |
| 39 | arm_compute::SamplingPolicy::TOP_LEFT); |
| 40 | } |
| 41 | |
| 42 | NeonResizeWorkload::NeonResizeWorkload(const ResizeQueueDescriptor& descriptor, |
| 43 | const WorkloadInfo& info) |
| 44 | : BaseWorkload<ResizeQueueDescriptor>(descriptor, info) |
| 45 | { |
| 46 | m_Data.ValidateInputsOutputs("NeonResizeWorkload", 1, 1); |
| 47 | |
| 48 | arm_compute::ITensor& input = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 49 | arm_compute::ITensor& output = boost::polymorphic_downcast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 50 | |
| 51 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 52 | input.info()->set_data_layout(aclDataLayout); |
| 53 | output.info()->set_data_layout(aclDataLayout); |
| 54 | |
| 55 | arm_compute::InterpolationPolicy aclInterpolationPolicy = |
| 56 | ConvertResizeMethodToAclInterpolationPolicy(descriptor.m_Parameters.m_Method); |
| 57 | |
| 58 | m_ResizeLayer.configure(&input, |
| 59 | &output, |
| 60 | aclInterpolationPolicy, |
| 61 | arm_compute::BorderMode::REPLICATE, |
| 62 | arm_compute::PixelValue(0.f), |
| 63 | arm_compute::SamplingPolicy::TOP_LEFT); |
| 64 | }; |
| 65 | |
| 66 | void NeonResizeWorkload::Execute() const |
| 67 | { |
| 68 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonResizeWorkload_Execute"); |
| 69 | m_ResizeLayer.run(); |
| 70 | } |
| 71 | |
| 72 | } //namespace armnn |