-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Util to set (auto) names on model's input, output tensors (#28975
) ### Details: - Add utils to core to set names on model input/output tensors - Define default tensor names and port separator - Use auto naming in model created by python API. Model outputs will have got names also. - The auto naming can be part of Model API but requires to add validation tools to find and resolve names collision - Auto naming cannot be added to Model creation in C++ as it can have impact on (de)serialization, requires more investigation ### Tickets: - CVS-159997 --------- Signed-off-by: Raasz, Pawel <[email protected]>
- Loading branch information
Showing
10 changed files
with
440 additions
and
51 deletions.
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,98 @@ | ||
// 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. | ||
* Tensors not defined in the map are set to default names if the tensor hasn't got names. | ||
* The tensors defined in the 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. | ||
* Tensors not defined in the map are set to default names if the tensor hasn't got names. | ||
* The tensors defined in the 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. | ||
* Tensors not defined in the maps are set to default names if the tensor hasn't got names. | ||
* The tensors defined in the 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. 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.