ArmNN
 25.11
Loading...
Searching...
No Matches
RefFloorWorkload.cpp
Go to the documentation of this file.
1//
2// Copyright © 2019-2024 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
7
8#include "Decoders.hpp"
9#include "Encoders.hpp"
10#include "RefWorkloadUtils.hpp"
11#include "Profiling.hpp"
12
13namespace armnn
14{
15
17{
18 Execute(m_Data.m_Inputs, m_Data.m_Outputs);
19}
20
21void RefFloorWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
22{
23 ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefFloatWorkload_Execute");
24
25 const TensorInfo &inputTensorInfo = GetTensorInfo(inputs[0]);
26 std::unique_ptr<Decoder<float>> decoderPtr = MakeDecoder<float>(inputTensorInfo, inputs[0]->Map());
27 Decoder<float> &decoder = *decoderPtr;
28
29 const TensorInfo &outputTensorInfo = GetTensorInfo(outputs[0]);
30 std::unique_ptr<Encoder<float>> encoderPtr = MakeEncoder<float>(outputTensorInfo, outputs[0]->Map());
31 Encoder<float> &encoder = *encoderPtr;
32
33 unsigned int numElements = GetTensorInfo(inputs[0]).GetNumElements();
34
35 for (unsigned int i = 0; i < numElements; ++i)
36 {
37 encoder.Set(floorf(decoder.Get()));
38 ++decoder;
39 ++encoder;
40 }
41}
42
43} //namespace armnn
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
virtual IType Get() const =0
virtual void Set(IType right)=0
void Execute() const override
unsigned int GetNumElements() const
Definition Tensor.hpp:198
Copyright (c) 2021 ARM Limited and Contributors.
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)