Commit 5e7aacf1 authored by Ransford Hyman Jr's avatar Ransford Hyman Jr Committed by Scott Cyphers

Read provenance tags from serialized graph (#3106)

* Add provenance tag support

* Added support to clone the provenance tags to the clone nodes

* Style fix

* Addressed comments

* Guarded the provenance code properly

* Added missing header file

* style
parent 8980e2ea
...@@ -233,6 +233,11 @@ std::list<std::shared_ptr<ngraph::Node>> ...@@ -233,6 +233,11 @@ std::list<std::shared_ptr<ngraph::Node>>
// There is a friendly name for this node so copy it // There is a friendly name for this node so copy it
cloned_node->set_friendly_name(node->get_friendly_name()); cloned_node->set_friendly_name(node->get_friendly_name());
} }
for (auto tag : node->get_provenance_tags())
{
cloned_node->add_provenance_tag(tag);
}
node_map[node.get()] = cloned_node; node_map[node.get()] = cloned_node;
} }
} }
......
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
#include "ngraph/op/tan.hpp" #include "ngraph/op/tan.hpp"
#include "ngraph/op/tanh.hpp" #include "ngraph/op/tanh.hpp"
#include "ngraph/op/topk.hpp" #include "ngraph/op/topk.hpp"
#include "ngraph/provenance.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
...@@ -1789,6 +1790,14 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json& node_js) ...@@ -1789,6 +1790,14 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json& node_js)
{ {
node->set_friendly_name(node_name); node->set_friendly_name(node_name);
} }
if (ngraph::get_provenance_enabled())
{
std::vector<json> prov_js = node_js.at("provenance_tags");
for (auto prov_tag : prov_js)
{
node->add_provenance_tag(prov_tag);
}
}
m_node_map[node_name] = node; m_node_map[node_name] = node;
} }
catch (...) catch (...)
...@@ -1900,6 +1909,15 @@ json JSONSerializer::serialize_node(const Node& n) ...@@ -1900,6 +1909,15 @@ json JSONSerializer::serialize_node(const Node& n)
} }
node["output_shapes"] = output_shapes; node["output_shapes"] = output_shapes;
} }
if (ngraph::get_provenance_enabled())
{
json provenance_tags = json::array();
for (auto prov_tag : n.get_provenance_tags())
{
provenance_tags.push_back(prov_tag);
}
node["provenance_tags"] = provenance_tags;
}
string node_op = n.description(); string node_op = n.description();
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8)) #if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
......
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