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

Commit

Permalink
remove internal function from external API and add some docs (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkimballn1 authored and jbobba committed Mar 28, 2018
1 parent a126968 commit ab8ab38
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/ngraph/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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()));

Expand All @@ -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;
Expand All @@ -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;
Expand Down
40 changes: 32 additions & 8 deletions src/ngraph/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit ab8ab38

Please sign in to comment.