-
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] Add specific tensor descriptor for Result (#25954)
### Details: - Introduce shared tensor descriptor: - It has specific tensor names. - When specific tensor names set they will be used as tensor names otherwise the shred tensor names are used. - Specific tensor names will be added to shared descriptor (input descriptor), and transferred to new tensor descriptor if changed. - Use shared tensor descriptor for Result, which got specific tensor names. - Add dev API Extension interface for descriptor::Tensor for internal OV use. - Update `ReverseShapeAndTypeInfer` to use descriptor interface instead change properties directly. Update `PartialShape` of descriptor can change it in undefined state with `Shape` property. - Improves tensor names handling for model outputs introduced in #23713 - Fix tensor names issue in `unroll_if` transformation (ticket: 114763) ### Tickets: - CVS-143105 - CVS-146649 - CVS-114763 ### Blocked by: - intel-innersource/frameworks.ai.openvino.tests#1684 - fixes e2e tests --------- Signed-off-by: Raasz, Pawel <[email protected]>
- Loading branch information
Showing
16 changed files
with
759 additions
and
217 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,92 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
#pragma once | ||
|
||
#include "openvino/core/descriptor/tensor.hpp" | ||
#include <memory> | ||
#include <unordered_set> | ||
|
||
#include "openvino/core/partial_shape.hpp" | ||
#include "openvino/core/type/element_type.hpp" | ||
|
||
namespace ov { | ||
namespace descriptor { | ||
|
||
class Tensor; | ||
class Input; | ||
class Output; | ||
|
||
// To change Tensor element type please change the Parameter type. | ||
OPENVINO_API | ||
void set_element_type(Tensor& tensor, const element::Type& elemenet_type); | ||
|
||
// To change Tensor type please change the Parameter type. | ||
OPENVINO_API | ||
void set_tensor_type(Tensor& tensor, const element::Type& element_type, const PartialShape& pshape); | ||
|
||
/** | ||
* @brief Set destination tensor names as copy of all names from source tensor all tensor names. | ||
* | ||
* @param dst The tensor descriptor to set names. | ||
* @param src The tensor descriptor as from which names will be copied. | ||
*/ | ||
OPENVINO_API | ||
void copy_tensor_names(Tensor& dst, const Tensor& src); | ||
|
||
/** @brief Tensor descriptor interface. */ | ||
class OPENVINO_API ITensorDescriptor { | ||
public: | ||
virtual const element::Type& get_element_type() const = 0; | ||
virtual const PartialShape& get_partial_shape() const = 0; | ||
virtual const Shape& get_shape() const = 0; | ||
virtual void set_type_shape(const element::Type& et, const PartialShape& shape) = 0; | ||
|
||
virtual void set_names(const std::unordered_set<std::string>& names) = 0; | ||
virtual void add_names(const std::unordered_set<std::string>& names) = 0; | ||
virtual const std::unordered_set<std::string>& get_names() const = 0; | ||
virtual const std::unordered_set<std::string>& get_all_names() const = 0; | ||
virtual const std::string& get_any_name() const = 0; | ||
|
||
virtual RTMap& rt_map() = 0; | ||
virtual const RTMap& rt_map() const = 0; | ||
virtual size_t pointer_hash() const noexcept = 0; | ||
|
||
protected: | ||
virtual ~ITensorDescriptor(); | ||
}; | ||
|
||
/** @brief The TensorExtension defines developer API for ov::descriptor::Tensor. */ | ||
struct OPENVINO_API TensorExtension { | ||
/** | ||
* @brief Get the tensor descriptor object | ||
* | ||
* @param tensor Tensor descriptor to access its implementation. | ||
* @return Reference to Tensor description implementation. | ||
*/ | ||
static const ITensorDescriptor& get_descriptor(const Tensor& tensor); | ||
static std::shared_ptr<ITensorDescriptor>& get_descriptor_ptr(Tensor& tensor); | ||
|
||
/** | ||
* @brief The hasher of shared pointer Tensor descriptor. | ||
*/ | ||
struct OPENVINO_API Hasher { | ||
size_t operator()(const std::shared_ptr<Tensor>& tensor) const; | ||
}; | ||
|
||
/** | ||
* @brief The comparator of shared pointer Tensor descriptor. | ||
*/ | ||
struct OPENVINO_API Equal { | ||
bool operator()(const std::shared_ptr<Tensor>& lhs, const std::shared_ptr<Tensor>& rhs) const; | ||
}; | ||
}; | ||
|
||
/** | ||
* @brief Set input descriptor as shared tensor on output descriptor. | ||
* | ||
* @param output_descriptor Descriptor to set shared tensor. | ||
* @param input_descriptor Input descriptor to set in output as shared tensor. | ||
*/ | ||
OPENVINO_API void set_shared_tensor(Output& output_descriptor, const Input& input_descriptor); | ||
} // namespace descriptor | ||
} // namespace ov |
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.