Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit bcb169d

Browse files
authored
Fix for KeyError: 'Size' error (#194)
1 parent 2788fcc commit bcb169d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

torchbench.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,8 @@ def run_one_model(
11131113
cos_similarity=False,
11141114
skip_accuracy_check=False,
11151115
):
1116+
t0 = time.perf_counter()
1117+
11161118
tolerance = 1e-4
11171119
# Increase the tolerance for torch allclose
11181120
if is_training and current_device == "cuda" and name in REQUIRE_HIGHER_TOLERANCE:
@@ -1170,7 +1172,9 @@ def run_one_model(
11701172
frames_third_pass = 0
11711173

11721174
if output_filename and "coverage" in output_filename:
1173-
results.append(f"{ok:3}/{total:3} +{frames_third_pass} frames")
1175+
results.append(
1176+
f"{ok:3}/{total:3} +{frames_third_pass} frames {time.perf_counter()-t0:.0f}s"
1177+
)
11741178

11751179
results.append(experiment(model, example_inputs))
11761180
print(" ".join(map(str, results)))

torchdynamo/variables/lists.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,11 @@ def python_type(self):
236236
return torch.Size
237237

238238
def reconstruct(self, codegen):
239-
load_torch_size = [
240-
create_instruction("LOAD_GLOBAL", "torch"),
241-
create_instruction("LOAD_METHOD", "Size"),
242-
]
243-
codegen.extend_output(load_torch_size)
239+
codegen.load_import_from("torch", "Size")
244240
codegen.foreach(self.items)
245241
build_torch_size = [
246242
create_instruction("BUILD_TUPLE", len(self.items)),
247-
create_instruction("CALL_METHOD", 1),
243+
create_instruction("CALL_FUNCTION", 1),
248244
]
249245
return build_torch_size
250246

0 commit comments

Comments
 (0)