Unverified Commit f784b0da authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

add clone unit test (#442)

fix clone of function with multiple outputs
parent 034d0849
......@@ -239,8 +239,12 @@ std::shared_ptr<ngraph::Function> ngraph::clone_function(std::shared_ptr<ngraph:
// clone function operations
clone_nodes(func->get_ops(), node_map);
// get cloned function result and parameters
auto cloned_result = node_map.get(func->get_result());
// get cloned function results and parameters
Nodes cloned_results;
for (shared_ptr<Node> node : func->get_results())
{
cloned_results.push_back(node_map.get(node));
}
std::vector<std::shared_ptr<op::Parameter>> cloned_params;
for (auto param : func->get_parameters())
{
......@@ -248,5 +252,5 @@ std::shared_ptr<ngraph::Function> ngraph::clone_function(std::shared_ptr<ngraph:
}
// create and return cloned function
return std::make_shared<ngraph::Function>(cloned_result, cloned_params);
return std::make_shared<ngraph::Function>(cloned_results, cloned_params);
}
......@@ -12,15 +12,18 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
#include "ngraph/file_util.hpp"
#include "ngraph/function.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/serializer.hpp"
#include "util/all_close.hpp"
#include "util/ndarray.hpp"
......@@ -313,6 +316,21 @@ TEST_F(CloneTest, clone_function_full)
ASSERT_TRUE(CompareNodes(func->get_ops(), cloned_func->get_ops(), node_map));
}
TEST(graph_util, clone_multiple_results)
{
auto shape = Shape{2, 2};
auto A = make_shared<op::Parameter>(element::f32, shape);
auto B = make_shared<op::Parameter>(element::f32, shape);
auto C = make_shared<op::Parameter>(element::f32, shape);
auto A_add_B = make_shared<op::Add>(A, B);
auto A_add_B_mul_C = make_shared<op::Multiply>(A_add_B, C);
auto f = make_shared<Function>(Nodes{A_add_B, A_add_B_mul_C}, op::Parameters{A, B, C});
NodeMap node_map;
auto copy = clone_function(f, node_map);
}
TEST(util, round_up)
{
EXPECT_EQ(0, round_up(0, 4));
......
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