debug_utils.cpp
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "precomp.hpp"
#include <sstream>
#include <opencv2/dnn/layer_reg.private.hpp>
#include <opencv2/dnn/utils/debug_utils.hpp>
#include <opencv2/core/utils/logger.hpp>
namespace cv { namespace dnn {
CV__DNN_INLINE_NS_BEGIN
bool DNN_DIAGNOSTICS_RUN = false;
bool DNN_SKIP_REAL_IMPORT = false;
void enableModelDiagnostics(bool isDiagnosticsMode)
{
DNN_DIAGNOSTICS_RUN = isDiagnosticsMode;
if (DNN_DIAGNOSTICS_RUN)
{
detail::NotImplemented::Register();
}
else
{
detail::NotImplemented::unRegister();
}
}
void skipModelImport(bool skip)
{
DNN_SKIP_REAL_IMPORT = skip;
}
void detail::LayerHandler::addMissing(const std::string& name, const std::string& type)
{
cv::AutoLock lock(getLayerFactoryMutex());
auto& registeredLayers = getLayerFactoryImpl();
// If we didn't add it, but can create it, it's custom and not missing.
if (layers.find(type) == layers.end() && registeredLayers.find(type) != registeredLayers.end())
{
return;
}
layers[type].insert(name);
}
bool detail::LayerHandler::contains(const std::string& type) const
{
return layers.find(type) != layers.end();
}
void detail::LayerHandler::printMissing()
{
if (layers.empty())
{
return;
}
std::stringstream ss;
ss << "DNN: Not supported types:\n";
for (const auto& type_names : layers)
{
const auto& type = type_names.first;
ss << "Type='" << type << "', affected nodes:\n[";
for (const auto& name : type_names.second)
{
ss << "'" << name << "', ";
}
ss.seekp(-2, std::ios_base::end);
ss << "]\n";
}
CV_LOG_ERROR(NULL, ss.str());
}
LayerParams detail::LayerHandler::getNotImplementedParams(const std::string& name, const std::string& op)
{
LayerParams lp;
lp.name = name;
lp.type = "NotImplemented";
lp.set("type", op);
return lp;
}
CV__DNN_INLINE_NS_END
}} // namespace