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
ff8a2008
Unverified
Commit
ff8a2008
authored
Dec 27, 2017
by
Robert Kimball
Committed by
GitHub
Dec 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ReplaceSlice serialization (#339)
parent
69a6fb09
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
serializer.cpp
src/ngraph/serializer.cpp
+24
-3
serializer.hpp
src/ngraph/serializer.hpp
+1
-0
No files found.
src/ngraph/serializer.cpp
View file @
ff8a2008
...
...
@@ -45,6 +45,7 @@
#include "ngraph/ops/power.hpp"
#include "ngraph/ops/reduce.hpp"
#include "ngraph/ops/remainder.hpp"
#include "ngraph/ops/replace_slice.hpp"
#include "ngraph/ops/reshape.hpp"
#include "ngraph/ops/select.hpp"
#include "ngraph/ops/sign.hpp"
...
...
@@ -68,7 +69,6 @@ static std::shared_ptr<ngraph::Function>
static
json
write
(
const
ngraph
::
Function
&
);
static
json
write
(
const
ngraph
::
Node
&
);
static
json
write
(
const
ngraph
::
element
::
Type
&
);
// This stupidity is caused by the fact that we do not pass element types
// by value but by reference even though they can be compared. There is no reason to pass
...
...
@@ -250,9 +250,15 @@ string ngraph::serialize(shared_ptr<ngraph::Function> func, size_t indent)
shared_ptr
<
ngraph
::
Function
>
ngraph
::
deserialize
(
istream
&
in
)
{
json
js
=
json
::
array
();
std
::
stringstream
ss
;
ss
<<
in
.
rdbuf
();
return
deserialize
(
ss
.
str
());
}
shared_ptr
<
ngraph
::
Function
>
ngraph
::
deserialize
(
const
string
&
s
)
{
json
js
=
json
::
parse
(
s
);
shared_ptr
<
Function
>
rc
;
in
>>
js
;
unordered_map
<
string
,
shared_ptr
<
Function
>>
function_map
;
for
(
json
func
:
js
)
{
...
...
@@ -492,6 +498,14 @@ static shared_ptr<ngraph::Function>
{
node
=
make_shared
<
op
::
Remainder
>
(
args
[
0
],
args
[
1
]);
}
else
if
(
node_op
==
"ReplaceSlice"
)
{
auto
lower_bounds
=
node_js
.
at
(
"lower_bounds"
).
get
<
vector
<
size_t
>>
();
auto
upper_bounds
=
node_js
.
at
(
"upper_bounds"
).
get
<
vector
<
size_t
>>
();
auto
strides
=
node_js
.
at
(
"strides"
).
get
<
vector
<
size_t
>>
();
node
=
make_shared
<
op
::
ReplaceSlice
>
(
args
[
0
],
args
[
1
],
lower_bounds
,
upper_bounds
,
strides
);
}
else
if
(
node_op
==
"Reshape"
)
{
auto
input_order
=
node_js
.
at
(
"input_order"
).
get
<
vector
<
size_t
>>
();
...
...
@@ -699,6 +713,13 @@ static json write(const Node& n)
else
if
(
node_op
==
"Remainder"
)
{
}
else
if
(
node_op
==
"ReplaceSlice"
)
{
auto
tmp
=
dynamic_cast
<
const
op
::
ReplaceSlice
*>
(
&
n
);
node
[
"lower_bounds"
]
=
tmp
->
get_lower_bounds
();
node
[
"upper_bounds"
]
=
tmp
->
get_upper_bounds
();
node
[
"strides"
]
=
tmp
->
get_strides
();
}
else
if
(
node_op
==
"Reshape"
)
{
auto
tmp
=
dynamic_cast
<
const
op
::
Reshape
*>
(
&
n
);
...
...
src/ngraph/serializer.hpp
View file @
ff8a2008
...
...
@@ -25,4 +25,5 @@ namespace ngraph
{
std
::
string
serialize
(
std
::
shared_ptr
<
ngraph
::
Function
>
,
size_t
indent
=
0
);
std
::
shared_ptr
<
ngraph
::
Function
>
deserialize
(
std
::
istream
&
);
std
::
shared_ptr
<
ngraph
::
Function
>
deserialize
(
const
std
::
string
&
);
}
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