Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
f784b0da
Unverified
Commit
f784b0da
authored
Feb 03, 2018
by
Robert Kimball
Committed by
GitHub
Feb 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add clone unit test (#442)
fix clone of function with multiple outputs
parent
034d0849
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
graph_util.cpp
src/ngraph/graph_util.cpp
+7
-3
util.cpp
test/util.cpp
+18
-0
No files found.
src/ngraph/graph_util.cpp
View file @
f784b0da
...
...
@@ -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_result
s
,
cloned_params
);
}
test/util.cpp
View file @
f784b0da
...
...
@@ -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
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment