Skip to content

Commit

Permalink
Fix non determinism inside Serialization (#5743)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb Kazantaev authored May 24, 2021
1 parent e3b4037 commit 2f95d25
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,22 @@ void ngfunction_2_irv10(pugi::xml_node& netXml,
port.append_attribute("id").set_value(port_id++);
port.append_attribute("precision")
.set_value(get_precision_name(o.get_element_type()).c_str());

// Sort tensor names
const auto & tensor_names = o.get_tensor().get_names();
std::vector<std::string> vector_names(tensor_names.begin(), tensor_names.end());
sort(vector_names.begin(), vector_names.end());

std::string names;
for (const auto& name : o.get_tensor().get_names()) {
for (const auto& name : vector_names) {
if (!names.empty())
names += ", ";
names += ",";
names += escape_delim(name);
}
if (!names.empty()) {
port.append_attribute("names").set_value(names.c_str());
}

for (auto d : o.get_shape()) {
pugi::xml_node dim = port.append_child("dim");
dim.append_child(pugi::xml_node_type::node_pcdata)
Expand Down

0 comments on commit 2f95d25

Please sign in to comment.