[nGraph] Remove obsolete attribute from Result op (#7682)

* Remove obsolete attribute from Result op

m_needs_default_layout field had no effect to the Result operator state,
even if set to true* by build_graph test.
Its setter and getter were unused.

* rather accidentaly considering implicit cast from const char*

* Restore redundant ctor as deprecated

It's user API so better keep it backward compatible

* Restore useless accessors as deprecated
This commit is contained in:
Tomasz Jankowski 2021-10-04 06:24:02 +02:00 committed by GitHub
parent 3d5c163c3d
commit 96519b1723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 21 deletions

View File

@ -19,25 +19,26 @@ public:
/// \brief Allows a value to be used as a function result. /// \brief Allows a value to be used as a function result.
/// ///
/// \param arg Node that produces the input tensor. /// \param arg Node that produces the input tensor.
Result(const Output<Node>& arg, bool needs_default_layout = false); Result(const Output<Node>& arg);
OPENVINO_DEPRECATED("This constructor is redundant, use Result(const Output<Node>& arg) instead.")
Result(const Output<Node>& arg, bool);
bool visit_attributes(AttributeVisitor& visitor) override; bool visit_attributes(AttributeVisitor& visitor) override;
void validate_and_infer_types() override; void validate_and_infer_types() override;
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;
void set_needs_default_layout(bool val) { OPENVINO_DEPRECATED("This method provides no usage and has no replacement.")
m_needs_default_layout = val; void set_needs_default_layout(bool) {}
} OPENVINO_DEPRECATED("This method provides no usage and has no replacement.")
bool needs_default_layout() const { bool needs_default_layout() const {
return m_needs_default_layout; return false;
} }
bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override;
bool has_evaluate() const override; bool has_evaluate() const override;
bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override;
private:
bool m_needs_default_layout{false};
}; };
} // namespace v0 } // namespace v0
} // namespace op } // namespace op

View File

@ -17,9 +17,11 @@ using namespace ngraph;
BWDCMP_RTTI_DEFINITION(op::v0::Result); BWDCMP_RTTI_DEFINITION(op::v0::Result);
op::Result::Result(const Output<Node>& arg, bool needs_default_layout) op::Result::Result(const Output<Node>& arg) : Op({arg}) {
: Op({arg}), constructor_validate_and_infer_types();
m_needs_default_layout(needs_default_layout) { }
op::Result::Result(const Output<Node>& arg, bool) : Op({arg}) {
constructor_validate_and_infer_types(); constructor_validate_and_infer_types();
} }
@ -42,7 +44,7 @@ shared_ptr<Node> op::Result::clone_with_new_inputs(const OutputVector& new_args)
NGRAPH_OP_SCOPE(v0_Result_clone_with_new_inputs); NGRAPH_OP_SCOPE(v0_Result_clone_with_new_inputs);
check_new_args_count(this, new_args); check_new_args_count(this, new_args);
auto res = make_shared<Result>(new_args.at(0), m_needs_default_layout); auto res = make_shared<Result>(new_args.at(0));
return std::move(res); return std::move(res);
} }

View File

