• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "NeonInstanceNormalizationWorkload.hpp"
7 
8 #include "NeonWorkloadUtils.hpp"
9 
10 #include <aclCommon/ArmComputeTensorUtils.hpp>
11 #include <armnn/backends/TensorHandle.hpp>
12 #include <neon/NeonTensorHandle.hpp>
13 
14 using namespace armnn::armcomputetensorutils;
15 
16 namespace armnn
17 {
18 
NeonInstanceNormalizationWorkloadValidate(const TensorInfo & input,const TensorInfo & output,const InstanceNormalizationDescriptor & descriptor)19 arm_compute::Status NeonInstanceNormalizationWorkloadValidate(const TensorInfo& input,
20                                                               const TensorInfo& output,
21                                                               const InstanceNormalizationDescriptor& descriptor)
22 {
23     const arm_compute::TensorInfo aclInputInfo  = BuildArmComputeTensorInfo(input, descriptor.m_DataLayout);
24     const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.m_DataLayout);
25 
26     return arm_compute::NEInstanceNormalizationLayer::validate(&aclInputInfo,
27                                                                &aclOutputInfo,
28                                                                descriptor.m_Gamma,
29                                                                descriptor.m_Beta,
30                                                                descriptor.m_Eps);
31 }
32 
NeonInstanceNormalizationWorkload(const InstanceNormalizationQueueDescriptor & descriptor,const WorkloadInfo & info)33 NeonInstanceNormalizationWorkload::NeonInstanceNormalizationWorkload(
34     const InstanceNormalizationQueueDescriptor& descriptor,
35     const WorkloadInfo& info)
36     : NeonBaseWorkload<InstanceNormalizationQueueDescriptor>(descriptor, info)
37 {
38     // Report Profiling Details
39     ARMNN_REPORT_PROFILING_WORKLOAD_DESC("NeonInstanceNormalizationWorkload_Construct",
40                                          descriptor.m_Parameters,
41                                          info,
42                                          this->GetGuid());
43 
44     m_Data.ValidateInputsOutputs("NeonInstanceNormalizationWorkload", 1, 1);
45 
46     arm_compute::ITensor& input  = static_cast<IAclTensorHandle*>(m_Data.m_Inputs[0])->GetTensor();
47     arm_compute::ITensor& output = static_cast<IAclTensorHandle*>(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 
53     m_Layer.configure(&input,
54                       &output,
55                       descriptor.m_Parameters.m_Gamma,
56                       descriptor.m_Parameters.m_Beta,
57                       descriptor.m_Parameters.m_Eps);
58 };
59 
Execute() const60 void NeonInstanceNormalizationWorkload::Execute() const
61 {
62     ARMNN_SCOPED_PROFILING_EVENT_NEON_GUID("NeonInstanceNormalizationWorkload_Execute", this->GetGuid());
63     m_Layer.run();
64 }
65 
66 } // namespace armnn