From 8217d4e37fce48490a68af7e8ce902af16318132 Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Tue, 29 Dec 2020 13:32:07 -0800 Subject: [PATCH] [prophetnet] wrong import (#9349) ``` python -c "from apex.normalization import FusedProphetNetLayerNorm" Traceback (most recent call last): File "", line 1, in ImportError: cannot import name 'FusedProphetNetLayerNorm' from 'apex.normalization' (/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/apex/normalization/__init__.py) ``` It looks like this code has never been tested, so it silently fails inside try/except. Discovered this by accident in https://github.com/huggingface/transformers/issues/9338#issuecomment-752217708 --- src/transformers/models/prophetnet/modeling_prophetnet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/models/prophetnet/modeling_prophetnet.py b/src/transformers/models/prophetnet/modeling_prophetnet.py index e8856830e4..ffa669d64b 100644 --- a/src/transformers/models/prophetnet/modeling_prophetnet.py +++ b/src/transformers/models/prophetnet/modeling_prophetnet.py @@ -513,9 +513,9 @@ class ProphetNetDecoderLMOutput(ModelOutput): def ProphetNetLayerNorm(normalized_shape, eps=1e-5, elementwise_affine=True): if torch.cuda.is_available(): try: - from apex.normalization import FusedProphetNetLayerNorm + from apex.normalization import FusedLayerNorm - return FusedProphetNetLayerNorm(normalized_shape, eps, elementwise_affine) + return FusedLayerNorm(normalized_shape, eps, elementwise_affine) except ImportError: pass return torch.nn.LayerNorm(normalized_shape, eps, elementwise_affine)