Remove deprecated util functions (#13417)

* Remove deprecated and not used functions:
- ngraph::is_valid_permutation
- ngraph::apply_permutation

* Use not blocking assertion in transpose test,
type prop
This commit is contained in:
Pawel Raasz 2022-10-12 08:23:26 +02:00 committed by GitHub
parent 660b309235
commit 988ed3b2f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 97 deletions

View File

@ -197,28 +197,6 @@ NGRAPH_API
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
size_t round_up(size_t size, size_t alignment);
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
bool is_valid_permutation(ngraph::AxisVector permutation, ngraph::Rank rank = Rank::dynamic());
template <typename T>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
T apply_permutation(T input, ngraph::AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
AxisVector apply_permutation<AxisVector>(AxisVector input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
Coordinate apply_permutation<Coordinate>(Coordinate input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon") Strides
apply_permutation<Strides>(Strides input, AxisVector order);
extern template NGRAPH_API NGRAPH_DEPRECATED("This method is deprecated and will be removed soon") Shape
apply_permutation<Shape>(Shape input, AxisVector order);
template <>
NGRAPH_DEPRECATED("This method is deprecated and will be removed soon")
NGRAPH_API PartialShape apply_permutation(PartialShape input, AxisVector order);
NGRAPH_API
AxisVector get_default_order(size_t rank);

View File

@ -212,74 +212,6 @@ std::ostream& operator<<(std::ostream& os, const ngraph::NodeVector& nv) {
return os;
}
bool ngraph::is_valid_permutation(ngraph::AxisVector permutation, ngraph::Rank rank) {
std::vector<bool> axis_occurs(permutation.size(), false);
// Check bounds if rank is static
if (rank.is_static()) {
auto bound = rank.get_length();
for (auto axis : permutation) {
if (static_cast<decltype(bound)>(axis) >= bound) {
return false;
}
}
}
for (auto& axis : permutation) {
axis_occurs[axis] = true;
}
for (size_t axis = 0; axis < permutation.size(); axis++) {
if (!axis_occurs[axis]) {
return false;
}
}
return (rank.is_dynamic() || static_cast<int64_t>(permutation.size()) == rank.get_length());
}
template <typename T>
T ngraph::apply_permutation(T input, AxisVector order) {
NGRAPH_CHECK(is_valid_permutation(order, input.size()), "Permutation ", order, " is not valid for ", input);
T output(input.size());
for (size_t i = 0; i < order.size(); i++) {
output[i] = input.at(order.at(i));
}
return output;
}
template AxisVector ngraph::apply_permutation<AxisVector>(AxisVector input, AxisVector order);
template Shape ngraph::apply_permutation<Shape>(Shape input, AxisVector order);
template ngraph::Coordinate ngraph::apply_permutation<ngraph::Coordinate>(ngraph::Coordinate input,
ngraph::AxisVector order);
template ngraph::CoordinateDiff ngraph::apply_permutation<ngraph::CoordinateDiff>(ngraph::CoordinateDiff input,
ngraph::AxisVector order);
template ngraph::Strides ngraph::apply_permutation<ngraph::Strides>(ngraph::Strides input, ngraph::AxisVector order);
namespace ngraph {
template <>
PartialShape apply_permutation(PartialShape input, AxisVector order) {
NGRAPH_CHECK(is_valid_permutation(order, input.rank()), "Permutation ", order, " is not valid for ", input);
// Here's the special part: if AxisVector is a viable permutation of _some_ rank, and input
// has dynamic rank, we just stick with dynamic rank.
if (input.rank().is_dynamic()) {
return input;
}
PartialShape output{PartialShape::dynamic(order.size())};
for (size_t i = 0; i < order.size(); i++) {
output[i] = input[order.at(i)];
}
return output;
}
} // namespace ngraph
AxisVector ngraph::get_default_order(const Shape& shape) {
return get_default_order(shape.size());
}

View File

@ -275,8 +275,8 @@ TEST(type_prop, transpose_order_as_parameter_shape) {
const auto r = make_shared<v1::Transpose>(arg, gather);
ASSERT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
ASSERT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape({Dimension(4, 16), 6, Dimension(2, 8)}));
EXPECT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
EXPECT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape({Dimension(4, 16), 6, Dimension(2, 8)}));
}
/** \brief Transpose with order as paramater shape dimensions after multiple transformations. */
@ -297,8 +297,8 @@ TEST(type_prop, transpose_order_as_parameter_shape_after_transformation) {
const auto r = make_shared<v1::Transpose>(arg, gather);
ASSERT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
ASSERT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape({6, Dimension(4, 16), Dimension(2, 8)}));
EXPECT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
EXPECT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape({6, Dimension(4, 16), Dimension(2, 8)}));
}
/**
@ -314,8 +314,8 @@ TEST(type_prop, transpose_when_order_is_shape_of_dynamic_partial_shape) {
const auto r = make_shared<v1::Transpose>(arg, shape_of);
ASSERT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
ASSERT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape::dynamic(3));
EXPECT_EQ(r->get_output_element_type(v1::Transpose::ARG_T), element::f32);
EXPECT_EQ(r->get_output_partial_shape(v1::Transpose::ARG_T), PartialShape::dynamic(3));
}
using transpose_prop_params = tuple<vector<int64_t>, // transpose order
@ -416,5 +416,5 @@ TEST_P(TransposeTest, propagate_labels) {
const auto order = op::Constant::create(element::i64, Shape{transpose_order.size()}, transpose_order);
const auto output = make_shared<op::Transpose>(input, order);
ASSERT_EQ(get_shape_labels(output->get_output_partial_shape(op::Transpose::ARG_T)), exp_labels);
EXPECT_EQ(get_shape_labels(output->get_output_partial_shape(op::Transpose::ARG_T)), exp_labels);
}