Unverified Commit 1cc3bc22 authored by Huazhong Ji's avatar Huazhong Ji Committed by GitHub
Browse files

nn.Identity is not required to be compatible with PyTorch < 1.1.0 as the...

nn.Identity is not required to be compatible with PyTorch < 1.1.0 as the minimum PyTorch version we currently support is 1.10.0 (#25974)

nn.Identity is not required to be compatible with PyTorch < 1.1.0 as the
minimum PyTorch version we currently support is 1.10.0
parent fbbe1b8a
......@@ -31,7 +31,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
from packaging import version
from torch import Tensor, nn
from torch.nn import CrossEntropyLoss
from torch.nn import CrossEntropyLoss, Identity
from .activations import get_activation
from .configuration_utils import PretrainedConfig
......@@ -151,20 +151,6 @@ def no_init_weights(_enable=True):
_init_weights = old_init_weights
try:
from torch.nn import Identity
except ImportError:
# Older PyTorch compatibility
class Identity(nn.Module):
r"""A placeholder identity operator that is argument-insensitive."""
def __init__(self, *args, **kwargs):
super().__init__()
def forward(self, input):
return input
def get_parameter_device(parameter: Union[nn.Module, GenerationMixin, "ModuleUtilsMixin"]):
try:
return next(parameter.parameters()).device
......
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