Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit a77f5e1

Browse files
committed
dnn: dump used convolution layers
1) ``` ./bin/opencv_perf_dnn --gtest_filter=*Net*:-*OpenPose*:*.SSD*:*YOLOv3*:*eccv*:*EAST* --gtest_param_filter=*CPU* --perf_min_samples=1 --perf_force_samples=1 | tee conv.log ``` 2) ``` grep '^CONV' conv.log | sed 's/CONV: / /g' | sort -gr | uniq -c \ | awk '{ { printf "%s %s %s %.3f x %s = %.3f %s ", $1*$4, $2, $3, $4*0.000000001, $1, $1*$4*0.000000001, $5 }; for(i=6;i<=NF;i++){printf "%s ", $i}; printf "\n" }' \ | sort -gr | sed -e 's/^[0-9.]* / /g' | sed 's/ $//g' \ | grep ', {{1, ' ```
1 parent 6500700 commit a77f5e1

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

modules/dnn/src/layers/convolution_layer.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace dnn
6060

6161
class BaseConvolutionLayerImpl : public ConvolutionLayer
6262
{
63+
int ngroups;
6364
public:
6465
BaseConvolutionLayerImpl(const LayerParams &params)
6566
{
@@ -69,7 +70,7 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer
6970
dilation.width, padMode);
7071

7172
numOutput = params.get<int>("num_output");
72-
int ngroups = params.get<int>("group", 1);
73+
ngroups = params.get<int>("group", 1);
7374

7475
adjustPad.height = params.get<int>("adj_h", 0);
7576
adjustPad.width = params.get<int>("adj_w", 0);
@@ -103,6 +104,29 @@ class BaseConvolutionLayerImpl : public ConvolutionLayer
103104

104105
void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs) CV_OVERRIDE
105106
{
107+
if (type == "Convolution")
108+
{
109+
int64 gflops = outputs[0].total()*(CV_BIG_INT(2)*kernel.area()*(inputs[0]->size[1]) + 1);
110+
std::cout << "input=" << shape(*inputs[0]) << " output=" << shape(outputs[0]) << std::endl;
111+
printf("CONV: /* GFLOPS %12lld */ {{%d, %d}, {{%d, %4d, %3d, %3d}}, %4d, %4d, {%d, %d}, {%d, %d}, {%d, %d}, {%d, %d}, \"%s\", %s, %12lld.},\n // ^^^^^ %s\n",
112+
(long long int)gflops,
113+
kernel.width, kernel.height,
114+
inputs[0]->size[0], inputs[0]->size[1], inputs[0]->size[2], inputs[0]->size[3],
115+
outputs[0].size[1], ngroups,
116+
stride.width, stride.height,
117+
dilation.width, dilation.height,
118+
pad.width, pad.height,
119+
adjustPad.width, adjustPad.height,
120+
padMode.empty() ? "" : padMode.c_str(),
121+
hasBias() ? "true" : "false",
122+
(long long int)gflops,
123+
name.c_str()
124+
);
125+
}
126+
else
127+
{
128+
printf("SKIP unsupported type: %s (%s)\n", type.c_str(), name.c_str());
129+
}
106130
CV_Assert(inputs.size() > 0);
107131

108132
CV_Assert(blobs.size() >= 1 && blobs.size() <= 2);

0 commit comments

Comments
 (0)