[testing] add timeout_decorator (#3543)

This commit is contained in:
Sam Shleifer
2020-05-01 09:05:47 -04:00
committed by GitHub
parent b8686174be
commit 18db92dd9a
3 changed files with 5 additions and 2 deletions

View File

@@ -13,10 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import tempfile
import unittest
import timeout_decorator # noqa
from transformers import is_torch_available
from .test_configuration_common import ConfigTester
@@ -357,6 +358,7 @@ class BartHeadTests(unittest.TestCase):
loss = outputs[0]
self.assertIsInstance(loss.item(), float)
@timeout_decorator.timeout(1)
def test_lm_forward(self):
config, input_ids, batch_size = self._get_config_and_data()
lm_labels = ids_tensor([batch_size, input_ids.shape[1]], self.vocab_size).to(torch_device)