Skip to content

Commit

Permalink
add the missing nullcontext to utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
max-andr authored Sep 23, 2021
1 parent 96d1a62 commit ceed494
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import torch
import torch.nn.functional as F
from torch import nn
from contextlib import contextmanager



logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -350,3 +352,10 @@ def backward(loss, opt, half_prec):
scaled_loss.backward()
else:
loss.backward()


@contextmanager
def nullcontext(enter_result=None):
yield enter_result


0 comments on commit ceed494

Please sign in to comment.