From c05170d3d8d9dd95ffc4433a2e35aa8dcce25de1 Mon Sep 17 00:00:00 2001 From: huangxu96 <46740794+huangxu96@users.noreply.github.com> Date: Tue, 15 Dec 2020 15:32:44 +0800 Subject: [PATCH] add alias for fluid.contrib.mixed_precision (#29562) * add alias for fluid.contrib.mixed_precision --- .../fluid/contrib/mixed_precision/__init__.py | 7 ++++++- .../contrib/mixed_precision/fp16_utils.py | 3 +++ python/paddle/static/amp/__init__.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 python/paddle/static/amp/__init__.py diff --git a/python/paddle/fluid/contrib/mixed_precision/__init__.py b/python/paddle/fluid/contrib/mixed_precision/__init__.py index c6296bcac93..a580ae5574c 100644 --- a/python/paddle/fluid/contrib/mixed_precision/__init__.py +++ b/python/paddle/fluid/contrib/mixed_precision/__init__.py @@ -13,9 +13,14 @@ # limitations under the License. from __future__ import print_function + from . import decorator from .decorator import * -from .fp16_lists import AutoMixedPrecisionLists +from . import fp16_lists +from .fp16_lists import * +from . import fp16_utils +from .fp16_utils import * __all__ = decorator.__all__ __all__ += fp16_lists.__all__ +__all__ += fp16_utils.__all__ diff --git a/python/paddle/fluid/contrib/mixed_precision/fp16_utils.py b/python/paddle/fluid/contrib/mixed_precision/fp16_utils.py index 2f2f476a875..c9a070a03a4 100644 --- a/python/paddle/fluid/contrib/mixed_precision/fp16_utils.py +++ b/python/paddle/fluid/contrib/mixed_precision/fp16_utils.py @@ -20,6 +20,9 @@ from ... import global_scope from ...log_helper import get_logger import logging import numpy as np + +__all__ = ["cast_model_to_fp16", "cast_parameters_to_fp16"] + _logger = get_logger( __name__, logging.INFO, fmt='%(asctime)s-%(levelname)s: %(message)s') diff --git a/python/paddle/static/amp/__init__.py b/python/paddle/static/amp/__init__.py new file mode 100644 index 00000000000..604c7c3d2b4 --- /dev/null +++ b/python/paddle/static/amp/__init__.py @@ -0,0 +1,18 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# 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. + +from ...fluid.contrib import mixed_precision +from ...fluid.contrib.mixed_precision import * + +__all__ = mixed_precision.__all__ -- GitLab