Skip to content

Commit eaad488

Browse files
committed
Fix test util
`torch_use_tf32_matmul` should reset to original setting when there is exception. Signed-off-by: Jay Gu <jagu@nvidia.com>
1 parent 05ac839 commit eaad488

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ def next_power_of_2(n: int):
219219
def torch_use_tf32_matmul():
220220
origin = torch.backends.cuda.matmul.fp32_precision
221221
torch.backends.cuda.matmul.fp32_precision = "tf32"
222-
yield
223-
torch.backends.cuda.matmul.fp32_precision = origin
222+
try:
223+
yield
224+
finally:
225+
torch.backends.cuda.matmul.fp32_precision = origin
224226

225227

226228
def get_compute_capability_major():

0 commit comments

Comments
 (0)