未验证 提交 1f8e6ad6 编写于 作者: I Infinity_lee 提交者: GitHub

[CodeStyle][C404] Unnecessary list comprehension (rewrite as a dict comprehension) (#51969)

上级 9796980c
......@@ -1790,7 +1790,7 @@ def group_param(sharding_info, fuse_size):
class ShardingInfo:
def __init__(self, group, rank, params_grads, partition_algor):
self.group = group
self.params_grads = dict([(p.name, (p, g)) for p, g in params_grads])
self.params_grads = {p.name: (p, g) for p, g in params_grads}
assert len(self.params_grads) == len(
set(self.params_grads)
), "found duplicated param in params_grads"
......
......@@ -231,9 +231,7 @@ def run_model(use_distributed_lamb, use_fp16, use_master_param_norm, **kwargs):
def reader():
for _ in range(6):
yield dict(
[(grad.name, gen_random_grad_tensor(grad)) for grad in grads]
)
yield {grad.name: gen_random_grad_tensor(grad) for grad in grads}
scope = paddle.static.Scope()
fetch_list = params
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册