Remove deprecated v0::Round op (#2905)

This commit is contained in:
Mateusz Tabaka
2020-11-02 04:47:35 +01:00
committed by GitHub
parent 3f35746c45
commit 557c83b64b
9 changed files with 31 additions and 76 deletions

View File

@@ -151,7 +151,6 @@ NGRAPH_OP(Reshape, ngraph::op::v1, 1)
NGRAPH_OP(Result, ngraph::op::v0, 0)
NGRAPH_OP(Reverse, ngraph::op::v1, 1)
NGRAPH_OP(ReverseSequence, ngraph::op::v0, 0)
NGRAPH_OP(Round, ngraph::op::v0, 0)
NGRAPH_OP(Round, ngraph::op::v5, 5)
NGRAPH_OP(ROIAlign, ngraph::op::v3, 3)
NGRAPH_OP(ScatterElementsUpdate, ngraph::op::v3, 3)

View File

@@ -24,39 +24,6 @@ namespace ngraph
{
namespace op
{
namespace v0
{
/// \brief Elementwise round operation.
class NGRAPH_DEPRECATED(
"This operation is deprecated and will be removed soon. Please do not use it.")
NGRAPH_API Round : public util::UnaryElementwiseArithmetic
{
NGRAPH_SUPPRESS_DEPRECATED_START
public:
static constexpr NodeTypeInfo type_info{"Round", 0};
const NodeTypeInfo& get_type_info() const override { return type_info; }
/// \brief Constructs a round operation.
Round() = default;
/// \brief Constructs a round operation. The output is round to the nearest integer
/// for each value. In case of halfs, the rule is to round them to the nearest even
/// integer.
///
/// \param arg Node that produces the input tensor.
Round(const Output<Node>& arg);
virtual std::shared_ptr<Node>
clone_with_new_inputs(const OutputVector& new_args) const override;
bool evaluate(const HostTensorVector& outputs,
const HostTensorVector& inputs) const override;
NGRAPH_SUPPRESS_DEPRECATED_END
};
}
NGRAPH_SUPPRESS_DEPRECATED_START
using v0::Round;
NGRAPH_SUPPRESS_DEPRECATED_END
namespace v5
{
/// \brief Elementwise round operation. The output is round to the nearest integer

View File

@@ -22,25 +22,9 @@
#include "ngraph/runtime/reference/copy.hpp"
#include "ngraph/runtime/reference/round.hpp"
NGRAPH_SUPPRESS_DEPRECATED_START
using namespace std;
using namespace ngraph;
constexpr NodeTypeInfo op::Round::type_info;
op::v0::Round::Round(const Output<Node>& arg)
: UnaryElementwiseArithmetic(arg)
{
constructor_validate_and_infer_types();
}
shared_ptr<Node> op::v0::Round::clone_with_new_inputs(const OutputVector& new_args) const
{
check_new_args_count(this, new_args);
return make_shared<v0::Round>(new_args.at(0));
}
namespace roundop
{
// function used by TYPE_CASE
@@ -104,16 +88,6 @@ namespace roundop
}
}
bool op::v0::Round::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const
{
OV_ITT_SCOPED_TASK(itt::domains::nGraphOp, "op::v0::Round::evaluate");
return roundop::evaluate_round(inputs[0],
outputs[0],
shape_size(get_output_shape(0)),
op::v5::Round::RoundMode::HALF_TO_EVEN);
}
NGRAPH_SUPPRESS_DEPRECATED_END
NGRAPH_RTTI_DEFINITION(op::v5::Round, "Round", 5);
op::v5::Round::Round(const Output<Node>& arg, RoundMode mode)

View File

@@ -35,7 +35,8 @@ NGRAPH_TEST(${BACKEND_NAME}, round)
{
Shape shape{5};
auto A = make_shared<op::Parameter>(element::f32, shape);
auto f = make_shared<Function>(make_shared<op::Round>(A), ParameterVector{A});
auto f = make_shared<Function>(
make_shared<op::v5::Round>(A, op::v5::Round::RoundMode::HALF_TO_EVEN), ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");
@@ -50,11 +51,33 @@ NGRAPH_TEST(${BACKEND_NAME}, round)
MIN_FLOAT_TOLERANCE_BITS));
}
NGRAPH_TEST(${BACKEND_NAME}, round_away_from_zero)
{
Shape shape{5};
auto A = make_shared<op::Parameter>(element::f32, shape);
auto f = make_shared<Function>(
make_shared<op::v5::Round>(A, op::v5::Round::RoundMode::HALF_AWAY_FROM_ZERO),
ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");
auto a = backend->create_tensor(element::f32, shape);
copy_data(a, vector<float>{0.9f, 2.5f, 2.3f, 1.5f, -4.5f});
auto result = backend->create_tensor(element::f32, shape);
auto handle = backend->compile(f);
handle->call_with_validate({result}, {a});
EXPECT_TRUE(test::all_close_f((vector<float>{1.0f, 3.0f, 2.0f, 2.0f, -5.0f}),
read_vector<float>(result),
MIN_FLOAT_TOLERANCE_BITS));
}
NGRAPH_TEST(${BACKEND_NAME}, round_2D)
{
Shape shape{3, 5};
auto A = make_shared<op::Parameter>(element::f32, shape);
auto f = make_shared<Function>(make_shared<op::Round>(A), ParameterVector{A});
auto f = make_shared<Function>(
make_shared<op::v5::Round>(A, op::v5::Round::RoundMode::HALF_TO_EVEN), ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");
@@ -91,7 +114,8 @@ NGRAPH_TEST(${BACKEND_NAME}, round_int64)
// This tests large numbers that will not fit in a double
Shape shape{3};
auto A = make_shared<op::Parameter>(element::i64, shape);
auto f = make_shared<Function>(make_shared<op::Round>(A), ParameterVector{A});
auto f = make_shared<Function>(
make_shared<op::v5::Round>(A, op::v5::Round::RoundMode::HALF_TO_EVEN), ParameterVector{A});
auto backend = runtime::Backend::create("${BACKEND_NAME}");

View File

@@ -884,7 +884,7 @@ TEST(eval, evaluate_relu_2Ffprop_i32)
TEST(eval, evaluate_round)
{
auto p = make_shared<op::Parameter>(element::f32, Shape{5});
auto round = make_shared<op::Round>(p);
auto round = make_shared<op::v5::Round>(p, op::v5::Round::RoundMode::HALF_TO_EVEN);
auto fun = make_shared<Function>(OutputVector{round}, ParameterVector{p});
auto result = make_shared<HostTensor>();
ASSERT_TRUE(fun->evaluate(
@@ -899,7 +899,7 @@ TEST(eval, evaluate_round)
TEST(eval, evaluate_round_2D)
{
auto p = make_shared<op::Parameter>(element::f32, Shape{3, 5});
auto round = make_shared<op::Round>(p);
auto round = make_shared<op::v5::Round>(p, op::v5::Round::RoundMode::HALF_TO_EVEN);
auto fun = make_shared<Function>(OutputVector{round}, ParameterVector{p});
auto result = make_shared<HostTensor>();
ASSERT_TRUE(fun->evaluate({result},

View File

@@ -688,7 +688,7 @@ namespace
void op_is_Round()
{
op::Round node;
op::v5::Round node;
EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node));
EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node));
EXPECT_FALSE(op::is_binary_elementwise_comparison(&node));

View File

@@ -587,6 +587,7 @@ abc_int64
# Unsupported primitive of type: Round
IE_CPU.onnx_model_round
IE_CPU.onnx_model_round_half_nearest_even
round_away_from_zero
# Unsupported primitive of type: SigmoidBackprop
sigmoid_bprop_n1c1h4

View File

@@ -1264,15 +1264,6 @@ protected:
}
break;
}
case OP_TYPEID::Round:
{
size_t element_count = shape_size(node.get_output_shape(0));
reference::round<T>(args[0]->get_data_ptr<const T>(),
out[0]->get_data_ptr<T>(),
element_count,
op::v5::Round::RoundMode::HALF_TO_EVEN);
break;
}
case OP_TYPEID::Select:
{
size_t element_count = shape_size(node.get_output_shape(0));

View File

@@ -112,7 +112,6 @@ NGRAPH_OP(Relu, ngraph::op)
NGRAPH_OP(Reshape, ngraph::op)
NGRAPH_OP(Result, ngraph::op)
NGRAPH_OP(ReverseSequence, ngraph::op)
NGRAPH_OP(Round, ngraph::op)
NGRAPH_OP(Select, ngraph::op)
NGRAPH_OP(Selu, ngraph::op)
NGRAPH_OP(ShapeOf, ngraph::op)