Skip to content

errant initialization in DNN OCL4DNNConvSpatial<float>::verifyResult #20585

@diablodale

Description

@diablodale

The initalization of top in the template function OCL4DNNConvSpatial<float>::verifyResult is errant.

top.zeros(4, sz, (use_half_) ? CV_16SC1 : CV_32FC1);

That code is a noop. It does nothing. Why? Because there is no member function zeros(). Instead there is a static function UMat::zeros(). C++ allows you to call the static using the dot. The static function returns a UMat. It does not alter a UMat itself. Therefore, the initialization function runs, creates a new UMat, and then discards it. top is never changed. This is a coding error that CV_NODISCARD would catch ;-)

Might be part of #18457. I have the same failure in mapping of that issue. While debugging, I found the above errant code.

If you want to initialize top with zeros, correct code is

top = top.zeros(4, sz, (use_half_) ? CV_16SC1 : CV_32FC1);
// or the equivalent
top = UMat::zeros(4, sz, (use_half_) ? CV_16SC1 : CV_32FC1);
System information (version)
  • OpenCV => 3.x and 4.x
  • Operating System / Platform => all
  • Compiler => all
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions