mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #27549 from atamas19:tensor_naming_functionality
G-API: Implement cfgEnsureNamedTensors option to OpenVINO Params #27549 Added the option cfgEnsureNamedTensors to be applied on OpenVINO models with nameless tensors. If a tensor doesn't have a name, it sets a default one. The default name is created using OpenVINO's standard `make_default_tensor_name` . `make_default_tensor_name` had to be rewritten because it is only available in OpenVINO's dev_api. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] 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. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -99,6 +99,8 @@ struct ParamDesc {
|
||||
PluginConfigT config;
|
||||
|
||||
size_t nireq = 1;
|
||||
|
||||
bool ensure_named_tensors = false;
|
||||
};
|
||||
|
||||
// NB: Just helper to avoid code duplication.
|
||||
@@ -205,6 +207,24 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Ensures the model has named tensors.
|
||||
|
||||
This function is used to ensure that all tensors in the model have names.
|
||||
It goes through all input and output nodes of the model and sets the names
|
||||
if they are not set. This is neccessary for models with nameless tensors.
|
||||
|
||||
If a tensor does not have a name, it will be assigned a default name
|
||||
based on the producer node's friendly name. If the producer node has multiple
|
||||
outputs, the name will be in the form "node_name:N", where N is the output index.
|
||||
|
||||
@param flag If true, then it guarantees that all tensors will have names.
|
||||
@return reference to this parameter structure.
|
||||
*/
|
||||
Params<Net>& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @brief Specifies tensor layout for an input layer.
|
||||
|
||||
The function is used to set tensor layout for an input layer.
|
||||
@@ -524,6 +544,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgEnsureNamedTensors. */
|
||||
Params& cfgEnsureNamedTensors(bool flag = true) {
|
||||
m_desc.ensure_named_tensors = flag;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** @see ov::Params::cfgInputTensorLayout. */
|
||||
Params& cfgInputTensorLayout(std::string layout) {
|
||||
detail::getModelToSetAttrOrThrow(m_desc.kind, "input tensor layout")
|
||||
|
||||
Reference in New Issue
Block a user