ArmNN
 24.02
RefCastWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RefCastWorkload.hpp"
7 #include "RefWorkloadUtils.hpp"
9 #include <ResolveType.hpp>
10 #include "Encoders.hpp"
11 #include "Decoders.hpp"
12 
13 namespace
14 {
15  void Cast(armnn::Decoder<float>& in, armnn::Encoder<float>& out, const uint32_t numElements )
16  {
17  for (unsigned int i = 0; i < numElements; i++)
18  {
19  out.Set(in.Get());
20  ++in;
21  ++out;
22  }
23  }
24 }
25 
26 namespace armnn
27 {
28 
30 {
32 }
33 
35 {
36  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
37  Execute(workingMemDescriptor->m_Inputs, workingMemDescriptor->m_Outputs);
38 }
39 
40 void RefCastWorkload::Execute(std::vector<ITensorHandle*> inputs, std::vector<ITensorHandle*> outputs) const
41 {
42  ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID("RefCastWorkload_Execute");
43 
44  TensorInfo inputTensorInfo(GetTensorInfo(inputs[0]));
45  TensorInfo outputTensorInfo(GetTensorInfo(outputs[0]));
46 
47  // Quantization info should set to default values.
48  if (inputTensorInfo.IsQuantized())
49  {
50  inputTensorInfo.SetQuantizationScale(1.0f);
51  inputTensorInfo.SetQuantizationOffset(0);
52  }
53  if (outputTensorInfo.IsQuantized())
54  {
55  outputTensorInfo.SetQuantizationScale(1.0f);
56  outputTensorInfo.SetQuantizationOffset(0);
57  }
58 
59  Cast(*MakeDecoder<float>(inputTensorInfo, inputs[0]->Map()),
60  *MakeEncoder<float>(outputTensorInfo, outputs[0]->Map()),
61  inputTensorInfo.GetNumElements());
62 }
63 
64 } //namespace armnn
armnn::Decoder< float >
armnn::Encoder::Set
virtual void Set(IType right)=0
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
armnn::TensorInfo
Definition: Tensor.hpp:152
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
ResolveType.hpp
RefCastWorkload.hpp
armnn::Encoder< float >
armnn::RefCastWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefCastWorkload.cpp:34
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::RefCastWorkload::Execute
void Execute() const override
Definition: RefCastWorkload.cpp:29
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition: WorkloadData.hpp:27
armnn::Decoder::Get
virtual IType Get() const =0
armnn::LayerType::Cast
@ Cast
RefWorkloadUtils.hpp
armnn::BaseWorkload< CastQueueDescriptor >::m_Data
CastQueueDescriptor m_Data
Definition: Workload.hpp:89
Decoders.hpp
armnn::LayerType::Map
@ Map
FloatingPointConverter.hpp
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
Encoders.hpp
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