G-API: Fix incorrect OpaqueKind for Kernel outputs#23843
Merged
asmorkalov merged 4 commits intoopencv:4.xfrom Jun 22, 2023
Merged
G-API: Fix incorrect OpaqueKind for Kernel outputs#23843asmorkalov merged 4 commits intoopencv:4.xfrom
asmorkalov merged 4 commits intoopencv:4.xfrom
Conversation
TolyaTalamanov
commented
Jun 21, 2023
| pkg = cv.gapi.kernels(GSquareMeanImpl) | ||
| mean, squares = comp.apply(cv.gin([1,2,3]), args=cv.gapi.compile_args(pkg)) | ||
|
|
||
| self.assertEqual([1,4,9], list(squares)) |
Contributor
Author
There was a problem hiding this comment.
@asmorkalov @opencv-alalek I'm a little bit confused why we convert std::vector<T> to python tuple instead of list?
https://github.com/opencv/opencv/blob/4.x/modules/python/src2/cv2_convert.hpp#L359-L362
Contributor
Author
|
@dmatveev Could you have a look, please? |
Contributor
Author
dmatveev
approved these changes
Jun 21, 2023
Contributor
dmatveev
left a comment
There was a problem hiding this comment.
👍 Fantastic, thanks for the quick turn-around!!!
Probably a short problem description would still make sense - for historic reasons..
| , {cv::detail::GTypeTraits<G>::shape} // output Shape | ||
| , {cv::detail::GTypeTraits<G>::op_kind} // input data kinds | ||
| , {cv::detail::GObtainCtor<G>::get()} // output template ctors | ||
| , {cv::detail::GTypeTraits<G>::op_kind} // output data kinds |
Contributor
There was a problem hiding this comment.
Suggested change
| , {cv::detail::GTypeTraits<G>::op_kind} // output data kinds | |
| , {cv::detail::GTypeTraits<G>::op_kind} // output data kind |
Co-authored-by: Dmitry Matveev <dmm1989@gmail.com>
Co-authored-by: Dmitry Matveev <dmm1989@gmail.com>
Merged
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
Jan 4, 2024
…aque-kind-for-kernel G-API: Fix incorrect OpaqueKind for Kernel outputs opencv#23843 ### Pull Request Readiness Checklist #### Overview The PR is going to fix several problems: 1. Major: `GKernel` doesn't hold `kind` for its outputs. Since `GModelBuilder` traverse graph from outputs to inputs once it reaches any output of the operation it will use its `kind` to create `Data` meta for all operation outputs. Since it essential for `python` to know `GTypeInfo` (which is `shape` and `kind`) it will be confused. Consider this operation: ``` @cv.gapi.op('custom.square_mean', in_types=[cv.GArray.Int], out_types=[cv.GOpaque.Float, cv.GArray.Int]) class GSquareMean: @staticmethod def outMeta(desc): return cv.empty_gopaque_desc(), cv.empty_array_desc() ``` Even though `GOpaque` is `Float`, corresponding metadata might have `Int` kind because it might be taken from `cv.GArray.Int` so it will be a problem if one of the outputs of these operation is graph output because python will cast it to the wrong type based on `Data` meta. 2. Minor: Some of the OpenVINO `IR`'s doesn't any layout information for input. It's usually true only for `IRv10` but since `OpenVINO 2.0` need this information to correctly configure resize we need to put default layout if there no such assigned in `ov::Model`. 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
thewoz
pushed a commit
to thewoz/opencv
that referenced
this pull request
May 29, 2024
…aque-kind-for-kernel G-API: Fix incorrect OpaqueKind for Kernel outputs opencv#23843 ### Pull Request Readiness Checklist #### Overview The PR is going to fix several problems: 1. Major: `GKernel` doesn't hold `kind` for its outputs. Since `GModelBuilder` traverse graph from outputs to inputs once it reaches any output of the operation it will use its `kind` to create `Data` meta for all operation outputs. Since it essential for `python` to know `GTypeInfo` (which is `shape` and `kind`) it will be confused. Consider this operation: ``` @cv.gapi.op('custom.square_mean', in_types=[cv.GArray.Int], out_types=[cv.GOpaque.Float, cv.GArray.Int]) class GSquareMean: @staticmethod def outMeta(desc): return cv.empty_gopaque_desc(), cv.empty_array_desc() ``` Even though `GOpaque` is `Float`, corresponding metadata might have `Int` kind because it might be taken from `cv.GArray.Int` so it will be a problem if one of the outputs of these operation is graph output because python will cast it to the wrong type based on `Data` meta. 2. Minor: Some of the OpenVINO `IR`'s doesn't any layout information for input. It's usually true only for `IRv10` but since `OpenVINO 2.0` need this information to correctly configure resize we need to put default layout if there no such assigned in `ov::Model`. 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Readiness Checklist
Overview
The PR is going to fix several problems:
GKerneldoesn't holdkindfor its outputs. SinceGModelBuildertraverse graph from outputs to inputs once it reaches any output of the operation it will use itskindto createDatameta for all operation outputs. Since it essential forpythonto knowGTypeInfo(which isshapeandkind) it will be confused.Consider this operation:
Even though
GOpaqueisFloat, corresponding metadata might haveIntkind because it might be taken fromcv.GArray.Intso it will be a problem if one of the outputs of these operation is graph output because python will cast it to the wrong type based on
Datameta.IR's doesn't any layout information for input. It's usually true only forIRv10but sinceOpenVINO 2.0need this information to correctly configure resize we need to put default layout if there no such assigned inov::Model.See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.