Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion torch_utils/ops/conv2d_gradfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import warnings
import contextlib
import torch
from distutils.version import LooseVersion

# pylint: disable=redefined-builtin
# pylint: disable=arguments-differ
Expand Down Expand Up @@ -50,7 +51,7 @@ def _should_use_custom_op(input):
return False
if input.device.type != 'cuda':
return False
if any(torch.__version__.startswith(x) for x in ['1.7.', '1.8.', '1.9']):
if LooseVersion(torch.__version__) >= LooseVersion('1.7.0'):
return True
warnings.warn(f'conv2d_gradfix not supported on PyTorch {torch.__version__}. Falling back to torch.nn.functional.conv2d().')
return False
Expand Down
3 changes: 2 additions & 1 deletion torch_utils/ops/grid_sample_gradfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import warnings
import torch
from distutils.version import LooseVersion

# pylint: disable=redefined-builtin
# pylint: disable=arguments-differ
Expand All @@ -34,7 +35,7 @@ def grid_sample(input, grid):
def _should_use_custom_op():
if not enabled:
return False
if any(torch.__version__.startswith(x) for x in ['1.7.', '1.8.', '1.9']):
if LooseVersion(torch.__version__) >= LooseVersion('1.7.0'):
return True
warnings.warn(f'grid_sample_gradfix not supported on PyTorch {torch.__version__}. Falling back to torch.nn.functional.grid_sample().')
return False
Expand Down