diff --git a/mindspore/ccsrc/utils/ordered_map.h b/mindspore/ccsrc/utils/ordered_map.h index 48aa36df31..56ae281dcf 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 f393ce74f2..8d2f7af15c 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(); }