Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit ab8ab38

Browse files
rkimballn1Jayaram Bobba
authored andcommitted
remove internal function from external API and add some docs (#774)
1 parent a126968 commit ab8ab38

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

src/ngraph/serializer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ static std::shared_ptr<ngraph::Function>
113113

114114
static json write(const ngraph::Function&, bool binary_constant_data);
115115
static json write(const ngraph::Node&, bool binary_constant_data);
116+
static string
117+
serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data);
116118

117119
static json write_element_type(const ngraph::element::Type& n)
118120
{
@@ -160,7 +162,7 @@ void ngraph::serialize(const string& path, shared_ptr<ngraph::Function> func, si
160162

161163
void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t indent)
162164
{
163-
string j = serialize(func, indent, true);
165+
string j = ::serialize(func, indent, true);
164166
cpio::Writer writer(out);
165167
writer.write(func->get_name(), j.c_str(), static_cast<uint32_t>(j.size()));
166168

@@ -178,8 +180,7 @@ void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t i
178180
writer.close();
179181
}
180182

181-
string
182-
ngraph::serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
183+
static string serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
183184
{
184185
json j;
185186
vector<json> functions;
@@ -203,6 +204,11 @@ string
203204
return rc;
204205
}
205206

207+
std::string ngraph::serialize(std::shared_ptr<ngraph::Function> func, size_t indent)
208+
{
209+
return ::serialize(func, indent, false);
210+
}
211+
206212
shared_ptr<ngraph::Function> ngraph::deserialize(istream& in)
207213
{
208214
std::stringstream ss;

src/ngraph/serializer.hpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,36 @@
2323

2424
namespace ngraph
2525
{
26-
std::string serialize(std::shared_ptr<ngraph::Function>,
27-
size_t indent = 0,
28-
bool binary_constant_data = false);
29-
void serialize(const std::string& path, std::shared_ptr<ngraph::Function>, size_t indent = 0);
30-
void serialize(std::ostream& out, std::shared_ptr<ngraph::Function>, size_t indent = 0);
31-
32-
std::shared_ptr<ngraph::Function> deserialize(std::istream&);
33-
std::shared_ptr<ngraph::Function> deserialize(const std::string&);
26+
// @brief Serialize a Function to a json string
27+
// @param func The Function to serialize
28+
// @param indent If 0 then there is no formatting applied and the resulting string is the
29+
// most compact representation. If non-zero then the json string is formatted with the
30+
// indent level specified.
31+
std::string serialize(std::shared_ptr<ngraph::Function> func, size_t indent = 0);
32+
33+
// @brief Serialize a Function to as a json file
34+
// @param path The path to the output file
35+
// @param func The Function to serialize
36+
// @param indent If 0 then there is no formatting applied and the resulting string is the
37+
// most compact representation. If non-zero then the json string is formatted with the
38+
// indent level specified.
39+
void serialize(const std::string& path,
40+
std::shared_ptr<ngraph::Function> func,
41+
size_t indent = 0);
42+
43+
// @brief Serialize a Function to a CPIO file with all constant data stored as binary
44+
// @param out The output stream to which the data is serialized.
45+
// @param func The Function to serialize
46+
// @param indent If 0 then there is no formatting applied and the json is the
47+
// most compact representation. If non-zero then the json is formatted with the
48+
// indent level specified.
49+
void serialize(std::ostream& out, std::shared_ptr<ngraph::Function> func, size_t indent = 0);
50+
51+
// @brief Deserialize a Function
52+
// @param in An isteam to the input data
53+
std::shared_ptr<ngraph::Function> deserialize(std::istream& in);
54+
55+
// @brief Deserialize a Function
56+
// @param str The json formatted string to deseriailze.
57+
std::shared_ptr<ngraph::Function> deserialize(const std::string& str);
3458
}

0 commit comments

Comments
 (0)