Commit 8bbb172b authored by Nick Korovaiko's avatar Nick Korovaiko Committed by adstraw

Catch performance issues due to op::Result early on (#723)

* make sure we don't get insidious perf bugs due to doule op::Results
* fix graph_partition tests
parent a855a3ad
......@@ -14,6 +14,7 @@
* limitations under the License.
*******************************************************************************/
#include <algorithm>
#include <list>
#include <memory>
......@@ -50,6 +51,14 @@ Function::Function(const NodeVector& results,
, m_name(name)
, m_unique_name("Function_" + to_string(m_instance_id))
{
if (std::any_of(results.cbegin(), results.cend(), [](std::shared_ptr<Node> n) {
return std::dynamic_pointer_cast<op::Result>(n);
}))
{
throw ngraph_error(
" Results already contain op::Results. Use a c-tor that takes a ResultVector");
}
std::transform(results.begin(), results.end(), m_results.begin(), [](std::shared_ptr<Node> n) {
return std::make_shared<op::Result>(n);
});
......
......@@ -300,7 +300,7 @@ TEST(graph_partition, hybrid_abc_manual)
auto D = A + B;
auto E = D * C;
auto R = make_shared<op::Result>(E);
auto f = make_shared<Function>(R, op::ParameterVector{A, B, C});
auto f = make_shared<Function>(ResultVector{R}, op::ParameterVector{A, B, C});
pass::Manager pass_manager;
pass_manager.register_pass<pass::AssignPlacement>(int_with_cpu_mul_policy);
......@@ -392,7 +392,7 @@ TEST(graph_partition, hybrid_abc)
auto D = A + B;
auto E = D * C;
auto R = make_shared<op::Result>(E);
auto f = make_shared<Function>(R, op::ParameterVector{A, B, C});
auto f = make_shared<Function>(ResultVector{R}, op::ParameterVector{A, B, C});
pass::Manager pass_manager;
pass_manager.register_pass<pass::AssignPlacement>(int_with_cpu_mul_policy);
......
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