ArmNN
 22.11
RefDebugWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 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 
35  ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, GetName() + "_Execute");
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 
68 
69 } // namespace armnn
void Execute() const override
CPU Execution: Reference C++ kernels.
typename ResolveTypeImpl< DT >::Type ResolveType
Definition: ResolveType.hpp:79
Copyright (c) 2021 ARM Limited and Contributors.
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:379
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex, bool outputsToFile)
Definition: Debug.cpp:97
void ExecuteAsync(ExecutionData &executionData) override
void RegisterDebugCallback(const DebugCallbackFunction &func) override
unsigned int GetNumElements() const
Definition: Tensor.hpp:196
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers