Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "RefFloorWorkload.hpp" |
| 7 | |
| 8 | #include "Decoders.hpp" |
| 9 | #include "Encoders.hpp" |
| 10 | #include "RefWorkloadUtils.hpp" |
| 11 | #include "Profiling.hpp" |
| 12 | |
| 13 | namespace armnn |
| 14 | { |
| 15 | |
| 16 | void RefFloorWorkload::Execute() const |
| 17 | { |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 18 | Execute(m_Data.m_Inputs, m_Data.m_Outputs); |
| 19 | } |
| 20 | |
| 21 | void RefFloorWorkload::ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) |
| 22 | { |
| 23 | Execute(workingMemDescriptor.m_Inputs, workingMemDescriptor.m_Outputs); |
| 24 | } |
| 25 | |
| 26 | void RefFloorWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const |
| 27 | { |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 28 | ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, "RefFloorFloat32Workload_Execute"); |
| 29 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 30 | const TensorInfo &inputTensorInfo = GetTensorInfo(inputs[0]); |
| 31 | std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputTensorInfo, inputs[0]->Map()); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 32 | Decoder<float> &decoder = *decoderPtr; |
| 33 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 34 | const TensorInfo &outputTensorInfo = GetTensorInfo(outputs[0]); |
| 35 | std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputTensorInfo, outputs[0]->Map()); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 36 | Encoder<float> &encoder = *encoderPtr; |
| 37 | |
Finn Williams | b8181f7 | 2021-04-07 10:23:21 +0100 | [diff] [blame] | 38 | unsigned int numElements = GetTensorInfo(inputs[0]).GetNumElements(); |
James Conroy | 83735b1 | 2019-05-30 16:36:59 +0100 | [diff] [blame] | 39 | |
| 40 | for (unsigned int i = 0; i < numElements; ++i) |
| 41 | { |
| 42 | encoder.Set(floorf(decoder.Get())); |
| 43 | ++decoder; |
| 44 | ++encoder; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | } //namespace armnn |