@ -288,7 +288,7 @@ TEST(build_graph, build_graph_with_add_result) {
auto res = make_shared<op::Result>(pattern); auto res = make_shared<op::Result>(pattern);
const auto axis = op::Constant::create(element::i64, Shape{}, {1}); const auto axis = op::Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<op::v1::Split>(pattern, axis, 3); auto crop = make_shared<op::v1::Split>(pattern, axis, 3);
auto res2 = make_shared<op::Result>(crop, "v0"); auto res2 = make_shared<op::Result>(crop);
auto f = make_shared<Function>(ResultVector({res}), ParameterVector{arg}); auto f = make_shared<Function>(ResultVector({res}), ParameterVector{arg});
@ -314,7 +314,7 @@ TEST(build_graph, build_graph_with_remove_result) {
auto res = make_shared<op::Result>(pattern); auto res = make_shared<op::Result>(pattern);
const auto axis = op::Constant::create(element::i64, Shape{}, {1}); const auto axis = op::Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<op::v1::Split>(pattern, axis, 3); auto crop = make_shared<op::v1::Split>(pattern, axis, 3);
auto res2 = make_shared<op::Result>(crop, "v0"); auto res2 = make_shared<op::Result>(crop);
auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg}); auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg});
@ -340,7 +340,7 @@ TEST(build_graph, build_graph_with_add_parameter) {
auto res = make_shared<op::Result>(pattern); auto res = make_shared<op::Result>(pattern);
const auto axis = op::Constant::create(element::i64, Shape{}, {1}); const auto axis = op::Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<op::v1::Split>(pattern, axis, 3); auto crop = make_shared<op::v1::Split>(pattern, axis, 3);
auto res2 = make_shared<op::Result>(crop, "v0"); auto res2 = make_shared<op::Result>(crop);
auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg}); auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg});
@ -369,7 +369,7 @@ TEST(build_graph, build_graph_with_remove_parameter) {
auto res = make_shared<op::Result>(pattern); auto res = make_shared<op::Result>(pattern);
const auto axis = op::Constant::create(element::i64, Shape{}, {1}); const auto axis = op::Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<op::v1::Split>(pattern, axis, 3); auto crop = make_shared<op::v1::Split>(pattern, axis, 3);
auto res2 = make_shared<op::Result>(crop, "v0"); auto res2 = make_shared<op::Result>(crop);
auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg, arg2}); auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg, arg2});
@ -398,7 +398,7 @@ TEST(build_graph, build_graph_with_remove_parameter_indexing) {
auto res = make_shared<op::Result>(pattern); auto res = make_shared<op::Result>(pattern);
const auto axis = op::Constant::create(element::i64, Shape{}, {1}); const auto axis = op::Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<op::v1::Split>(pattern, axis, 3); auto crop = make_shared<op::v1::Split>(pattern, axis, 3);
auto res2 = make_shared<op::Result>(crop, "v0"); auto res2 = make_shared<op::Result>(crop);
auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg2, arg}); auto f = make_shared<Function>(ResultVector({res, res2}), ParameterVector{arg2, arg});
@ -449,7 +449,7 @@ TEST(build_graph, build_graph_parameters_variables_autodetection) {
auto res = make_shared<Result>(pattern); auto res = make_shared<Result>(pattern);
const auto axis = Constant::create(element::i64, Shape{}, {1}); const auto axis = Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<Split>(pattern, axis, 3); auto crop = make_shared<Split>(pattern, axis, 3);
auto res2 = make_shared<Result>(crop, "v0"); auto res2 = make_shared<Result>(crop);
auto f = make_shared<Function>(OutputVector{res, res2}, SinkVector{assign}); auto f = make_shared<Function>(OutputVector{res, res2}, SinkVector{assign});
@ -477,7 +477,7 @@ TEST(build_graph, build_graph_variables_ctors) {
auto res = make_shared<Result>(pattern); auto res = make_shared<Result>(pattern);
const auto axis = Constant::create(element::i64, Shape{}, {1}); const auto axis = Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<Split>(pattern, axis, 3); auto crop = make_shared<Split>(pattern, axis, 3);
auto res2 = make_shared<Result>(crop, "v0"); auto res2 = make_shared<Result>(crop);
{ {
auto f = make_shared<Function>(OutputVector{res, res2}, auto f = make_shared<Function>(OutputVector{res, res2},
@ -524,10 +524,10 @@ TEST(build_graph, build_graph_unregistred_variables) {
auto res = make_shared<Result>(pattern); auto res = make_shared<Result>(pattern);
const auto axis = Constant::create(element::i64, Shape{}, {1}); const auto axis = Constant::create(element::i64, Shape{}, {1});
auto crop = make_shared<Split>(pattern, axis, 3); auto crop = make_shared<Split>(pattern, axis, 3);
auto res2 = make_shared<Result>(crop, "v0"); auto res2 = make_shared<Result>(crop);
EXPECT_ANY_THROW(make_shared<Function>(OutputVector{res, res2}, EXPECT_ANY_THROW(make_shared<Function>(OutputVector{res, res2},
SinkVector{assign, assign_2}, SinkVector{assign, assign_2},
ParameterVector{arg, arg2}, ParameterVector{arg, arg2},
VariableVector{variable})); VariableVector{variable}));
} }