ArmNN
 25.02
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RefBatchNormalizationWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017,2019-2024 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 
30 void RefBatchNormalizationWorkload::Execute(std::vector<ITensorHandle*> inputs,
31  std::vector<ITensorHandle*> outputs) const
32 {
33  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefBatchNormalizationWorkload_Execute");
34 
35  std::unique_ptr<Decoder<float>> meanDecoder = MakeDecoder<float>(m_Mean->GetTensorInfo(),
36  m_Mean->Map(true));
37  std::unique_ptr<Decoder<float>> varianceDecoder = MakeDecoder<float>(m_Variance->GetTensorInfo(),
38  m_Variance->Map(true));
39  std::unique_ptr<Decoder<float>> gammaDecoder = MakeDecoder<float>(m_Gamma->GetTensorInfo(),
40  m_Gamma->Map(true));
41  std::unique_ptr<Decoder<float>> betaDecoder = MakeDecoder<float>(m_Beta->GetTensorInfo(),
42  m_Beta->Map(true));
43  std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]),
44  inputs[0]->Map());
45  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]),
46  outputs[0]->Map());
47 
48  BatchNormImpl(m_Data, *meanDecoder, *varianceDecoder, *betaDecoder, *gammaDecoder, *inputDecoder, *outputEncoder);
49 }
50 
51 } // namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
QueueDescriptor m_Data
Definition: Workload.hpp:74
RefBatchNormalizationWorkload(const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
Copyright (c) 2021 ARM Limited and Contributors.
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
void BatchNormImpl(const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
std::vector< ITensorHandle * > m_Inputs
std::vector< ITensorHandle * > m_Outputs
Contains information about TensorInfos of a layer.