James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefMeanWorkload.hpp" |
| 7 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 8 | #include "Reduce.hpp" |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 9 | #include "RefWorkloadUtils.hpp" |
| 10 | |
| 11 | #include "Profiling.hpp" |
| 12 | |
| 13 | #include <vector> |
| 14 | |
| 15 | namespace armnn |
| 16 | { |
| 17 | |
| 18 | RefMeanWorkload::RefMeanWorkload(const MeanQueueDescriptor& descriptor, const WorkloadInfo& info) |
| 19 | :BaseWorkload<MeanQueueDescriptor>(descriptor, info) {} |
| 20 | |
| 21 | void RefMeanWorkload::Execute() const |
| 22 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 23 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 24 | } |
| 25 | |
| 26 | void RefMeanWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 27 | { |
| 28 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 29 | } |
| 30 | |
| 31 | void RefMeanWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 32 | { |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 33 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefMeanWorkload_Execute"); |
| 34 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 35 | const TensorInfo& inputInfo = GetTensorInfo(inputs[0]); |
| 36 | const TensorInfo& outputInfo = GetTensorInfo(outputs[0]); |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 37 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 38 | auto inputDecoder = MakeDecoder<float>(inputInfo, inputs[0]->Map()); |
| 39 | auto outputEncoder = MakeEncoder<float>(outputInfo, outputs[0]->Map()); |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 40 | |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 41 | Reduce(inputInfo, |
| 42 | outputInfo, |
| 43 | *inputDecoder, |
| 44 | *outputEncoder, |
| 45 | m_Data.m_Parameters.m_Axis, |
| 46 | armnn::ReduceOperation::Mean); |
James Conroy | 4d1ff58 | 2019-06-10 17:06:39 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | } //namespace armnn |