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
535125f8
Unverified
Commit
535125f8
authored
Feb 08, 2018
by
Jai Menon
Committed by
GitHub
Feb 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into jmenon/warnings
parents
4eb1f9ba
a01170fb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
10 deletions
+36
-10
visualize_tree.cpp
src/ngraph/pass/visualize_tree.cpp
+20
-3
serializer.cpp
src/ngraph/serializer.cpp
+12
-3
serialize.cpp
test/serialize.cpp
+4
-4
No files found.
src/ngraph/pass/visualize_tree.cpp
View file @
535125f8
...
@@ -66,12 +66,22 @@ std::string pass::VisualizeTree::get_attributes(shared_ptr<Node> node)
...
@@ -66,12 +66,22 @@ std::string pass::VisualizeTree::get_attributes(shared_ptr<Node> node)
stringstream
ss
;
stringstream
ss
;
if
(
node
->
is_parameter
())
if
(
node
->
is_parameter
())
{
{
ss
<<
" "
<<
node
->
get_name
()
<<
" [shape=box color=blue
]
\n
"
;
ss
<<
" "
<<
node
->
get_name
()
<<
" [shape=box color=blue"
;
}
}
else
else
{
{
ss
<<
" "
<<
node
->
get_name
()
<<
" [shape=ellipse color=black
]
\n
"
;
ss
<<
" "
<<
node
->
get_name
()
<<
" [shape=ellipse color=black"
;
}
}
ss
<<
" label=
\"
"
<<
node
->
get_name
();
if
(
std
::
getenv
(
"NGRAPH_VISUALIZE_TREE_OUTPUT_SHAPES"
)
!=
nullptr
)
{
ss
<<
" "
<<
vector_to_string
(
node
->
get_shape
());
}
ss
<<
"
\"
]
\n
"
;
return
ss
.
str
();
return
ss
.
str
();
}
}
...
@@ -88,7 +98,14 @@ void pass::VisualizeTree::render() const
...
@@ -88,7 +98,14 @@ void pass::VisualizeTree::render() const
out
.
close
();
out
.
close
();
stringstream
ss
;
stringstream
ss
;
ss
<<
"dot -Tpng "
<<
tmp_file
<<
" -o "
<<
m_name
;
const
char
*
format
=
std
::
getenv
(
"NGRAPH_VISUALIZE_TREE_OUTPUT_FORMAT"
);
if
(
!
format
)
{
format
=
"png"
;
}
ss
<<
"dot -T"
<<
format
<<
" "
<<
tmp_file
<<
" -o "
<<
m_name
;
auto
cmd
=
ss
.
str
();
auto
cmd
=
ss
.
str
();
auto
stream
=
popen
(
cmd
.
c_str
(),
"r"
);
auto
stream
=
popen
(
cmd
.
c_str
(),
"r"
);
pclose
(
stream
);
pclose
(
stream
);
...
...
src/ngraph/serializer.cpp
View file @
535125f8
...
@@ -225,11 +225,8 @@ shared_ptr<ngraph::Function> ngraph::deserialize(const string& s)
...
@@ -225,11 +225,8 @@ shared_ptr<ngraph::Function> ngraph::deserialize(const string& s)
for
(
json
func
:
js
)
for
(
json
func
:
js
)
{
{
shared_ptr
<
Function
>
f
=
read_function
(
func
,
function_map
);
shared_ptr
<
Function
>
f
=
read_function
(
func
,
function_map
);
if
(
rc
==
nullptr
)
{
rc
=
f
;
rc
=
f
;
}
}
}
return
rc
;
return
rc
;
}
}
...
@@ -772,6 +769,7 @@ static json write(const Node& n)
...
@@ -772,6 +769,7 @@ static json write(const Node& n)
// TODO Multiple outputs
// TODO Multiple outputs
json
inputs
=
json
::
array
();
json
inputs
=
json
::
array
();
json
outputs
=
json
::
array
();
json
outputs
=
json
::
array
();
for
(
const
descriptor
::
Input
&
input
:
n
.
get_inputs
())
for
(
const
descriptor
::
Input
&
input
:
n
.
get_inputs
())
{
{
inputs
.
push_back
(
input
.
get_output
().
get_node
()
->
get_name
());
inputs
.
push_back
(
input
.
get_output
().
get_node
()
->
get_name
());
...
@@ -780,9 +778,20 @@ static json write(const Node& n)
...
@@ -780,9 +778,20 @@ static json write(const Node& n)
{
{
outputs
.
push_back
(
n
.
get_output_tensor
(
i
).
get_name
());
outputs
.
push_back
(
n
.
get_output_tensor
(
i
).
get_name
());
}
}
node
[
"inputs"
]
=
inputs
;
node
[
"inputs"
]
=
inputs
;
node
[
"outputs"
]
=
outputs
;
node
[
"outputs"
]
=
outputs
;
if
(
std
::
getenv
(
"NGRAPH_SERIALIZER_OUTPUT_SHAPES"
)
!=
nullptr
)
{
json
output_shapes
=
json
::
array
();
for
(
size_t
i
=
0
;
i
<
n
.
get_output_size
();
++
i
)
{
output_shapes
.
push_back
(
n
.
get_output_shape
(
i
));
}
node
[
"output_shapes"
]
=
output_shapes
;
}
string
node_op
=
n
.
description
();
string
node_op
=
n
.
description
();
if
(
node_op
==
"Abs"
)
if
(
node_op
==
"Abs"
)
{
{
...
...
test/serialize.cpp
100644 → 100755
View file @
535125f8
...
@@ -65,7 +65,7 @@ TEST(serialize, main)
...
@@ -65,7 +65,7 @@ TEST(serialize, main)
istringstream
in
(
js
);
istringstream
in
(
js
);
shared_ptr
<
Function
>
sfunc
=
deserialize
(
in
);
shared_ptr
<
Function
>
sfunc
=
deserialize
(
in
);
// Now call
g
on some test vectors.
// Now call
h
on some test vectors.
auto
manager
=
runtime
::
Manager
::
get
(
"INTERPRETER"
);
auto
manager
=
runtime
::
Manager
::
get
(
"INTERPRETER"
);
auto
external
=
manager
->
compile
(
sfunc
);
auto
external
=
manager
->
compile
(
sfunc
);
auto
backend
=
manager
->
allocate_backend
();
auto
backend
=
manager
->
allocate_backend
();
...
@@ -80,13 +80,13 @@ TEST(serialize, main)
...
@@ -80,13 +80,13 @@ TEST(serialize, main)
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
cf
->
call
({
x
,
y
,
z
},
{
result
});
cf
->
call
({
x
,
y
,
z
},
{
result
});
EXPECT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
read_vector
<
float
>
(
result
));
EXPECT_EQ
((
vector
<
float
>
{
216
,
320
,
440
,
576
}),
read_vector
<
float
>
(
result
));
cf
->
call
({
y
,
x
,
z
},
{
result
});
cf
->
call
({
y
,
x
,
z
},
{
result
});
EXPECT_EQ
((
vector
<
float
>
{
54
,
80
,
110
,
144
}),
read_vector
<
float
>
(
result
));
EXPECT_EQ
((
vector
<
float
>
{
216
,
320
,
440
,
576
}),
read_vector
<
float
>
(
result
));
cf
->
call
({
x
,
z
,
y
},
{
result
});
cf
->
call
({
x
,
z
,
y
},
{
result
});
EXPECT_EQ
((
vector
<
float
>
{
50
,
72
,
98
,
128
}),
read_vector
<
float
>
(
result
));
EXPECT_EQ
((
vector
<
float
>
{
200
,
288
,
392
,
512
}),
read_vector
<
float
>
(
result
));
}
}
TEST
(
serialize
,
existing_models
)
TEST
(
serialize
,
existing_models
)
...
...
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