Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
  • Loading branch information
zhaixuejun1993 committed Feb 5, 2024
1 parent 4b3acb2 commit bee4417
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 25 deletions.
8 changes: 0 additions & 8 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,15 @@ 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
}
}
}

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
}

if (m_original_output_data_types.empty()) {
Expand Down Expand Up @@ -161,9 +157,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
}

/// Return the output port that was used in the constructor
Expand All @@ -173,9 +167,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
}
};

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
}
}
return true;
Expand Down
11 changes: 6 additions & 5 deletions src/core/include/openvino/core/descriptor/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ using TensorLabelVector = std::vector<TensorLabel>;
namespace pass {
class ReverseShapeAndTypeInfer;
class SymbolicPropagation;
}
} // namespace pass

namespace op {
class TypeRelaxedBase;
class TemporaryReplaceOutputType;

std::unordered_map<size_t, std::pair<ov::Tensor, ov::Tensor>> OPENVINO_API
convert_input_types(OutputVector& inputs, const element::TypeVector& types);

void OPENVINO_API
reset_input_types(const std::unordered_map<size_t, std::pair<ov::Tensor, ov::Tensor>>& original_input_vals,
OutputVector& inputs);
}
} // namespace op

namespace descriptor {

Expand Down Expand Up @@ -114,11 +116,10 @@ class OPENVINO_API Tensor {
void clone_from(const Tensor& old);

private:
OPENVINO_DEPRECATED(
"set_element_type() is deprecated. To change Tensor element type please change the Parameter type")
// set_element_type() is private func. To change Tensor element type please change the Parameter type.
void set_element_type(const element::Type& elemenet_type);

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

protected:
Expand Down
2 changes: 0 additions & 2 deletions src/core/src/descriptor/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +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;
Expand All @@ -44,7 +43,6 @@ void ov::descriptor::Tensor::set_tensor_type(const element::Type& element_type,
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))
Expand Down
2 changes: 0 additions & 2 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
}

std::string ov::Node::description() const {
Expand Down
7 changes: 1 addition & 6 deletions src/core/src/op/type_relaxed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ std::unordered_map<size_t, std::pair<ov::Tensor, ov::Tensor>> convert_input_type
parameter = std::make_shared<op::v0::Parameter>(element::undefined, PartialShape());
convert = std::make_shared<ov::op::v0::Convert>(parameter, element::undefined);
}
// ov::op::convert_types(parameter, convert, input, original_type);
{
parameter->set_element_type(input.get_element_type());
parameter->set_partial_shape(input.get_shape());
Expand All @@ -69,9 +68,7 @@ std::unordered_map<size_t, std::pair<ov::Tensor, ov::Tensor>> convert_input_type
auto& tensor = input.get_tensor();

if (lower_success || upper_success) {
OPENVINO_SUPPRESS_DEPRECATED_START
tensor.set_element_type(original_type); // deprecated piece
OPENVINO_SUPPRESS_DEPRECATED_END
tensor.set_element_type(original_type);
}
if (lower_success)
tensor.set_lower_value(lower_tensor[0]);
Expand Down Expand Up @@ -111,9 +108,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
if (item.second.first)
tensor.set_lower_value(item.second.first);
if (item.second.second)
Expand Down

0 comments on commit bee4417

Please sign in to comment.