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