提交 3647c98b authored 作者: Virgile Andreani's avatar Virgile Andreani 提交者: Ricardo Vieira

Fix PERF102: useless calls to dict.items()

上级 223b739f
......@@ -478,7 +478,7 @@ def _check_inputs(
"""
destroyed_idx_list = []
destroy_map = node.op.destroy_map
for o_pos, i_pos_list in destroy_map.items():
for i_pos_list in destroy_map.values():
destroyed_idx_list.extend(i_pos_list)
destroyed_res_list = [node.inputs[i] for i in destroyed_idx_list]
......@@ -598,7 +598,7 @@ def _check_viewmap(fgraph, node, storage_map):
# TODO: make sure this is correct
# According to OB, duplicate inputs are rejected on build graph time
# if they cause problems. So if they are here it should be ok.
for key, val in good_alias.items():
for key in good_alias:
bad_alias.pop(key, None)
if bad_alias:
raise BadViewMap(node, oi, outstorage, list(bad_alias.values()))
......
......@@ -1380,9 +1380,9 @@ class ProfileStats:
items.sort(key=lambda a: a[1], reverse=True)
for idx, ((fgraph, node), node_outputs_size) in enumerate(items[:N]):
code = ["c"] * len(node.outputs)
for out, inp in node.op.destroy_map.items():
for out in node.op.destroy_map:
code[out] = "i"
for out, inp in node.op.view_map.items():
for out in node.op.view_map:
code[out] = "v"
shapes = str(fct_shapes[fgraph][node])
......
......@@ -182,7 +182,7 @@ def _build_droot_impact(destroy_handler):
root_destroyer = {} # root -> destroyer apply
for app in destroy_handler.destroyers:
for output_idx, input_idx_list in app.op.destroy_map.items():
for input_idx_list in app.op.destroy_map.values():
if len(input_idx_list) != 1:
raise NotImplementedError()
input_idx = input_idx_list[0]
......@@ -698,7 +698,7 @@ class DestroyHandler(Bookkeeper):
# keep track of clients that should run before the current Apply
root_clients = set_type()
# for each destroyed input...
for output_idx, input_idx_list in app.op.destroy_map.items():
for input_idx_list in app.op.destroy_map.values():
destroyed_idx = input_idx_list[0]
destroyed_variable = app.inputs[destroyed_idx]
root = droot[destroyed_variable]
......
......@@ -545,7 +545,7 @@ class Stack(UpdatingVM):
# Add the outputs that are needed for the in-place updates of the
# inputs in `self.update_vars`
output_subset = list(output_subset)
for inp, out in self.update_vars.items():
for out in self.update_vars.values():
out_idx = self.fgraph.outputs.index(out)
if out_idx not in output_subset:
output_subset.append(out_idx)
......
......@@ -528,7 +528,7 @@ def makeTester(
@pytest.mark.skipif(skip, reason="Skipped")
def test_bad_build(self):
for testname, inputs in self.bad_build.items():
for inputs in self.bad_build.values():
inputs = [copy(input) for input in inputs]
inputrs = [shared(input) for input in inputs]
with pytest.raises(Exception):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论