forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into nashez/napi_tensor_continuous
- Loading branch information
Showing
26 changed files
with
1,020 additions
and
282 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.