ArmNN
 24.02
RefQuantizeWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include "RefWorkloadUtils.hpp"
9 
10 #include <armnn/TypesUtils.hpp>
11 
12 
13 namespace armnn
14 {
15 
16 namespace
17 {
18 
19 void QuantizeImpl(Decoder<float>& in, Encoder<float>& out, size_t numValues)
20 {
21  for (unsigned int i = 0; i < numValues; i++)
22  {
23  in[i];
24  out[i];
25  out.Set(in.Get());
26  }
27 }
28 
29 } //namespace
30 
32  : RefBaseWorkload(descriptor, info)
33  , m_NumElements(info.m_InputTensorInfos[0].GetNumElements())
34 {
35 }
36 
38 {
40 }
41 
43 {
44  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
45  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
46 }
47 
48 void RefQuantizeWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
49 {
50  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefQuantizeWorkload_Execute");
51 
52  std::unique_ptr<Decoder<float>> inputDecoder = MakeDecoder<float>(GetTensorInfo(inputs[0]), inputs[0]->Map());
53  std::unique_ptr<Encoder<float>> outputEncoder = MakeEncoder<float>(GetTensorInfo(outputs[0]), outputs[0]->Map());
54 
55  QuantizeImpl(*inputDecoder, *outputEncoder, m_NumElements);
56 }
57 
58 } //namespace armnn
armnn::RefQuantizeWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefQuantizeWorkload.cpp:42
armnn::QuantizeQueueDescriptor
Definition: WorkloadData.hpp:299
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
TypesUtils.hpp
ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
Definition: RefWorkloadUtils.hpp:22
RefQuantizeWorkload.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::BoostLogSeverityMapping::info
@ info
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::RefQuantizeWorkload::Execute
void Execute() const override
Definition: RefQuantizeWorkload.cpp:37
RefWorkloadUtils.hpp
armnn::BaseWorkload< QuantizeQueueDescriptor >::m_Data
QuantizeQueueDescriptor m_Data
Definition: Workload.hpp:89
armnn::LayerType::Map
@ Map
armnn::experimental::WorkingMemDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkingMemDescriptor.hpp:20
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::experimental::WorkingMemDescriptor
Definition: WorkingMemDescriptor.hpp:18
armnn::RefBaseWorkload
Definition: RefBaseWorkload.hpp:13
armnn::RefQuantizeWorkload::RefQuantizeWorkload
RefQuantizeWorkload(const QuantizeQueueDescriptor &descriptor, const WorkloadInfo &info)
Definition: RefQuantizeWorkload.cpp:31
armnn::experimental::WorkingMemDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkingMemDescriptor.hpp:21
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition: WorkloadData.hpp:26
armnn::experimental::ExecutionData
Definition: ExecutionData.hpp:14