Unverified Commit 111ed897 authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Better performance for graph.huge test. More robust Function validation (#4490)

* Better performance for graph.huge test. More robust Function validation

* Fix parameter replace in unit test
Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
parent 870ef868
......@@ -81,14 +81,8 @@ void Function::validate_nodes_and_infer_types()
for (auto& node : get_ordered_ops())
{
node->revalidate_and_infer_types();
}
}
void Function::init()
{
validate_nodes_and_infer_types();
traverse_nodes(this, [&](shared_ptr<Node> node) {
// If we find a parameter make sure it is in the list of parameters of the function
if (node->is_parameter())
{
auto it = std::find(m_parameters.begin(), m_parameters.end(), node);
......@@ -97,7 +91,12 @@ void Function::init()
throw ngraph_error("Function references undeclared parameter");
}
}
});
}
}
void Function::init()
{
validate_nodes_and_infer_types();
}
std::vector<shared_ptr<Node>> Function::get_ordered_ops() const
......
......@@ -176,9 +176,11 @@ TEST(build_graph, multi_output_split_dynamic)
auto abs = make_shared<op::Abs>(split->output(1));
EXPECT_TRUE(abs->get_output_partial_shape(0).same_scheme(PartialShape::dynamic()));
auto f = make_shared<Function>(abs, ParameterVector{data});
auto new_parameter = make_shared<op::Parameter>(element::f32, Shape{2, 4});
split->input(0).replace_source_output(new_parameter->output(0));
auto f = make_shared<Function>(abs, ParameterVector{new_parameter});
f->validate_nodes_and_infer_types();
EXPECT_EQ(abs->get_shape(), (Shape{2, 2}));
}
......
......@@ -545,13 +545,13 @@ TEST(graph, huge)
{
auto param = make_shared<op::Parameter>(element::f32, Shape{3, 3});
std::shared_ptr<Node> n = param;
weak_nodes.push_back(n);
for (size_t i = 0; i < 1000000; i++)
{
n = make_shared<op::Negative>(n);
weak_nodes.push_back(n);
}
auto f = make_shared<Function>(NodeVector{n}, ParameterVector{param});
f->map_unordered_ops(
[&weak_nodes](Node* node) { weak_nodes.push_back(node->shared_from_this()); });
}
for (auto& weak_node : weak_nodes)
......
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