Skip to content

[G-API] Pipeline modeling tool - Fix generating FP16 Mat#21566

Merged
alalek merged 3 commits intoopencv:4.xfrom
TolyaTalamanov:at/gapi-modeling-tool_fix_handling_fp16_precision
Feb 7, 2022
Merged

[G-API] Pipeline modeling tool - Fix generating FP16 Mat#21566
alalek merged 3 commits intoopencv:4.xfrom
TolyaTalamanov:at/gapi-modeling-tool_fix_handling_fp16_precision

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Build configuration

force_builders=Custom,Custom Win,Custom Mac
build_gapi_standalone:Linux x64=ade-0.1.1f
build_gapi_standalone:Win64=ade-0.1.1f
build_gapi_standalone:Mac=ade-0.1.1f
build_gapi_standalone:Linux x64 Debug=ade-0.1.1f

Xbuild_image:Custom=centos:7
Xbuildworker:Custom=linux-1
build_gapi_standalone:Custom=ade-0.1.1f

build_image:Custom=ubuntu-openvino-2021.4.1:20.04
build_image:Custom Win=openvino-2021.4.1
build_image:Custom Mac=openvino-2021.4.1

test_modules:Custom=gapi,python2,python3,java
test_modules:Custom Win=gapi,python2,python3,java
test_modules:Custom Mac=gapi,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=*

cv::randu(out, 0.f, 1.f);
break;
case CV_16F: {
cv::Mat fp32_mat(out.size(), CV_MAKETYPE(CV_32F, out.channels()));
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.

If out is ND (honestly it's always ND, since we create cv::Mat's from std::vector) calling size method cause exception

@TolyaTalamanov TolyaTalamanov changed the title Fix handling fp16 precision [G-API] Pipeline modeling tool - Fix generating FP16 Mat Feb 4, 2022
// create cv::Mat the same way in order to achieve meta matching.
// Change this line when it's fixed to:
// mat.create(dims, CV_MAKETYPE(depth, dims.size()));
mat.create(dims, depth);
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.

@mshabunin @alalek Could you help us with understanding?
Which line is correct to create ND cv::Mat?

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.

mat.create(dims, CV_MAKETYPE(depth, dims.size()));

This doesn't look valid as dims.size() should NOT be used as number of channels.


mat.create(dims, depth);

This code is equal to mat.create(dims, CV_MAKETYPE(depth, 1));

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.

And what's the correct way to create ND Mat with dims and let's say CV_32F depth?

mat.create(dims, CV_32f)

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.

CV_32F is allowed (CN=1 is assumed).
CV_32FC1 is accurate.

@TolyaTalamanov TolyaTalamanov force-pushed the at/gapi-modeling-tool_fix_handling_fp16_precision branch from 2667616 to d440af5 Compare February 4, 2022 08:45
@dmatveev dmatveev self-assigned this Feb 7, 2022
@dmatveev dmatveev added this to the 4.6.0 milestone Feb 7, 2022
Copy link
Copy Markdown
Contributor

@dmatveev dmatveev left a comment

Choose a reason for hiding this comment

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

👍

@alalek alalek merged commit 0835600 into opencv:4.x Feb 7, 2022
TolyaTalamanov added a commit to TolyaTalamanov/opencv that referenced this pull request Feb 18, 2022
…tool_fix_handling_fp16_precision

[G-API] Pipeline modeling tool - Fix generating FP16 Mat

* Fix handling fp16 precision

* Disable preproc in case FP16 input inside IE backend

* Fix isApplicableForResize function
@alalek alalek mentioned this pull request Feb 22, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…tool_fix_handling_fp16_precision

[G-API] Pipeline modeling tool - Fix generating FP16 Mat

* Fix handling fp16 precision

* Disable preproc in case FP16 input inside IE backend

* Fix isApplicableForResize function
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