Expose get_config() on ModelTesters (#12812)
* Expose get_config() on ModelTesters * Typo
This commit is contained in:
@@ -19,7 +19,7 @@ import copy
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from transformers import is_torch_available
|
||||
from transformers import LEDConfig, is_torch_available
|
||||
from transformers.file_utils import cached_property
|
||||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||
@@ -34,7 +34,6 @@ if is_torch_available():
|
||||
|
||||
from transformers import (
|
||||
MODEL_FOR_QUESTION_ANSWERING_MAPPING,
|
||||
LEDConfig,
|
||||
LEDForConditionalGeneration,
|
||||
LEDForQuestionAnswering,
|
||||
LEDForSequenceClassification,
|
||||
@@ -75,7 +74,6 @@ def prepare_led_inputs_dict(
|
||||
}
|
||||
|
||||
|
||||
@require_torch
|
||||
class LEDModelTester:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -141,7 +139,12 @@ class LEDModelTester:
|
||||
|
||||
decoder_input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size)
|
||||
|
||||
config = LEDConfig(
|
||||
config = self.get_config()
|
||||
inputs_dict = prepare_led_inputs_dict(config, input_ids, decoder_input_ids)
|
||||
return config, inputs_dict
|
||||
|
||||
def get_config(self):
|
||||
return LEDConfig(
|
||||
vocab_size=self.vocab_size,
|
||||
d_model=self.hidden_size,
|
||||
encoder_layers=self.num_hidden_layers,
|
||||
@@ -158,8 +161,6 @@ class LEDModelTester:
|
||||
pad_token_id=self.pad_token_id,
|
||||
attention_window=self.attention_window,
|
||||
)
|
||||
inputs_dict = prepare_led_inputs_dict(config, input_ids, decoder_input_ids)
|
||||
return config, inputs_dict
|
||||
|
||||
def prepare_config_and_inputs_for_common(self):
|
||||
config, inputs_dict = self.prepare_config_and_inputs()
|
||||
|
||||
Reference in New Issue
Block a user