ArmNN
 25.11
Loading...
Searching...
No Matches
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"
10
11#include "Profiling.hpp"
12
13namespace 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{
27 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
28}
29
30void 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.
RefBaseWorkload(const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
RefBatchNormalizationWorkload(const BatchNormalizationQueueDescriptor &descriptor, const WorkloadInfo &info)
Copyright (c) 2021 ARM Limited and Contributors.
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
void BatchNormImpl(const BatchNormalizationQueueDescriptor &data, Decoder< float > &meanDecoder, Decoder< float > &varianceDecoder, Decoder< float > &betaDecoder, Decoder< float > &gammaDecoder, Decoder< float > &inputDecoder, Encoder< float > &outputEncoder)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)
Contains information about TensorInfos of a layer.