Skip to content
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

Move api set_element_type() & set_tensor_type() from public to private #22645

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/common/transformations/include/ov_ops/type_relaxed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ class OPENVINO_API TypeRelaxedBase {
for (size_t i = 0; i < node.get_input_size(); ++i) {
auto origin_input_type = get_origin_input_type(i);
if (origin_input_type != element::undefined) {
OPENVINO_SUPPRESS_DEPRECATED_START
node.get_input_tensor(i).set_tensor_type(origin_input_type, node.get_input_partial_shape(i));
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_tensor_type(node.get_input_tensor(i),
origin_input_type,
node.get_input_partial_shape(i));
}
}
}

void restore_input_data_types(Node& node, const element::TypeVector& old_input_types) {
// Restore original input data types
for (size_t i = 0; i < node.get_input_size(); ++i) {
OPENVINO_SUPPRESS_DEPRECATED_START
node.get_input_tensor(i).set_tensor_type(old_input_types[i], node.get_input_partial_shape(i));
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_tensor_type(node.get_input_tensor(i),
old_input_types[i],
node.get_input_partial_shape(i));
}

if (m_original_output_data_types.empty()) {
Expand Down Expand Up @@ -161,9 +161,7 @@ class TemporaryReplaceOutputType {
TemporaryReplaceOutputType(Output<Node> output, element::Type tmp_type) : m_output(output) {
// save original element type in order to restore it in the destructor
orig_type = m_output.get_element_type();
OPENVINO_SUPPRESS_DEPRECATED_START
m_output.get_tensor().set_element_type(tmp_type);
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_element_type(m_output.get_tensor(), tmp_type);
}

/// Return the output port that was used in the constructor
Expand All @@ -173,9 +171,7 @@ class TemporaryReplaceOutputType {

/// Restores the original element type for the output
~TemporaryReplaceOutputType() {
OPENVINO_SUPPRESS_DEPRECATED_START
m_output.get_tensor().set_element_type(orig_type);
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_element_type(m_output.get_tensor(), orig_type);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ bool ov::pass::SymbolicPropagation::run_on_model(const std::shared_ptr<ov::Model
for (auto& output : op->outputs()) {
auto shape = output.get_partial_shape();
symbolic_set_up_for_shape(dt, shape);
OPENVINO_SUPPRESS_DEPRECATED_START
output.get_tensor().set_tensor_type(output.get_element_type(), shape);
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_tensor_type(output.get_tensor(), output.get_element_type(), shape);
}
}
return true;
Expand Down
14 changes: 8 additions & 6 deletions src/core/include/openvino/core/descriptor/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ OPENVINO_DEPRECATED("set_ov_tensor_legacy_name() is deprecated. Please don't use
OPENVINO_API
void set_ov_tensor_legacy_name(Tensor& tensor, const std::string& tensor_name);

// To change Tensor element type please change the Parameter type.
void set_element_type(Tensor& tensor, const element::Type& elemenet_type);

// To change Tensor type please change the Parameter type.
void set_tensor_type(Tensor& tensor, const element::Type& element_type, const PartialShape& pshape);

/// \brief Compile-time descriptor of a first-class value that is a tensor.
class OPENVINO_API Tensor {
public:
Expand All @@ -58,12 +64,6 @@ class OPENVINO_API Tensor {
void set_names(const std::unordered_set<std::string>& names);
void add_names(const std::unordered_set<std::string>& names);

OPENVINO_DEPRECATED("set_tensor_type() is deprecated. To change Tensor type please change the Parameter type")
void set_tensor_type(const element::Type& element_type, const PartialShape& pshape);
OPENVINO_DEPRECATED(
"set_element_type() is deprecated. To change Tensor element type please change the Parameter type")
void set_element_type(const element::Type& elemenet_type);

/// \brief sets lower bound value description
void set_lower_value(const ov::Tensor& value);
/// \brief sets upper bound value description
Expand Down Expand Up @@ -137,6 +137,8 @@ class OPENVINO_API Tensor {

friend OPENVINO_API std::string get_ov_tensor_legacy_name(const Tensor& tensor);
friend OPENVINO_API void set_ov_tensor_legacy_name(Tensor& tensor, const std::string& tensor_name);
friend void set_element_type(Tensor& tensor, const element::Type& elemenet_type);
friend void set_tensor_type(Tensor& tensor, const element::Type& element_type, const PartialShape& pshape);
friend class pass::ReverseShapeAndTypeInfer;
};

Expand Down
24 changes: 12 additions & 12 deletions src/core/src/descriptor/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ ov::descriptor::Tensor::Tensor(const element::Type& element_type,
m_name_it = m_names.cend();
}

OPENVINO_SUPPRESS_DEPRECATED_START
void ov::descriptor::Tensor::set_tensor_type(const element::Type& element_type, const PartialShape& pshape) {
set_element_type(element_type);
m_partial_shape = pshape;
m_shape_changed = true;
}

void ov::descriptor::Tensor::set_element_type(const element::Type& element_type) {
m_element_type = element_type;
}
OPENVINO_SUPPRESS_DEPRECATED_END

void ov::descriptor::Tensor::invalidate_values() {
if (ov::skip_invalidation(*this))
return;
Expand Down Expand Up @@ -153,6 +141,18 @@ void ov::descriptor::set_ov_tensor_legacy_name(ov::descriptor::Tensor& tensor, c
tensor.m_legacy_name = tensor_name;
}

void ov::descriptor::set_tensor_type(ov::descriptor::Tensor& tensor,
const element::Type& element_type,
const PartialShape& pshape) {
tensor.m_element_type = element_type;
tensor.m_partial_shape = pshape;
tensor.m_shape_changed = true;
}

void ov::descriptor::set_element_type(ov::descriptor::Tensor& tensor, const element::Type& element_type) {
tensor.m_element_type = element_type;
}

std::ostream& ov::descriptor::operator<<(std::ostream& out, const ov::descriptor::Tensor& tensor) {
std::string names;
for (const auto& name : tensor.get_names()) {
Expand Down
4 changes: 1 addition & 3 deletions src/core/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ void ov::Node::set_input_is_relevant_to_value(size_t i, bool relevant) {
}

void ov::Node::set_output_type(size_t i, const element::Type& element_type, const PartialShape& pshape) {
OPENVINO_SUPPRESS_DEPRECATED_START
get_output_descriptor(i).get_tensor_ptr()->set_tensor_type(element_type, pshape);
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_tensor_type(get_output_descriptor(i).get_tensor(), element_type, pshape);
}

std::string ov::Node::description() const {
Expand Down
8 changes: 2 additions & 6 deletions src/core/src/op/type_relaxed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ void convert_types(std::shared_ptr<v0::Parameter>& parameter,
auto& tensor = output.get_tensor();

if (lower_success || upper_success) {
OPENVINO_SUPPRESS_DEPRECATED_START
tensor.set_element_type(new_type); // deprecated piece
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_element_type(tensor, new_type);
}
if (lower_success)
tensor.set_lower_value(lower_tensor[0]);
Expand Down Expand Up @@ -115,9 +113,7 @@ void reset_input_types(const std::unordered_map<size_t, std::pair<ov::Tensor, ov
const auto& etype =
item.second.first ? item.second.first.get_element_type() : item.second.second.get_element_type();
auto& tensor = inputs[item.first].get_tensor();
OPENVINO_SUPPRESS_DEPRECATED_START
tensor.set_element_type(etype);
OPENVINO_SUPPRESS_DEPRECATED_END
ov::descriptor::set_element_type(tensor, etype);
if (item.second.first)
tensor.set_lower_value(item.second.first);
if (item.second.second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ void MemoryLSTMCellTest::SetUp() {
auto out_hidden = tensor_iterator->get_iter_value(H_o, -1);
auto out_cell = tensor_iterator->get_iter_value(C_o, -1);

out_hidden.get_tensor().set_element_type(element_type);
out_cell.get_tensor().set_element_type(element_type);

auto cell_memory_write = std::make_shared<ov::op::v6::Assign>(out_cell, var_cell);
auto hidden_memory_write = std::make_shared<ov::op::v6::Assign>(out_hidden, var_hidden);

Expand Down Expand Up @@ -271,9 +268,6 @@ void MemoryLSTMCellTest::create_pure_tensor_iterator_model() {
auto out_hidden = tensor_iterator->get_iter_value(H_o, -1);
auto out_cell = tensor_iterator->get_iter_value(C_o, -1);

out_hidden.get_tensor().set_element_type(element_type);
out_cell.get_tensor().set_element_type(element_type);

auto final_reshape_pattern =
std::make_shared<ov::op::v0::Constant>(element::i64, Shape{4}, std::vector<size_t>({1, 1, 1, hiddenSize}));
auto final_reshape = std::make_shared<ov::op::v1::Reshape>(out_unsqueeze, final_reshape_pattern, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ void MultipleLSTMCellTest::SetUp() {
auto out_hidden = tensor_iterator->get_iter_value(H_o, -1);
auto out_cell = tensor_iterator->get_iter_value(C_o, -1);

out_hidden.get_tensor().set_element_type(element_type);
out_cell.get_tensor().set_element_type(element_type);

auto cell_memory_write = std::make_shared<ov::op::v6::Assign>(out_cell, var_cell);
auto hidden_memory_write = std::make_shared<ov::op::v6::Assign>(out_hidden, var_hidden);

Expand Down Expand Up @@ -193,9 +190,6 @@ void MultipleLSTMCellTest::SetUp() {
auto out_hidden_2 = tensor_iterator_2->get_iter_value(H_o_2, -1);
auto out_cell_2 = tensor_iterator_2->get_iter_value(C_o_2, -1);

out_hidden_2.get_tensor().set_element_type(element_type);
out_cell_2.get_tensor().set_element_type(element_type);

auto cell_memory_2_write = std::make_shared<ov::op::v6::Assign>(out_cell_2, var_cell_2);
auto hidden_memory_2_write = std::make_shared<ov::op::v6::Assign>(out_hidden_2, var_hidden_2);

Expand Down Expand Up @@ -381,8 +375,6 @@ void MultipleLSTMCellTest::create_pure_tensor_iterator_model() {
auto out_hidden = tensor_iterator->get_iter_value(H_o, -1);
auto out_cell = tensor_iterator->get_iter_value(C_o, -1);

out_hidden.get_tensor().set_element_type(element_type);
out_cell.get_tensor().set_element_type(element_type);
tensor_iterator->validate_and_infer_types();

auto first_reshape_pattern =
Expand Down Expand Up @@ -444,8 +436,6 @@ void MultipleLSTMCellTest::create_pure_tensor_iterator_model() {
auto out_hidden_2 = tensor_iterator_2->get_iter_value(H_o_2, -1);
auto out_cell_2 = tensor_iterator_2->get_iter_value(C_o_2, -1);

out_hidden_2.get_tensor().set_element_type(element_type);
out_cell_2.get_tensor().set_element_type(element_type);
tensor_iterator_2->validate_and_infer_types();
auto final_reshape_pattern =
std::make_shared<ov::op::v0::Constant>(element::i64, Shape{4}, std::vector<size_t>({1, 1, 1, hiddenSize}));
Expand Down
Loading