ArmNN
 24.08
RefDebugWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2018-2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RefDebugWorkload.hpp"
7 #include "Debug.hpp"
8 #include "RefWorkloadUtils.hpp"
9 
10 #include <ResolveType.hpp>
11 
12 #include <cstring>
13 
14 namespace armnn
15 {
16 
17 template<armnn::DataType DataType>
19 {
20  Execute(m_Data.m_Inputs);
21 }
22 
23 template<armnn::DataType DataType>
25 {
26  WorkingMemDescriptor* workingMemDescriptor = static_cast<WorkingMemDescriptor*>(executionData.m_Data);
27  Execute(workingMemDescriptor->m_Inputs);
28 }
29 
30 template<armnn::DataType DataType>
31 void RefDebugWorkload<DataType>::Execute(std::vector<ITensorHandle*> inputs) const
32 {
33  using T = ResolveType<DataType>;
34 
36 
37  const TensorInfo& inputInfo = GetTensorInfo(inputs[0]);
38 
39  const T* inputData = GetInputTensorData<T>(0, m_Data);
40  T* outputData = GetOutputTensorData<T>(0, m_Data);
41 
42  if (m_Callback)
43  {
44  m_Callback(m_Data.m_Guid, m_Data.m_SlotIndex, inputs[0]);
45  }
46  else
47  {
48  Debug(inputInfo, inputData, m_Data.m_Guid, m_Data.m_LayerName, m_Data.m_SlotIndex, m_Data.m_LayerOutputToFile);
49  }
50 
51  std::memcpy(outputData, inputData, inputInfo.GetNumElements()*sizeof(T));
52 }
53 
54 template<armnn::DataType DataType>
56 {
57  m_Callback = func;
58 }
59 
70 
71 } // namespace armnn
armnn::TensorInfo::GetNumElements
unsigned int GetNumElements() const
Definition: Tensor.hpp:198
armnn::experimental::ExecutionData::m_Data
void * m_Data
Definition: ExecutionData.hpp:16
armnn::RefDebugWorkload::RegisterDebugCallback
void RegisterDebugCallback(const DebugCallbackFunction &func) override
Definition: RefDebugWorkload.cpp:55
armnn::RefDebugWorkload::ExecuteAsync
void ExecuteAsync(ExecutionData &executionData) override
Definition: RefDebugWorkload.cpp:24
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
armnn::RefDebugWorkload
Definition: RefDebugWorkload.hpp:16
ResolveType.hpp
RefDebugWorkload.hpp
Debug.hpp
armnn::GetTensorInfo
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
Definition: RefWorkloadUtils.hpp:33
armnn::RefDebugWorkload::Execute
void Execute() const override
Definition: RefDebugWorkload.cpp:18
armnn::ResolveType
typename ResolveTypeImpl< DT >::Type ResolveType
Definition: ResolveType.hpp:79
armnn::Debug
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex, bool outputsToFile)
Definition: Debug.cpp:97
RefWorkloadUtils.hpp
armnn::DebugCallbackFunction
std::function< void(LayerGuid guid, unsigned int slotIndex, ITensorHandle *tensorHandle)> DebugCallbackFunction
Define the type of callback for the Debug layer to call.
Definition: Types.hpp:398
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::experimental::ExecutionData
Definition: ExecutionData.hpp:14