diff --git a/mindspore/ccsrc/utils/ordered_map.h b/mindspore/ccsrc/utils/ordered_map.h index 48aa36df31fec13b288a68a9edf99268663a5f34..56ae281dcf17b93034609f2f6bdd69390fe35458 100644 --- a/mindspore/ccsrc/utils/ordered_map.h +++ b/mindspore/ccsrc/utils/ordered_map.h @@ -88,7 +88,9 @@ class OrderedMap { } void clear() { - map_data_.clear(); + if (!map_data_.empty()) { + map_data_.clear(); + } sequential_data_.clear(); } diff --git a/mindspore/ccsrc/utils/ordered_set.h b/mindspore/ccsrc/utils/ordered_set.h index f393ce74f2e527767dd6d2c62edc26ebbcc7bcd1..8d2f7af15c3bcf95ea2f5fb6e8694a44f2e4d7fb 100644 --- a/mindspore/ccsrc/utils/ordered_set.h +++ b/mindspore/ccsrc/utils/ordered_set.h @@ -127,7 +127,9 @@ class OrderedSet { // Clear the elements void clear() { - mapped_data_.clear(); + if (!mapped_data_.empty()) { + mapped_data_.clear(); + } ordered_data_.clear(); }