Commit 33c74139 authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Scott Cyphers

Added missing attribute to Result serialization (#3037)

* Added missing attribute to Result serialization

* Fix default layout attribute

* use helper routine for optional attrs
parent 250dddbc
......@@ -24,8 +24,9 @@
using namespace std;
using namespace ngraph;
op::Result::Result(const shared_ptr<Node>& arg)
op::Result::Result(const shared_ptr<Node>& arg, bool needs_default_layout)
: Op("Result", check_single_output_args({arg}))
, m_needs_default_layout(needs_default_layout)
{
constructor_validate_and_infer_types();
// always borrow the placement conf even the default one
......@@ -44,11 +45,7 @@ shared_ptr<Node> op::Result::copy_with_new_args(const NodeVector& new_args) cons
{
check_new_args_count(this, new_args);
auto res = make_shared<Result>(new_args.at(0));
if (res)
{
res->set_needs_default_layout(m_needs_default_layout);
}
auto res = make_shared<Result>(new_args.at(0), m_needs_default_layout);
return std::move(res);
}
......
......@@ -30,7 +30,7 @@ namespace ngraph
/// \brief Allows a value to be used as a function result.
///
/// \param arg Node that produces the input tensor.
Result(const std::shared_ptr<Node>& arg);
Result(const std::shared_ptr<Node>& arg, bool needs_default_layout = false);
void validate_and_infer_types() override;
......
......@@ -1417,7 +1417,9 @@ static shared_ptr<ngraph::Function>
}
case OP_TYPEID::Result:
{
node = make_shared<op::Result>(args[0]);
auto needs_default_layout =
get_or_default<bool>(node_js, "needs_default_layout", false);
node = make_shared<op::Result>(args[0], needs_default_layout);
break;
}
case OP_TYPEID::Reverse:
......@@ -2341,7 +2343,11 @@ static json write(const Node& n, bool binary_constant_data)
node["output_shape"] = tmp->get_output_shape();
break;
}
case OP_TYPEID::Result: { break;
case OP_TYPEID::Result:
{
auto tmp = dynamic_cast<const op::Result*>(&n);
node["needs_default_layout"] = tmp->needs_default_layout();
break;
}
case OP_TYPEID::Reverse:
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment