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> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 12 | #include <armnn/utility/PolymorphicDowncast.hpp> |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 13 | #include <backendsCommon/CpuTensorHandle.hpp> |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 14 | |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 15 | #include <neon/NeonTensorHandle.hpp> |
| 16 | |
| 17 | using namespace armnn::armcomputetensorutils; |
| 18 | |
| 19 | namespace armnn |
| 20 | { |
| 21 | |
| 22 | arm_compute::Status NeonResizeWorkloadValidate(const TensorInfo& input, |
| 23 | const TensorInfo& output, |
| 24 | const ResizeDescriptor& descriptor) |
| 25 | { |
| 26 | arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input); |
| 27 | arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output); |
| 28 | |
| 29 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(descriptor.m_DataLayout); |
| 30 | aclInputInfo.set_data_layout(aclDataLayout); |
| 31 | aclOutputInfo.set_data_layout(aclDataLayout); |
| 32 | |
| 33 | arm_compute::InterpolationPolicy aclInterpolationPolicy = |
| 34 | ConvertResizeMethodToAclInterpolationPolicy(descriptor.m_Method); |
| 35 | |
| 36 | return arm_compute::NEScale::validate(&aclInputInfo, |
| 37 | &aclOutputInfo, |
| 38 | aclInterpolationPolicy, |
| 39 | arm_compute::BorderMode::REPLICATE, |
| 40 | arm_compute::PixelValue(0.f), |
| 41 | arm_compute::SamplingPolicy::TOP_LEFT); |
| 42 | } |
| 43 | |
| 44 | NeonResizeWorkload::NeonResizeWorkload(const ResizeQueueDescriptor& descriptor, |
| 45 | const WorkloadInfo& info) |
| 46 | : BaseWorkload<ResizeQueueDescriptor>(descriptor, info) |
| 47 | { |
| 48 | m_Data.ValidateInputsOutputs("NeonResizeWorkload", 1, 1); |
| 49 | |
Jan Eilers | bb446e5 | 2020-04-02 13:56:54 +0100 | [diff] [blame] | 50 | arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 51 | arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 52 | |
| 53 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 54 | input.info()->set_data_layout(aclDataLayout); |
| 55 | output.info()->set_data_layout(aclDataLayout); |
| 56 | |
| 57 | arm_compute::InterpolationPolicy aclInterpolationPolicy = |
| 58 | ConvertResizeMethodToAclInterpolationPolicy(descriptor.m_Parameters.m_Method); |
| 59 | |
| 60 | m_ResizeLayer.configure(&input, |
| 61 | &output, |
| 62 | aclInterpolationPolicy, |
| 63 | arm_compute::BorderMode::REPLICATE, |
| 64 | arm_compute::PixelValue(0.f), |
Sang-Hoon Park | 820eb14 | 2020-01-08 10:25:24 +0000 | [diff] [blame] | 65 | arm_compute::SamplingPolicy::TOP_LEFT, |
| 66 | true, |
| 67 | descriptor.m_Parameters.m_BilinearAlignCorners); |
Ellen Norris-Thompson | 37e6868 | 2019-07-15 14:23:30 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | void NeonResizeWorkload::Execute() const |
| 71 | { |
| 72 | ARMNN_SCOPED_PROFILING_EVENT_NEON("NeonResizeWorkload_Execute"); |
| 73 | m_ResizeLayer.run(); |
| 74 | } |
| 75 | |
| 76 | } //namespace armnn |