Skip to content

Add support for Conv1D on OpenCV backend#18783

Merged
alalek merged 12 commits intoopencv:3.4from
sl-sergei:fix_conv1d
Nov 13, 2020
Merged

Add support for Conv1D on OpenCV backend#18783
alalek merged 12 commits intoopencv:3.4from
sl-sergei:fix_conv1d

Conversation

@sl-sergei
Copy link
Copy Markdown
Contributor

@sl-sergei sl-sergei commented Nov 11, 2020

resolves #18205

merge with extra: opencv/opencv_extra#813

opencv_extra=test_conv1d

force_builders=Custom,Custom Win,Custom Mac

Xbuildworker:Custom=linux-3
Xbuild_image:Custom=ubuntu:18.04
XCPU_BASELINE:Custom=AVX512_SKX
Xdisable_ipp:Custom=ON

build_image:Custom=ubuntu-openvino-2021.1.0:20.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=*

typedef tuple<Conv1DParamID, tuple<Backend, Target> > Conv1DTestParam_t;
typedef TestBaseWithParam<Conv1DTestParam_t> Conv1D;

PERF_TEST_P_(Conv1D, conv1d)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation.

Target targetId = get<1>(get<1>(GetParam()));

if (targetId != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indentation.

Sorry, my formatter broke (again)

lp.set("kernel_size", kernel);
lp.set("pad", pad);
if (!padMode.empty())
lp.set("pad_mode", padMode);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation.

Comment on lines +123 to +127
{
Mat bias(1, outChannels, CV_32F);
randu(bias, -1.0f, 1.0f);
lp.blobs.push_back(bias);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation.

{
Mat res = net.forward();
}
EXPECT_NEAR(flops, declared_flops, declared_flops * 1e-6);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

flops is integer value. Check should be exact without epsilon.

net.setPreferableBackend(backendId);
net.setPreferableTarget(targetId);

Mat output = net.forward();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add some check for output result. At least output shape.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, this is a warmup iteration, I don't think it is necessary to check the correctness of output shapes inside performance tests (it is already covered in other tests)

@sl-sergei sl-sergei removed the request for review from l-bat November 12, 2020 13:51
@sl-sergei
Copy link
Copy Markdown
Contributor Author

@dkurt I have updated the code, can you resolve your comments/requests?

@sl-sergei
Copy link
Copy Markdown
Contributor Author

@asmorkalov Can you resolve your comments/requests?

@sl-sergei
Copy link
Copy Markdown
Contributor Author

@alalek @dkurt My current changes do not affect test case Layer_Test_Slice.slice_channels_and_batch_17762/3 and some other tests in opencv_test_dnn, but still they are sporadically fail on MYRIAD device. Do you know something about this problem?

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 12, 2020

Ignore these test failures because they are not related to this patch.
These tests fail on other PRs too.

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.

👍 Thanks!

@l-bat
Copy link
Copy Markdown
Contributor

l-bat commented Nov 13, 2020

Could you please add test with variable weights (blobs.empty())?

@sl-sergei
Copy link
Copy Markdown
Contributor Author

@dkurt @alalek What do you think about OpenCL support? I discussed it today with Vadim Pisarevsky and we consider it as low priority task. @alalek How fast can these changes be merged to 4.* branch? I want to enable it for CUDA backend.

@sl-sergei
Copy link
Copy Markdown
Contributor Author

Could you please add test with variable weights (blobs.empty())?

Sure

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 13, 2020

"Merge 3.4" is expected on this week (at 21:00 UTC today or tomorrow)

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 13, 2020

You can skip implementation of OpenCL optimizations, but it should be properly handled.

There is general policy about DNN layers implementation:

  • layer .forward() should not fail with exception due to lack of optimization implementation
  • layer + DNN engine should fallback on OpenCV+CPU in such cases if optimization doesn't support passed parameters
  • OpenCV+CPU should be always supported

/cc @vpisarev

@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 13, 2020

but still they are sporadically fail on MYRIAD device

You have used outdated versions of IE for testing.
Actual versions which should be used by default are stored here: https://github.com/opencv/opencv/wiki/CI-configuration ("DNN testing" section)

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.

5 participants