Ryan OShea | bab8fa9 | 2022-03-09 10:29:02 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClPooling3dWorkload.hpp" |
| 7 | #include <cl/ClLayerSupport.hpp> |
| 8 | #include <cl/ClTensorHandle.hpp> |
| 9 | #include <aclCommon/ArmComputeUtils.hpp> |
| 10 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 11 | |
| 12 | #include "ClWorkloadUtils.hpp" |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | using namespace armcomputetensorutils; |
| 17 | |
| 18 | arm_compute::Status ClPooling3dWorkloadValidate(const TensorInfo& input, |
| 19 | const TensorInfo& output, |
| 20 | const Pooling3dDescriptor& descriptor) |
| 21 | { |
| 22 | const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout); |
| 23 | const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout); |
| 24 | |
| 25 | arm_compute::Pooling3dLayerInfo layerInfo = BuildArmComputePooling3dLayerInfo(descriptor); |
| 26 | |
| 27 | return arm_compute::CLPooling3dLayer::validate(&aclInputInfo, &aclOutputInfo, layerInfo); |
| 28 | } |
| 29 | |
| 30 | ClPooling3dWorkload::ClPooling3dWorkload( const Pooling3dQueueDescriptor& descriptor, |
| 31 | const WorkloadInfo& info, |
| 32 | const arm_compute::CLCompileContext& clCompileContext) |
| 33 | : ClBaseWorkload<Pooling3dQueueDescriptor>(descriptor, info) |
| 34 | { |
| 35 | // Report Profiling Details |
| 36 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClPooling3dWorkload_Construct", |
| 37 | descriptor.m_Parameters, |
| 38 | info, |
| 39 | this->GetGuid()); |
| 40 | |
| 41 | m_Data.ValidateInputsOutputs("ClPooling3dWorkload", 1, 1); |
| 42 | |
| 43 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 44 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 45 | |
| 46 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 47 | input.info()->set_data_layout(aclDataLayout); |
| 48 | output.info()->set_data_layout(aclDataLayout); |
| 49 | |
| 50 | // flag to use wider accumulators (32 bit instead of 16 for FP16) to improve accuracy |
| 51 | // enable fp_mixed_precision for the the FP16 cases that |
| 52 | // accumulation reaches a limit beyond which there is no more increment of the value |
| 53 | bool fpMixedPrecision = false; |
| 54 | |
| 55 | arm_compute::Pooling3dLayerInfo layerInfo = BuildArmComputePooling3dLayerInfo(m_Data.m_Parameters, |
| 56 | fpMixedPrecision); |
| 57 | |
| 58 | { |
| 59 | ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "ClPooling3dWorkload_configure"); |
| 60 | // Run the layer. |
| 61 | m_PoolingLayer.configure(clCompileContext, &input, &output, layerInfo); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void ClPooling3dWorkload::Execute() const |
| 66 | { |
| 67 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClPooling3dWorkload_Execute", this->GetGuid()); |
| 68 | RunClFunction(m_PoolingLayer, CHECK_LOCATION()); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 | |