Fix non determinism inside Serialization (#5743)

This commit is contained in:
Gleb Kazantaev 2021-05-24 10:56:33 +03:00 committed by GitHub
parent e3b4037b69
commit 2f95d25205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -753,8 +753,14 @@ 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 += escape_delim(name);
@ -762,6 +768,7 @@ void ngfunction_2_irv10(pugi::xml_node& netXml,
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)