diff --git a/python/paddle/distributed/auto_parallel/process_group.py b/python/paddle/distributed/auto_parallel/process_group.py index 0fb05bfd93101e8e89d1ece3b78367c7b38c14a8..3ab96bb2a9be99b41c9c5381f706412ade14a3f3 100644 --- a/python/paddle/distributed/auto_parallel/process_group.py +++ b/python/paddle/distributed/auto_parallel/process_group.py @@ -109,7 +109,7 @@ class ProcessGroup: not self.is_instantiate() ), "Cannot add new ranks after instantiating the process group" self._ranks.extend(new_ranks) - self._ranks = sorted(list(set(self.ranks))) + self._ranks = sorted(set(self.ranks)) def local_rank(self, global_rank): if global_rank in self.ranks: diff --git a/python/paddle/distributed/auto_parallel/tuner/rule_based_tuner.py b/python/paddle/distributed/auto_parallel/tuner/rule_based_tuner.py index 6c74aac842dbf65b35d762b913cfb86fc2f682dd..e2713cea63aae66096296575d45ba98edde22c3d 100644 --- a/python/paddle/distributed/auto_parallel/tuner/rule_based_tuner.py +++ b/python/paddle/distributed/auto_parallel/tuner/rule_based_tuner.py @@ -750,7 +750,7 @@ class OperatorClusteringUtil: @staticmethod def get_ranks(seq): """Get rank array of the given seq by doubled algorithm.""" - ordered_seq = sorted(list(set(seq))) + ordered_seq = sorted(set(seq)) item_to_rank = {item: idx for idx, item in enumerate(ordered_seq)} inter_ranks = [item_to_rank[item] for item in seq] diff --git a/python/paddle/distributed/passes/auto_parallel_recompute.py b/python/paddle/distributed/passes/auto_parallel_recompute.py index a1fa73d8c3316ca016210887ad3930f95572c3a8..bd756ca6fde5e87a995926447e964421fbe1d9f6 100644 --- a/python/paddle/distributed/passes/auto_parallel_recompute.py +++ b/python/paddle/distributed/passes/auto_parallel_recompute.py @@ -99,7 +99,7 @@ class RecomputeState(ProgramStats): segments.append([segment_idx[0], segment_idx[-1] + 1]) self._checkpoints.extend(self.ops[segment_idx[-1]].output_arg_names) - for i in reversed(sorted(no_recompute_segments)): + for i in sorted(no_recompute_segments, reverse=True): assert i < len( segments ), "the no_recompute_segments idx [{}] should be lower the number of segment [{}]".format( diff --git a/python/paddle/hapi/dynamic_flops.py b/python/paddle/hapi/dynamic_flops.py index 461b744a5bb5de35163dcb33aa1ce59b119b31ce..89f5928c6a528d0695fd02c7fd1d6d3871fdf2f5 100644 --- a/python/paddle/hapi/dynamic_flops.py +++ b/python/paddle/hapi/dynamic_flops.py @@ -271,7 +271,7 @@ def dynamic_flops(model, inputs, custom_ops=None, print_detail=False): 'total_params', 'input_shape', 'output_shape', - }.issubset(set(list(m._buffers.keys()))): + }.issubset(set(m._buffers.keys())): total_ops += m.total_ops total_params += m.total_params @@ -292,7 +292,7 @@ def dynamic_flops(model, inputs, custom_ops=None, print_detail=False): 'total_params', 'input_shape', 'output_shape', - }.issubset(set(list(m._buffers.keys()))): + }.issubset(set(m._buffers.keys())): table.add_row( [ m.full_name(), diff --git a/python/paddle/jit/dy2static/ifelse_transformer.py b/python/paddle/jit/dy2static/ifelse_transformer.py index d752b9a9fb279517574a4e2786c2a8241e6bbe9e..2718d4ddd6bb3c27d924185366c88efc8b22a5aa 100644 --- a/python/paddle/jit/dy2static/ifelse_transformer.py +++ b/python/paddle/jit/dy2static/ifelse_transformer.py @@ -339,8 +339,8 @@ def transform_if_else(node, root): """ # TODO(liym27): Consider variable like `self.a` modified in if/else node. - return_name_ids = sorted(list(node.pd_scope.modified_vars())) - push_pop_ids = sorted(list(node.pd_scope.variadic_length_vars())) + return_name_ids = sorted(node.pd_scope.modified_vars()) + push_pop_ids = sorted(node.pd_scope.variadic_length_vars()) nonlocal_names = list(return_name_ids) nonlocal_names.sort() # NOTE: All var in return_name_ids should be in nonlocal_names. diff --git a/python/paddle/vision/datasets/cifar.py b/python/paddle/vision/datasets/cifar.py index 444aa361f180beb528e6487bd7067502bf047b12..80547614e282185bb6f58d1ed169505374e67bd0 100644 --- a/python/paddle/vision/datasets/cifar.py +++ b/python/paddle/vision/datasets/cifar.py @@ -157,7 +157,7 @@ class Cifar10(Dataset): each_item.name for each_item in f if self.flag in each_item.name ) - names = sorted(list(names)) + names = sorted(names) for name in names: batch = pickle.load(f.extractfile(name), encoding='bytes') diff --git a/tools/print_signatures.py b/tools/print_signatures.py index 2ae695c8fc74ff0d87f2784ba487d5c24387c890..094108845ef2f681910d61c6080d8cd7b73cfb4f 100644 --- a/tools/print_signatures.py +++ b/tools/print_signatures.py @@ -164,7 +164,7 @@ def get_all_api(root_path='paddle', attr="__all__"): ) return [ - (sorted(list(api_info['all_names']))[0], md5(api_info['docstring'])) + (sorted(api_info['all_names'])[0], md5(api_info['docstring'])) for api_info in api_info_dict.values() ] @@ -380,7 +380,7 @@ if __name__ == '__main__': for k, api_info in api_info_dict.items(): # 1. the shortest suggested_name may be renamed; # 2. some api's fullname is not accessable, the module name of it is overrided by the function with the same name; - api_name = sorted(list(api_info['all_names']))[0] + api_name = sorted(api_info['all_names'])[0] all_api_names_to_k[api_name] = k all_api_names_sorted = sorted(all_api_names_to_k.keys()) for api_name in all_api_names_sorted: