Skip to content

dnn: update network dump code, include ngraph serialization#17388

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
alalek:dnn_update_network_dump
May 27, 2020
Merged

dnn: update network dump code, include ngraph serialization#17388
opencv-pushbot merged 1 commit intoopencv:3.4from
alalek:dnn_update_network_dump

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented May 26, 2020

relates #17382

force_builders=Custom,Custom Win,Custom Mac
build_image:Custom=ubuntu-openvino-2020.2.0:16.04
build_image:Custom Win=openvino-2020.2.0
build_image:Custom Mac=openvino-2020.2.0

test_modules:Custom=dnn,python2,python3,java
test_modules:Custom Win=dnn,python2,python3,java
test_modules:Custom Mac=dnn,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*


if (DNN_IE_SERIALIZE)
{
#ifndef OPENCV_DNN_DISABLE_NETWORK_AUTO_DUMP
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this is defined? And what is default value?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not defined anywhere in OpenCV, but can be passed through build flags.
Purpose is custom builds which want to turn off network dumps.

Copy link
Copy Markdown
Member

@dkurt dkurt May 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought that AUTO_DUMP means to dump networks by default, without flags. If it's build flag, that means that if OPENCV_DNN_DISABLE_NETWORK_AUTO_DUMP is not specified but OPENCV_DNN_IE_SERIALIZE is ON we cannot dump the network?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is aligned with this code.

Idea is compile-time blocker to dump/serialize network.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, basically my motivation is to have this option available in OpenCV from OpenVINO distribution. Sometimes to enable models in OpenVINO it's helpful to have this method. Will this build flag be available in OpenVINO build by default or we can miss it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is enabled by default, including OpenVINO builds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see now, sorry. #ifndef and DISABLE. Thanks!

std::string dumpFileNameBase = netImpl_.getDumpFileNameBase();
try
{
cnn.serialize(dumpFileNameBase + "_ngraph.xml", dumpFileNameBase + "_ngraph.bin");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, dumping network twice doesn't work (at least for YOLOv3 tests):

cnn.serialize(dumpFileNameBase + "_ngraph.xml", dumpFileNameBase + "_ngraph.bin");
cnn.serialize(dumpFileNameBase + "_ngraph2.xml", dumpFileNameBase + "_ngraph2.bin");

Error message is:

Exception: Broken edge form layer Multiply_169520 to layer Divide_143502during serialization of IR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bug in Inference Engine. Have you checked an accuracy after a single serialize? Maybe it breaks even inference.

Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

@dkurt dkurt self-assigned this May 26, 2020
@opencv-pushbot opencv-pushbot merged commit 7d9e1be into opencv:3.4 May 27, 2020
@dkurt
Copy link
Copy Markdown
Member

dkurt commented May 28, 2020

Faced the following error:

terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(3.4.10-dev) /home/dkurt/opencv/modules/core/src/system.cpp:2026: error: (-5:Bad argument) Invalid value for parameter OPENCV_DNN_IE_SERIALIZE: ./model.xml in function 'read'

Aborted (core dumped)

when

export OPENCV_DNN_IE_SERIALIZE=./model.xml

Update: Oh, I see. This is boolean,

export OPENCV_DNN_IE_SERIALIZE=1

output

ocv_dnn_net_00000_00_ngraph.bin
ocv_dnn_net_00000_00_ngraph.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants