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>
static json write(const ngraph::Function&, 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)
{
......@@ -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)
{
string j = serialize(func, indent, true);
string j = ::serialize(func, indent, true);
cpio::Writer writer(out);
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
writer.close();
}
string
ngraph::serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
static string serialize(shared_ptr<ngraph::Function> func, size_t indent, bool binary_constant_data)
{
json j;
vector<json> functions;
......@@ -203,6 +204,11 @@ string
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)
{
std::stringstream ss;
......
......@@ -23,12 +23,36 @@
namespace ngraph
{
std::string serialize(std::shared_ptr<ngraph::Function>,
size_t indent = 0,
bool binary_constant_data = false);
void serialize(const std::string& path, std::shared_ptr<ngraph::Function>, size_t indent = 0);
void serialize(std::ostream& out, 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&);
// @brief Serialize a Function to a json string
// @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.
std::string serialize(std::shared_ptr<ngraph::Function> func, size_t indent = 0);
// @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