Not serialize compile arguments which have no S11N<T> template specialization#18651
Conversation
cc1eca1 to
adb2cb4
Compare
|
@smirnov-alexey , @dmatveev. |
| os << arg.tag; | ||
| arg.serialize(os); | ||
| ByteMemoryOutStream tmpS; | ||
| tmpS << arg.tag; |
There was a problem hiding this comment.
Tag could be written to a primary stream.
There was a problem hiding this comment.
Thanks! Reworked this part!
| cv::gapi::s11n::detail::S11N<T>::deserialize(is) | ||
| }; | ||
| static_assert(cv::gapi::s11n::detail::has_S11N_spec<T>::value, | ||
| "cv::gapi::deserialize<GCompileArgs, Types...> waits Types to have S11N specializations" |
| cv::gapi::s11n::IIStream& is = *pIs; | ||
|
|
||
| std::string tag; | ||
| is >> tag; |
There was a problem hiding this comment.
Here you read tag directly from the stream, but in the serialization code, you write tag to a temporary stream and then serialize its vector.
In theory, this code should work incorrectly. Please double-check.
There was a problem hiding this comment.
Here I have a GCompileArg as serialized vector of char, which were deserialized from the main stream and this vector of char should contain that that were deserialized in temporary stream.
There was a problem hiding this comment.
Please simplify, the code shouldn't cause the confusion like mine
There was a problem hiding this comment.
Simplified, thanks!
| GCompileArgs dArgsEmptyVar4 = cv::gapi::deserialize<GCompileArgs, EmptyCustomType>(sArgs4); | ||
| EXPECT_EQ(1u, dArgsEmptyVar4.size()); | ||
| EXPECT_TRUE(cv::gapi::getCompileArg<EmptyCustomType>(dArgsEmptyVar4).has_value()); | ||
| } |
There was a problem hiding this comment.
There must be a test failing due to inconsistency in S11N for custom compile arg tags.
6145aea to
60ff600
Compare
| for (uint32_t i = 0; i < sz; ++i) { | ||
| std::string tag; | ||
| is >> tag; | ||
| args.push_back(cv::gapi::detail::deserialize_arg<std::tuple<Types...>>::exec(is, tag)); | ||
|
|
||
| std::vector<char> sArg; | ||
| is >> sArg; | ||
|
|
||
| cv::util::optional<GCompileArg> dArg = |
There was a problem hiding this comment.
This whole thing can be further simplified, but let's leave it for now.
Just put a task in our tracker to implement GCompileArgs serialization in a more generic two-stage way (based on vectors).
smirnov-alexey
left a comment
There was a problem hiding this comment.
Overall looks good
…CompileArgs - cv::gapi::serialize bypasses compile arguments which have no S11N specialization with serialize/deserialize callbacks for underlying types - cv::gapi::deserialize can accept arbitraty number of serialized compile args in a stream but will return only those which are requested by user via template parameter pack if they are presented in the stream. If some or all of them are not presented cv::gapi::deserialize will ignore and return only those which are presented - cv::gapi::deserialize can accept only types which can be deserialized (have S11N<T> specialization with the user callbacks) - Added cv::gapi::s11n::detail::has_S11N_spec<T> trait to separate compile arguments which have S11N<T> specialization with the user callbacks
60ff600 to
48ccbe3
Compare
Pull Request Readiness Checklist
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.