Skip to content

[G-API] Enable 2D inputs for GIEBackend#20925

Merged
alalek merged 2 commits intoopencv:4.xfrom
TolyaTalamanov:at/enable-2d-inputs-giebackend
Nov 16, 2021
Merged

[G-API] Enable 2D inputs for GIEBackend#20925
alalek merged 2 commits intoopencv:4.xfrom
TolyaTalamanov:at/enable-2d-inputs-giebackend

Conversation

@TolyaTalamanov
Copy link
Copy Markdown
Contributor

@TolyaTalamanov TolyaTalamanov commented Oct 22, 2021

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

NV12 color format is missed.
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=*


// NB: For some reason RGB image is 2D image
// (since channel component is not counted here).
// In order to disnguish 2D tensor from image, have a look on model
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.

disnguish -- > distinguish

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.

Done

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

This branch based: #20918

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

TolyaTalamanov commented Nov 3, 2021

@alalek These warnings come from ngraph

   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/abs.hpp(26,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/acos.hpp(34,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/acosh.hpp(37,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/asin.hpp(37,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/asinh.hpp(37,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/atan.hpp(38,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/atanh.hpp(37,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/ceiling.hpp(28,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/constant.hpp(177,79): warning C4100: 'inputs': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/constant.hpp(177,50): warning C4100: 'outputs': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]
   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/embedding_segments_sum.hpp(69,65): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]

Should I just suppress them for gapi_infer_ie_test.cpp

endif()

if (HAVE_NGRAPH)
ocv_target_link_libraries(${the_module} PRIVATE ngraph::ngraph)
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.

@alalek I noticed that InferenceEngine and ngraph are handled different way, do we need to make alias to ngraph::ngraph like NGRAPH_TARGET?

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.

Does it make sense not to use InferenceEngine separately from ngraph by default?

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.

separately

find_package(InferenceEngine) and find_package(ngraph).

Check DNN module integration.

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.

I believe it's so similar to my implementation, isn't it? Except maybe this: https://github.com/opencv/opencv/blob/master/modules/dnn/CMakeLists.txt#L162 in DNN definitions set globally, in G-API we need this only for opencv_test_gapi, so far

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.

Is this question closed now?

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.

@alalek Is it OK?

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

PR based on this: #20918


#ifdef HAVE_NGRAPH
#include <ngraph/ngraph.hpp>
#endif
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.

@alalek These warnings come from ngraph

   572>C:\Program Files (x86)\IntelSWTools\openvino_2021.4.689\deployment_tools\ngraph\include\ngraph/op/abs.hpp(26,57): warning C4100: 'visitor': unreferenced formal parameter (compiling source file C:\build\precommit_custom_windows\opencv\modules\gapi\test\infer\gapi_infer_ie_test.cpp) [C:\build\precommit_custom_windows\build\modules\gapi\opencv_test_gapi.vcxproj]

Use this prolog code before ngraph include :

#if defined(__clang__) // clang or MSVC clang
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4100)
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif

and similar prolog code (check referenced file).


/cc @ilya-lavrenov FYI (public headers should not emit warnings)

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.

Added, works fine now, thanks!

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.

@alalek it's fixed in latest master (checked by openvinotoolkit/openvino#8403 where I don't have to fix such issues)

Secondly, you can include IE headers as SYSTEM

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.

as SYSTEM

Even on Windows and MSVC?


in latest master

Upcoming release is 2021.4 LTS update. So we still forced to use/validate that.

@dmatveev dmatveev self-assigned this Nov 10, 2021
endif()

if (HAVE_NGRAPH)
ocv_target_link_libraries(${the_module} PRIVATE ngraph::ngraph)
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.

Is this question closed now?

#include "backends/ie/util.hpp"
#include "backends/ie/giebackend/giewrapper.hpp"

#ifdef HAVE_NGRAPH
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.

Should tests link with ngraph::ngraph too? I don't remember if it is the case for CMake.

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.

That's a good point, but ngraph is enabled by using -DWITH_NGRAPH=ON and this flag isn't mandatory to use IE itself.
So if user just do cmake as same as usual: -DWITH_INF_ENGINE=ON ngraph won't be found.

@ilya-lavrenov Could you help, please? Do you know whether ngraph will be mandatory part of IE in upcoming OpenVINO 2.0 release?

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.

LGTM but please close the linker question

@TolyaTalamanov TolyaTalamanov force-pushed the at/enable-2d-inputs-giebackend branch from 494aa33 to 0d2531f Compare November 16, 2021 07:03
Copy link
Copy Markdown
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

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

LGTM

@TolyaTalamanov
Copy link
Copy Markdown
Contributor Author

@alalek I believe it's ready to be merged

@alalek alalek merged commit c7df824 into opencv:4.x Nov 16, 2021
@alalek alalek mentioned this pull request Dec 30, 2021
@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
…ts-giebackend

[G-API] Enable 2D inputs for GIEBackend

* Enable 2D inputs

* Fix typo
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