Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 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) |
Finn Williams | 73c547d | 2022-02-15 20:47:34 +0000 | [diff] [blame] | 18 | : RefBaseWorkload(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 | |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 30 | void RefBatchNormalizationWorkload::ExecuteAsync(ExecutionData& executionData) |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 31 | { |
Matthew Sloyan | 2d213a7 | 2022-06-30 17:13:04 +0100 | [diff] [blame] | 32 | WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data); |
| 33 | Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void RefBatchNormalizationWorkload::Execute(std::vector<ITensorHandle*> inputs, |
| 37 | std::vector<ITensorHandle*> outputs) const |
| 38 | { |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 39 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefBatchNormalizationWorkload_Execute"); |
| 40 | |
Matteo Martincigh | 6526395 | 2019-06-20 12:46:43 +0100 | [diff] [blame] | 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)); |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 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()); |
Matteo Martincigh | 3122bd5 | 2019-06-03 16:54:25 +0100 | [diff] [blame] | 53 | |
| 54 | BatchNormImpl(m_Data, *meanDecoder, *varianceDecoder, *betaDecoder, *gammaDecoder, *inputDecoder, *outputEncoder); |
| 55 | } |
| 56 | |
Matteo Martincigh | 6526395 | 2019-06-20 12:46:43 +0100 | [diff] [blame] | 57 | } // namespace armnn |