Unverified Commit 6b5a8f83 authored by daquexian's avatar daquexian Committed by GitHub
Browse files

lazy import torch._softmax_backward_data for better compatibility (#20796)



lazy import torch._softmax_backward_data
Signed-off-by: default avatardaquexian <daquexian566@gmail.com>
Signed-off-by: default avatardaquexian <daquexian566@gmail.com>
parent b4b613b1
...@@ -16,7 +16,7 @@ from typing import Callable, List, Optional, Set, Tuple, Union ...@@ -16,7 +16,7 @@ from typing import Callable, List, Optional, Set, Tuple, Union
import torch import torch
from packaging import version from packaging import version
from torch import _softmax_backward_data, nn from torch import nn
from .utils import logging from .utils import logging
...@@ -48,6 +48,8 @@ def softmax_backward_data(parent, grad_output, output, dim, self): ...@@ -48,6 +48,8 @@ def softmax_backward_data(parent, grad_output, output, dim, self):
to the torch version detected. to the torch version detected.
""" """
from torch import _softmax_backward_data
if is_torch_less_than_1_11: if is_torch_less_than_1_11:
return _softmax_backward_data(grad_output, output, parent.dim, self) return _softmax_backward_data(grad_output, output, parent.dim, self)
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment