1 // Copyright (C) 2018 Intel Corporation
3 // SPDX-License-Identifier: Apache-2.0
15 #include "cpp/ie_cnn_network.h"
16 #include <CPP/memory.hpp>
17 #include <CPP/primitive.hpp>
18 #include <CPP/network.hpp>
20 // Debugging options flags
21 // #define _DEBUG_LAYER_CONTENT
22 // #define _DEBUG_LAYER_CONTENT_FULL
23 // #define _DEBUG_LAYER_FORMAT
24 // #define _PLUGIN_PERF_PRINTS
26 namespace CLDNNPlugin {
30 bool m_bDebugLayerContent;
31 bool m_bDebugLayerContentIndexed;
32 bool m_bDebugLayerFormat;
33 bool m_bPluginPerfPrints;
34 cldnn::tensor::value_type m_maxPrintSize;
37 void PrintOptions() const;
38 static std::string GetFormatName(cldnn::format::type format);
39 static std::string GetDataTypeName(cldnn::data_types dataType);
40 void PrintInput(const InferenceEngine::TBlob<float>& input) const;
41 void PrintIndexedValue(const cldnn::memory& mem, const cldnn::tensor index) const;
42 static uint32_t CalcLinearIndex(const cldnn::layout& memLayout, const cldnn::tensor index);
44 void PrintNetworkOutputs(std::map<cldnn::primitive_id, cldnn::network_output>& outputsMap) const;
45 void DumpSingleOutput(cldnn::primitive_id name, std::map<cldnn::primitive_id, cldnn::network_output>& outputs, bool bSingleFeatureMap = false)const;
47 // the functions below will work in release unlike the rest
48 void AddTimedEvent(std::string eventName, std::string startingAt = std::string());
49 void PrintTimedEvents();
50 void ClearTimedEvents();
52 void EnableWA(std::string name);
53 void DisableWA(std::string name);
54 bool IsWAActive(std::string name);
56 static std::string IELayoutToString(InferenceEngine::Layout layout);
59 std::map<std::string, std::chrono::steady_clock::time_point> m_TimedEventTimestamp;
60 std::map<std::string, std::string> m_TimedEventStart;
61 std::set<std::string> m_workaroundNames;
63 static float SimpleConvertFP16toFP32(uint16_t u16val);
66 static void DumpElementsRaw(cldnn::memory& mem, const std::vector<size_t>& pitches, size_t numElements) {
68 auto layout = mem.get_layout();
69 auto ptr = mem.pointer<T>();
70 auto data = ptr.data(); // +offset;
71 auto elements = std::min(layout.count(), numElements);
72 cldnn::status_t status = CLDNN_SUCCESS;
73 for (size_t i = 0; i < elements;) {
74 // size_t linearAddress = ... // todo calc linear with pitches
75 std::cout << std::setprecision(10)
76 << ((layout.data_type == cldnn::data_types::f32) ? data[i] : cldnn_half_to_float(uint16_t(data[i]), &status))
79 for (auto& pitch : pitches) {
80 if ((i % pitch) == 0) {
81 std::cout << std::endl;
89 }; // namespace CLDNNPlugin