ArmNN
 21.05
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  Execute(m_Data.m_Inputs);
21 }
22 
23 template<armnn::DataType DataType>
25 {
26  Execute(workingMemDescriptor.m_Inputs);
27 }
28 
29 template<armnn::DataType DataType>
30 void RefDebugWorkload<DataType>::Execute(std::vector<ITensorHandle*> inputs) const
31 {
32  using T = ResolveType<DataType>;
33 
34  ARMNN_SCOPED_PROFILING_EVENT(Compute::CpuRef, GetName() + "_Execute");
35 
36  const TensorInfo& inputInfo = GetTensorInfo(inputs[0]);
37 
38  const T* inputData = GetInputTensorData<T>(0, m_Data);
39  T* outputData = GetOutputTensorData<T>(0, m_Data);
40 
41  if (m_Callback)
42  {
43  m_Callback(m_Data.m_Guid, m_Data.m_SlotIndex, inputs[0]);
44  }
45  else
46  {
47  Debug(inputInfo, inputData, m_Data.m_Guid, m_Data.m_LayerName, m_Data.m_SlotIndex);
48  }
49 
50  std::memcpy(outputData, inputData, inputInfo.GetNumElements()*sizeof(T));
51 }
52 
53 template<armnn::DataType DataType>
55 {
56  m_Callback = func;
57 }
58 
67 
68 } // namespace armnn
void Execute() const override
CPU Execution: Reference C++ kernels.
typename ResolveTypeImpl< DT >::Type ResolveType
Definition: ResolveType.hpp:79
void ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) override
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:316
#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