Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefBatchNormalizationWorkload.hpp" |
| 7 | |
| 8 | #include "BatchNormImpl.hpp" |
| 9 | #include "RefWorkloadUtils.hpp" |
| 10 | |
| 11 | #include "Profiling.hpp" |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | RefBatchNormalizationWorkload::RefBatchNormalizationWorkload(const BatchNormalizationQueueDescriptor& descriptor, |
| 17 | const WorkloadInfo& info) |
| 18 | : BaseWorkload(descriptor, info) |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 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))) |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 23 | {} |
| 24 | |
| 25 | void RefBatchNormalizationWorkload::Execute() const |
| 26 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 27 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 28 | } |
| 29 | |
| 30 | void RefBatchNormalizationWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 31 | { |
| 32 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 33 | } |
| 34 | |
| 35 | void RefBatchNormalizationWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 36 | std::vector<ITensorHandle*> outputs) const |
| 37 | { |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 38 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefBatchNormalizationWorkload_Execute"); |
| 39 | |
Matteo Martincigh | 6526395 | 2019-06-20 12:46:43 +0100 | [diff] [blame] | 40 | std::unique_ptr<Decoder<float>> meanDecoder = MakeDecoder<float>(m_Mean->GetTensorInfo(), |
| 41 | m_Mean->Map(true)); |
| 42 | std::unique_ptr<Decoder<float>> varianceDecoder = MakeDecoder<float>(m_Variance->GetTensorInfo(), |
| 43 | m_Variance->Map(true)); |
| 44 | std::unique_ptr<Decoder<float>> gammaDecoder = MakeDecoder<float>(m_Gamma->GetTensorInfo(), |
| 45 | m_Gamma->Map(true)); |
| 46 | std::unique_ptr<Decoder<float>> betaDecoder = MakeDecoder<float>(m_Beta->GetTensorInfo(), |
| 47 | m_Beta->Map(true)); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 48 | std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), |
| 49 | inputs[0]->Map()); |
| 50 | std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), |
| 51 | outputs[0]->Map()); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 52 | |
| 53 | BatchNormImpl(m_Data, *meanDecoder, *varianceDecoder, *betaDecoder, *gammaDecoder, *inputDecoder, *outputEncoder); |
| 54 | } |
| 55 | |
Matteo Martincigh | 6526395 | 2019-06-20 12:46:43 +0100 | [diff] [blame] | 56 | } // namespace armnn |