Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClInstanceNormalizationWorkload.hpp" |
| 7 | #include "ClWorkloadUtils.hpp" |
| 8 | |
| 9 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 10 | |
| 11 | #include <cl/ClTensorHandle.hpp> |
| 12 | |
| 13 | using namespace armnn::armcomputetensorutils; |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | arm_compute::Status ClInstanceNormalizationWorkloadValidate(const TensorInfo& input, |
| 19 | const TensorInfo& output, |
| 20 | const InstanceNormalizationDescriptor& 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 | return arm_compute::CLInstanceNormalizationLayer::validate(&aclInputInfo, |
| 26 | &aclOutputInfo, |
| 27 | descriptor.m_Gamma, |
| 28 | descriptor.m_Beta, |
| 29 | descriptor.m_Eps); |
| 30 | } |
| 31 | |
| 32 | ClInstanceNormalizationWorkload::ClInstanceNormalizationWorkload( |
| 33 | const InstanceNormalizationQueueDescriptor& descriptor, |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 34 | const WorkloadInfo& info, |
| 35 | const arm_compute::CLCompileContext& clCompileContext) |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 36 | : BaseWorkload<InstanceNormalizationQueueDescriptor>(descriptor, info) |
| 37 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 38 | // Report Profiling Details |
| 39 | ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClInstanceNormalizationWorkload_Construct", |
| 40 | descriptor.m_Parameters, |
| 41 | info, |
| 42 | this->GetGuid()); |
| 43 | |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 44 | m_Data.ValidateInputsOutputs("ClInstanceNormalizationWorkload", 1, 1); |
| 45 | |
| 46 | arm_compute::ICLTensor& input = static_cast<IClTensorHandle*>(m_Data.m_Inputs[0])->GetTensor(); |
| 47 | arm_compute::ICLTensor& output = static_cast<IClTensorHandle*>(m_Data.m_Outputs[0])->GetTensor(); |
| 48 | |
| 49 | arm_compute::DataLayout aclDataLayout = ConvertDataLayout(m_Data.m_Parameters.m_DataLayout); |
| 50 | input.info()->set_data_layout(aclDataLayout); |
| 51 | output.info()->set_data_layout(aclDataLayout); |
| 52 | |
Sadik Armagan | e944475 | 2020-12-02 11:28:58 +0000 | [diff] [blame] | 53 | m_Layer.configure(clCompileContext, |
| 54 | &input, |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 55 | &output, |
| 56 | descriptor.m_Parameters.m_Gamma, |
| 57 | descriptor.m_Parameters.m_Beta, |
| 58 | descriptor.m_Parameters.m_Eps); |
| 59 | }; |
| 60 | |
| 61 | void ClInstanceNormalizationWorkload::Execute() const |
| 62 | { |
Keith Davis | bcd860a | 2021-08-05 14:20:33 +0100 | [diff] [blame] | 63 | ARMNN_SCOPED_PROFILING_EVENT_CL_GUID("ClInstanceNormalizationWorkload_Execute", this->GetGuid()); |
Aron Virginas-Tar | 8168f40 | 2019-10-04 13:10:16 +0100 | [diff] [blame] | 64 | RunClFunction(m_Layer, CHECK_LOCATION()); |
| 65 | } |
| 66 | |
| 67 | } // namespace armnn |