-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Util to set (auto) names on model's input, output tensors #28975
Open
praasz
wants to merge
8
commits into
openvinotoolkit:master
Choose a base branch
from
praasz:feature/utils-generate-input-output-model-names
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+436
−52
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
02d247c
Add utils to set names on model's I/O tensors
praasz 719357c
Use auto tensor names when model created by python API
praasz 8915077
Merge branch 'master' into feature/utils-generate-input-output-model-…
praasz 043a9d0
Merge branch 'master' into feature/utils-generate-input-output-model-…
praasz 4217e5c
Rename function for default name and correct includes
praasz fc20032
Merge remote-tracking branch 'origin/master' into feature/utils-gener…
praasz 2aef675
Code style fix
praasz ebe4925
Fix code style
praasz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <unordered_map> | ||
|
||
#include "openvino/core/core_visibility.hpp" | ||
#include "openvino/core/descriptor/tensor.hpp" | ||
#include "openvino/core/model.hpp" | ||
|
||
namespace ov { | ||
|
||
/** @brief Generic atg suggests automated functionality. | ||
* | ||
* Can be use for template specialization or function overloading | ||
*/ | ||
struct AutoTag {}; | ||
inline constexpr AutoTag AUTO{}; | ||
|
||
/** @brief Alias to map of port number and tensor names */ | ||
using TensorNamesMap = std::unordered_map<size_t, TensorNames>; | ||
} // namespace ov | ||
|
||
namespace ov::util { | ||
|
||
/** @brief Set input tensors names for the model | ||
* | ||
* Sets only tensors defined in the input map. | ||
* The tensors defined in map but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its input tensors names. | ||
* @param inputs_names Map of input tensor names. | ||
*/ | ||
OPENVINO_API void set_input_tensors_names(Model& model, const TensorNamesMap& inputs_names); | ||
|
||
/** @brief Set input tensors names for the model | ||
* | ||
* Sets tensors defined in the input map others on others set to default names if there is no name. | ||
* The tensors defined in map but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its input tensors names. | ||
* @param inputs_names Map of input tensor names. Default empty. | ||
*/ | ||
OPENVINO_API void set_input_tensors_names(const AutoTag&, Model& model, const TensorNamesMap& inputs_names = {}); | ||
|
||
/** @brief Set output tensors names for the model | ||
* | ||
* Sets only tensors defined in the output map. | ||
* The tensors defined in map but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its output tensors names. | ||
* @param outputs_names Map of output tensor names.AnyMap | ||
*/ | ||
OPENVINO_API void set_output_tensor_names(Model& model, const TensorNamesMap& outputs_names); | ||
|
||
/** @brief Set output tensors names for the model. | ||
* | ||
* Sets tensors defined in the output map others on others set to default names if there is no name. | ||
* The tensors defined in map but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its output tensors names. | ||
* @param outputs_names Map of output tensor names. Default empty. | ||
*/ | ||
OPENVINO_API void set_output_tensor_names(const AutoTag&, Model& model, const TensorNamesMap& outputs_names = {}); | ||
|
||
/** @brief Set input and output tensors names for the model | ||
* | ||
* Sets only tensors defined in the input and output maps. | ||
* The tensors defined in maps but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its input and output tensors names. | ||
* @param inputs_names Map of input tensor names. | ||
* @param outputs_names Map of output tensor names. | ||
*/ | ||
OPENVINO_API void set_tensors_names(Model& model, | ||
const TensorNamesMap& inputs_names, | ||
const TensorNamesMap& outputs_names); | ||
|
||
/** @brief Set input and output tensors names for the model. | ||
* | ||
* Sets tensors defined in the input and output maps others on others set to default names if there is no name. | ||
* The tensors defined in map but not existing in the model will be ignored. | ||
* | ||
* @param model Model to set its input and output tensors names. | ||
* @param inputs_names Map of input tensor names. Default empty. | ||
* @param outputs_names Map of output tensor names. Default empty. | ||
*/ | ||
OPENVINO_API void set_tensors_names(const AutoTag&, | ||
Model& model, | ||
const TensorNamesMap& inputs_names = {}, | ||
const TensorNamesMap& outputs_names = {}); | ||
|
||
} // namespace ov::util |
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to wrap it into one more namespace (ov::util::AUTO or ov::name::AUTO or smth else)?
ov::AUTO looks unobvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is generic purpose Tag it will be easier use it from main
ov
namespace.