ArmNN
 21.02
RefDebugWorkload.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. 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  using T = ResolveType<DataType>;
21 
22  ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, GetName() + "_Execute");
23 
24  const TensorInfo& inputInfo = GetTensorInfo(m_Data.m_Inputs[0]);
25 
26  const T* inputData = GetInputTensorData<T>(0, m_Data);
27  T* outputData = GetOutputTensorData<T>(0, m_Data);
28 
29  if (m_Callback)
30  {
31  m_Callback(m_Data.m_Guid, m_Data.m_SlotIndex, m_Data.m_Inputs[0]);
32  }
33  else
34  {
35  Debug(inputInfo, inputData, m_Data.m_Guid, m_Data.m_LayerName, m_Data.m_SlotIndex);
36  }
37 
38  std::memcpy(outputData, inputData, inputInfo.GetNumElements()*sizeof(T));
39 }
40 
41 template<armnn::DataType DataType>
43 {
44  m_Callback = func;
45 }
46 
55 
56 } // namespace armnn
void Execute() const override
CPU Execution: Reference C++ kernels.
typename ResolveTypeImpl< DT >::Type ResolveType
Definition: ResolveType.hpp:73
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:283
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:173
void Debug(const TensorInfo &inputInfo, const T *inputData, LayerGuid guid, const std::string &layerName, unsigned int slotIndex)
Definition: Debug.cpp:18
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
void RegisterDebugCallback(const DebugCallbackFunction &func) override
unsigned int GetNumElements() const
Definition: Tensor.hpp:192