ArmNN
 24.08
RefBatchNormalizationWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017,2019-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "BatchNormImpl.hpp"
9 #include "RefWorkloadUtils.hpp"
10 
11 #include "Profiling.hpp"
12 
13 namespace armnn
14 {
15 
17  const WorkloadInfo& info)
18  : RefBaseWorkload(descriptor, info)
19  , m_Mean (std::make_unique<ScopedTensorHandle>(*(descriptor.m_Mean)))
20  , m_Variance(std::make_unique<ScopedTensorHandle>(*(descriptor.m_Variance)))
21  , m_Beta (std::make_unique<ScopedTensorHandle>(*(descriptor.m_Beta)))
22  , m_Gamma (std::make_unique<ScopedTensorHandle>(*(descriptor.m_Gamma)))
23 {}
24 
26 {
28 }
29 
31 {
32  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
33  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
34 }
35 
36 void RefBatchNormalizationWorkload::Execute(std::vector<ITensorHandle*> inputs,
37  std::vector<ITensorHandle*> outputs) const
38 {
39  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefBatchNormalizationWorkload_Execute");
40 
41  std::unique_ptr<Decoder<float>> meanDecoder = MakeDecoder<float>(m_Mean->GetTensorInfo(),
42  m_Mean->Map(true));
43  std::unique_ptr<Decoder<float>> varianceDecoder = MakeDecoder<float>(m_Variance->GetTensorInfo(),
44  m_Variance->Map(true));
45  std::unique_ptr<Decoder<float>> gammaDecoder = MakeDecoder<float>(m_Gamma->GetTensorInfo(),
46  m_Gamma->Map(true));
47  std::unique_ptr<Decoder<float>> betaDecoder = MakeDecoder<float>(m_Beta->GetTensorInfo(),
48  m_Beta->Map(true));
49  std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]),
50  inputs[0]->Map());
51  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]),
52  outputs[0]->Map());
53 
54  BatchNormImpl(m_Data, *meanDecoder, *varianceDecoder, *betaDecoder, *gammaDecoder, *inputDecoder, *outputEncoder);
55 }
56 
57 } // namespace armnn
armnn::BatchNormalizationQueueDescriptor
Definition: WorkloadData.hpp:311
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
Profiling.hpp
ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: RefWorkloadUtils.hpp:22
RefBatchNormalizationWorkload.hpp
armnn::BatchNormImpl
void BatchNormImpl(const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
Definition: BatchNormImpl.cpp:18
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
BatchNormImpl.hpp
RefWorkloadUtils.hpp
armnn::RefBatchNormalizationWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefBatchNormalizationWorkload.cpp:30
armnn::BaseWorkload< BatchNormalizationQueueDescriptor >::m_Data
BatchNormalizationQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::RefBatchNormalizationWorkload::RefBatchNormalizationWorkload
RefBatchNormalizationWorkload(const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: RefBatchNormalizationWorkload.cpp:16
std
Definition: BackendId.hpp:149
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
armnn::ScopedTensorHandle
Definition: TensorHandle.hpp:115
armnn::RefBatchNormalizationWorkload::Execute
void Execute() const override
Definition: RefBatchNormalizationWorkload.cpp:25
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14