__init__.py 1.52 KB
Newer Older
Raul Puri's avatar
Raul Puri committed
1
# coding=utf-8
Mohammad's avatar
Mohammad committed
2
# Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
Raul Puri's avatar
Raul Puri committed
3
4
5
6
7
8
9
10
11
12
13
14
15
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

16
17
18
_LAYER_NORM = None


Mohammad Shoeybi's avatar
Mohammad Shoeybi committed
19
def import_layernorm(fp32_residual_connection, bf16):
20
21
22

    global _LAYER_NORM
    if not _LAYER_NORM:
Mohammad Shoeybi's avatar
Mohammad Shoeybi committed
23
24
25
        if bf16:
            from torch.nn import LayerNorm
        elif fp32_residual_connection:
26
27
28
29
30
31
32
33
            from .fused_layer_norm import MixedFusedLayerNorm as LayerNorm
        else:
            from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
        _LAYER_NORM = LayerNorm
            
    return _LAYER_NORM


Raul Puri's avatar
Raul Puri committed
34
from .distributed import *
35
36
37
38
from .bert_model import (BertModel,
                         BertModelFirstStage,
                         BertModelIntermediateStage,
                         BertModelLastStage)
39
40
41
42
from .gpt_model import (GPTModel,
                        GPTModelFirstStage,
                        GPTModelIntermediateStage,
                        GPTModelLastStage)
43
from .language_model import get_language_model
Mohammad Shoeybi's avatar
Mohammad Shoeybi committed
44
from .module import Float16Module
45
46