Deprecate modeling_utils.py classes (#37298)
* Move utils classes into models * Add deprecation warnings * Remove from docs * Update config attributes check
This commit is contained in:
committed by
GitHub
parent
a245011252
commit
4f58fc9c82
@@ -5384,6 +5384,10 @@ class PoolerStartLogits(nn.Module):
|
||||
def __init__(self, config: PretrainedConfig):
|
||||
super().__init__()
|
||||
self.dense = nn.Linear(config.hidden_size, 1)
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `PoolerStartLogits` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMPoolerStartLogits`."
|
||||
)
|
||||
|
||||
def forward(
|
||||
self, hidden_states: torch.FloatTensor, p_mask: Optional[torch.FloatTensor] = None
|
||||
@@ -5426,6 +5430,10 @@ class PoolerEndLogits(nn.Module):
|
||||
self.activation = nn.Tanh()
|
||||
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
||||
self.dense_1 = nn.Linear(config.hidden_size, 1)
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `PoolerEndLogits` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMPoolerEndLogits`."
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
@@ -5493,6 +5501,10 @@ class PoolerAnswerClass(nn.Module):
|
||||
self.dense_0 = nn.Linear(config.hidden_size * 2, config.hidden_size)
|
||||
self.activation = nn.Tanh()
|
||||
self.dense_1 = nn.Linear(config.hidden_size, 1, bias=False)
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `PoolerAnswerClass` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMPoolerAnswerClass`."
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
@@ -5574,6 +5586,12 @@ class SquadHeadOutput(ModelOutput):
|
||||
end_top_index: Optional[torch.LongTensor] = None
|
||||
cls_logits: Optional[torch.FloatTensor] = None
|
||||
|
||||
def __post_init__(self):
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `SquadHeadOutput` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMSquadHeadOutput`."
|
||||
)
|
||||
|
||||
|
||||
class SQuADHead(nn.Module):
|
||||
r"""
|
||||
@@ -5594,6 +5612,11 @@ class SQuADHead(nn.Module):
|
||||
self.end_logits = PoolerEndLogits(config)
|
||||
self.answer_class = PoolerAnswerClass(config)
|
||||
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `SQuADHead` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMSQuADHead`."
|
||||
)
|
||||
|
||||
@replace_return_docstrings(output_type=SquadHeadOutput, config_class=PretrainedConfig)
|
||||
def forward(
|
||||
self,
|
||||
@@ -5747,6 +5770,11 @@ class SequenceSummary(nn.Module):
|
||||
if hasattr(config, "summary_last_dropout") and config.summary_last_dropout > 0:
|
||||
self.last_dropout = nn.Dropout(config.summary_last_dropout)
|
||||
|
||||
logger.warning_once(
|
||||
"[DEPRECATION WARNING] `SequenceSummary` is deprecated and will be removed in v4.53. "
|
||||
"Please use model-specific class, e.g. `XLMSequenceSummary`."
|
||||
)
|
||||
|
||||
def forward(
|
||||
self, hidden_states: torch.FloatTensor, cls_index: Optional[torch.LongTensor] = None
|
||||
) -> torch.FloatTensor:
|
||||
|
||||
Reference in New Issue
Block a user