Commit ab8ab385 authored by Robert Kimball's avatar Robert Kimball Committed by Jayaram Bobba

remove internal function from external API and add some docs (#774)

parent a1269685
...@@ -113,6 +113,8 @@ static std::shared_ptr<ngraph::Function> ...@@ -113,6 +113,8 @@ static std::shared_ptr<ngraph::Function>
static json write(const ngraph::Function&, bool binary_constant_data); static json write(const ngraph::Function&, bool binary_constant_data);
static json write(const ngraph::Node&, bool binary_constant_data); static json write(const ngraph::Node&, bool binary_constant_data);
static string
serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data);
static json write_element_type(const ngraph::element::Type& n) static json write_element_type(const ngraph::element::Type& n)
{ {
...@@ -160,7 +162,7 @@ void ngraph::serialize(const string& path, shared_ptr<ngraph::Function> func, si ...@@ -160,7 +162,7 @@ void ngraph::serialize(const string& path, shared_ptr<ngraph::Function> func, si
void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t indent) void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t indent)
{ {
string j = serialize(func, indent, true); string j = ::serialize(func, indent, true);
cpio::Writer writer(out); cpio::Writer writer(out);
writer.write(func->get_name(), j.c_str(), static_cast<uint32_t>(j.size())); writer.write(func->get_name(), j.c_str(), static_cast<uint32_t>(j.size()));
...@@ -178,8 +180,7 @@ void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t i ...@@ -178,8 +180,7 @@ void ngraph::serialize(ostream& out, shared_ptr<ngraph::Function> func, size_t i
writer.close(); writer.close();
} }
string static string serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
ngraph::serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
{ {
json j; json j;
vector<json> functions; vector<json> functions;
...@@ -203,6 +204,11 @@ string ...@@ -203,6 +204,11 @@ string
return rc; return rc;
} }
std::string ngraph::serialize(std::shared_ptr<ngraph::Function> func, size_t indent)
{
return ::serialize(func, indent, false);
}
shared_ptr<ngraph::Function> ngraph::deserialize(istream& in) shared_ptr<ngraph::Function> ngraph::deserialize(istream& in)
{ {
std::stringstream ss; std::stringstream ss;
......
...@@ -23,12 +23,36 @@ ...@@ -23,12 +23,36 @@
namespace ngraph namespace ngraph
{ {
std::string serialize(std::shared_ptr<ngraph::Function>, // @brief Serialize a Function to a json string
size_t indent = 0, // @param func The Function to serialize
bool binary_constant_data = false); // @param indent If 0 then there is no formatting applied and the resulting string is the
void serialize(const std::string& path, std::shared_ptr<ngraph::Function>, size_t indent = 0); // most compact representation. If non-zero then the json string is formatted with the
void serialize(std::ostream& out, std::shared_ptr<ngraph::Function>, size_t indent = 0); // indent level specified.
std::string serialize(std::shared_ptr<ngraph::Function> func, size_t indent = 0);
std::shared_ptr<ngraph::Function> deserialize(std::istream&);
std::shared_ptr<ngraph::Function> deserialize(const std::string&); // @brief Serialize a Function to as a json file
// @param path The path to the output file
// @param func The Function to serialize
// @param indent If 0 then there is no formatting applied and the resulting string is the
// most compact representation. If non-zero then the json string is formatted with the
// indent level specified.
void serialize(const std::string& path,
std::shared_ptr<ngraph::Function> func,
size_t indent = 0);
// @brief Serialize a Function to a CPIO file with all constant data stored as binary
// @param out The output stream to which the data is serialized.
// @param func The Function to serialize
// @param indent If 0 then there is no formatting applied and the json is the
// most compact representation. If non-zero then the json is formatted with the
// indent level specified.
void serialize(std::ostream& out, std::shared_ptr<ngraph::Function> func, size_t indent = 0);
// @brief Deserialize a Function
// @param in An isteam to the input data
std::shared_ptr<ngraph::Function> deserialize(std::istream& in);
// @brief Deserialize a Function
// @param str The json formatted string to deseriailze.
std::shared_ptr<ngraph::Function> deserialize(const std::string& str);
} }
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