Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Samsung Electronics Co Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefReduceWorkload.hpp" |
| 7 | |
| 8 | #include "Reduce.hpp" |
| 9 | #include "RefWorkloadUtils.hpp" |
| 10 | #include "BaseIterator.hpp" |
| 11 | #include "Profiling.hpp" |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | RefReduceWorkload::RefReduceWorkload( |
| 17 | const ReduceQueueDescriptor& descriptor, |
| 18 | const WorkloadInfo& info) |
| 19 | : BaseWorkload<ReduceQueueDescriptor>(descriptor, info) {} |
| 20 | |
| 21 | void RefReduceWorkload::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 RefReduceWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 27 | { |
| 28 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 29 | } |
| 30 | |
| 31 | void RefReduceWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 32 | { |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 33 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefReduceWorkload_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]); |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 37 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 38 | std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputInfo, inputs[0]->Map()); |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 39 | Decoder<float>& decoder = *decoderPtr; |
| 40 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 41 | std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputInfo, outputs[0]->Map()); |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 42 | Encoder<float>& encoder = *encoderPtr; |
| 43 | |
| 44 | Reduce(inputInfo, |
| 45 | outputInfo, |
| 46 | decoder, |
| 47 | encoder, |
| 48 | m_Data.m_Parameters.m_vAxis, |
| 49 | m_Data.m_Parameters.m_ReduceOperation); |
| 50 | } |
| 51 | |
| 52 | } //namespace armnn |