From 4b2794c85695e134dd3d32a3b07006db0734e175 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Tue, 12 Feb 2019 09:48:39 +0800 Subject: [PATCH] rename test=release/1.3 --- .../fluid/contrib/decoder/beam_search_decoder.py | 6 +++--- python/paddle/fluid/contrib/inferencer.py | 4 ++-- python/paddle/fluid/contrib/trainer.py | 4 ++-- python/paddle/fluid/executor.py | 4 ++-- python/paddle/fluid/framework.py | 14 +++++++------- python/paddle/fluid/imperative/base.py | 4 ++-- python/paddle/fluid/initializer.py | 4 ++-- python/paddle/fluid/layers/control_flow.py | 4 ++-- python/paddle/fluid/layers/io.py | 4 ++-- python/paddle/fluid/optimizer.py | 4 ++-- python/paddle/fluid/profiler.py | 6 +++--- python/paddle/fluid/recordio_writer.py | 4 ++-- python/paddle/fluid/unique_name.py | 4 ++-- python/paddle/fluid/wrapped_decorator.py | 4 ++-- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/python/paddle/fluid/contrib/decoder/beam_search_decoder.py b/python/paddle/fluid/contrib/decoder/beam_search_decoder.py index d0ca4fd48..5854cadb5 100644 --- a/python/paddle/fluid/contrib/decoder/beam_search_decoder.py +++ b/python/paddle/fluid/contrib/decoder/beam_search_decoder.py @@ -22,7 +22,7 @@ This API is still under active development and may change drastically. from __future__ import print_function -from ...wrapped_decorator import contextmanager +from ...wrapped_decorator import signature_safe_contextmanager import numpy as np import six @@ -419,7 +419,7 @@ class TrainingDecoder(object): self._state_cell = state_cell self._state_cell._enter_decoder(self) - @contextmanager + @signature_safe_contextmanager def block(self): """ Define the behavior of the decoder for each RNN time step. @@ -613,7 +613,7 @@ class BeamSearchDecoder(object): self._word_dim = word_dim self._input_var_dict = input_var_dict - @contextmanager + @signature_safe_contextmanager def block(self): """ Define the behavior of the decoder for each RNN time step. diff --git a/python/paddle/fluid/contrib/inferencer.py b/python/paddle/fluid/contrib/inferencer.py index 41a0d55b5..4f3712923 100644 --- a/python/paddle/fluid/contrib/inferencer.py +++ b/python/paddle/fluid/contrib/inferencer.py @@ -14,7 +14,7 @@ from __future__ import print_function -from ..wrapped_decorator import contextmanager +from ..wrapped_decorator import signature_safe_contextmanager from .. import core @@ -105,7 +105,7 @@ class Inferencer(object): return results - @contextmanager + @signature_safe_contextmanager def _prog_and_scope_guard(self): with framework.program_guard(main_program=self.inference_program): with executor.scope_guard(self.scope): diff --git a/python/paddle/fluid/contrib/trainer.py b/python/paddle/fluid/contrib/trainer.py index f448c309b..d27b80843 100644 --- a/python/paddle/fluid/contrib/trainer.py +++ b/python/paddle/fluid/contrib/trainer.py @@ -14,7 +14,7 @@ from __future__ import print_function -from ..wrapped_decorator import contextmanager +from ..wrapped_decorator import signature_safe_contextmanager import os import errno import shutil @@ -453,7 +453,7 @@ class Trainer(object): io.save_inference_model(param_path, feeded_var_names, target_vars, exe) - @contextmanager + @signature_safe_contextmanager def _prog_and_scope_guard(self): with framework.program_guard( main_program=self.train_program, diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 6c49c5640..8815911ea 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -17,7 +17,7 @@ from __future__ import print_function import os import multiprocessing import numpy as np -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager import six from .framework import Program, default_main_program, Variable from . import core @@ -49,7 +49,7 @@ def _switch_scope(scope): return ex -@contextmanager +@signature_safe_contextmanager def scope_guard(scope): """ Change the global/default scope instance by Python `with` statement. All diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index f94c8136c..832c97c7d 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -16,7 +16,7 @@ from __future__ import print_function import collections from collections import defaultdict -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager import os import re import traceback @@ -111,7 +111,7 @@ class NameScope(object): _name_scope = NameScope() -@contextmanager +@signature_safe_contextmanager def name_scope(prefix=None): """ Generate hierarchical name prefix for the operators. @@ -1775,7 +1775,7 @@ class Program(object): def set_op_role_var(self, var_name): self._op_role_var = [var_name] - @contextmanager + @signature_safe_contextmanager def _optimized_guard(self, param_and_grads): """ A with guard to set :code:`Optimization` :code:`OpRole` and @@ -1805,7 +1805,7 @@ class Program(object): self._op_role_var = tmp_var self._current_role = tmp_role - @contextmanager + @signature_safe_contextmanager def _lr_schedule_guard(self, is_with_opt=False): """ A with guard to set :code:`LRSched` :code:`OpRole` and @@ -2459,7 +2459,7 @@ def switch_startup_program(program): return prev_program -@contextmanager +@signature_safe_contextmanager def program_guard(main_program, startup_program=None): """ Change the global main program and startup program with `with` statement. @@ -2524,7 +2524,7 @@ def _get_var(name, program=None): return program.global_block().var(name) -@contextmanager +@signature_safe_contextmanager def _imperative_guard(tracer): global _imperative_tracer_ tmp_trace = _imperative_tracer_ @@ -2535,7 +2535,7 @@ def _imperative_guard(tracer): _imperative_tracer_ = tmp_trace -@contextmanager +@signature_safe_contextmanager def _imperative_place_guard(place): global _imperative_current_expected_place_ tmp_place = _imperative_current_expected_place_ diff --git a/python/paddle/fluid/imperative/base.py b/python/paddle/fluid/imperative/base.py index 2f8b3534a..d4525233c 100644 --- a/python/paddle/fluid/imperative/base.py +++ b/python/paddle/fluid/imperative/base.py @@ -11,7 +11,7 @@ # 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 ..wrapped_decorator import contextmanager +from ..wrapped_decorator import signature_safe_contextmanager import numpy as np from paddle.fluid import core @@ -24,7 +24,7 @@ def enabled(): return framework._in_imperative_mode() -@contextmanager +@signature_safe_contextmanager def guard(place=None): train = framework.Program() startup = framework.Program() diff --git a/python/paddle/fluid/initializer.py b/python/paddle/fluid/initializer.py index 8f3f03cb1..e8341be28 100644 --- a/python/paddle/fluid/initializer.py +++ b/python/paddle/fluid/initializer.py @@ -16,7 +16,7 @@ from __future__ import print_function from . import framework import numpy as np -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager from .core import VarDesc from . import unique_name @@ -49,7 +49,7 @@ def force_init_on_cpu(): return _force_init_on_cpu_ -@contextmanager +@signature_safe_contextmanager def init_on_cpu(): """ Force the variable to be inited on CPU. diff --git a/python/paddle/fluid/layers/control_flow.py b/python/paddle/fluid/layers/control_flow.py index 1d639144e..3a6753b01 100644 --- a/python/paddle/fluid/layers/control_flow.py +++ b/python/paddle/fluid/layers/control_flow.py @@ -13,7 +13,7 @@ # limitations under the License. from __future__ import print_function -from ..wrapped_decorator import contextmanager +from ..wrapped_decorator import signature_safe_contextmanager from .layer_function_generator import autodoc, templatedoc from .tensor import assign, fill_constant @@ -1532,7 +1532,7 @@ class DynamicRNN(object): outputs={'Out': [x_reordered]}) return shrink_memory(x_reordered, self.step_idx, self.lod_rank_table) - @contextmanager + @signature_safe_contextmanager def block(self): """ The block for user to define operators in RNN. See the class docstring diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index 58c892315..b88be6690 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -13,7 +13,7 @@ # limitations under the License. from __future__ import print_function -from ..wrapped_decorator import contextmanager +from ..wrapped_decorator import signature_safe_contextmanager import multiprocessing import os import six @@ -1116,7 +1116,7 @@ class Preprocessor(object): def _is_completed(self): return self.sub_block and self.source_var_names and self.sink_var_names - @contextmanager + @signature_safe_contextmanager def block(self): self.status = Preprocessor.IN_SUB_BLOCK self.sub_block = self.main_prog._create_block() diff --git a/python/paddle/fluid/optimizer.py b/python/paddle/fluid/optimizer.py index e89103f18..fbd04f1eb 100644 --- a/python/paddle/fluid/optimizer.py +++ b/python/paddle/fluid/optimizer.py @@ -15,7 +15,7 @@ from __future__ import print_function from collections import defaultdict -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager from paddle.fluid.framework import Program, Variable, name_scope, default_main_program from paddle.fluid.distribute_lookup_table import find_distributed_lookup_table @@ -1610,7 +1610,7 @@ class ModelAverage(Optimizer): }, stop_gradient=True) - @contextmanager + @signature_safe_contextmanager def apply(self, executor, need_restore=True): """Apply average values to parameters of current model. """ diff --git a/python/paddle/fluid/profiler.py b/python/paddle/fluid/profiler.py index 08f5b3831..d5670dbc8 100644 --- a/python/paddle/fluid/profiler.py +++ b/python/paddle/fluid/profiler.py @@ -15,7 +15,7 @@ from __future__ import print_function from . import core -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager import os import six @@ -35,7 +35,7 @@ NVPROF_CONFIG = [ ] -@contextmanager +@signature_safe_contextmanager def cuda_profiler(output_file, output_mode=None, config=None): """The CUDA profiler. This fuctions is used to profile CUDA program by CUDA runtime application @@ -217,7 +217,7 @@ def stop_profiler(sorted_key=None, profile_path='/tmp/profile'): core.disable_profiler(key_map[sorted_key], profile_path) -@contextmanager +@signature_safe_contextmanager def profiler(state, sorted_key=None, profile_path='/tmp/profile'): """The profiler interface. Different from cuda_profiler, this profiler can be used to profile both CPU diff --git a/python/paddle/fluid/recordio_writer.py b/python/paddle/fluid/recordio_writer.py index 5302dbb35..aa581f23a 100644 --- a/python/paddle/fluid/recordio_writer.py +++ b/python/paddle/fluid/recordio_writer.py @@ -15,14 +15,14 @@ from __future__ import print_function import os -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager from . import core __all__ = [ 'convert_reader_to_recordio_file', 'convert_reader_to_recordio_files' ] -@contextmanager +@signature_safe_contextmanager def create_recordio_writer(filename, compressor=core.RecordIOWriter.Compressor.Snappy, max_num_records=1000): diff --git a/python/paddle/fluid/unique_name.py b/python/paddle/fluid/unique_name.py index e1ec726ec..324257c13 100644 --- a/python/paddle/fluid/unique_name.py +++ b/python/paddle/fluid/unique_name.py @@ -15,7 +15,7 @@ from __future__ import print_function import collections -from .wrapped_decorator import contextmanager +from .wrapped_decorator import signature_safe_contextmanager import six import sys @@ -68,7 +68,7 @@ def switch(new_generator=None): return old -@contextmanager +@signature_safe_contextmanager def guard(new_generator=None): if isinstance(new_generator, six.string_types): new_generator = UniqueNameGenerator(new_generator) diff --git a/python/paddle/fluid/wrapped_decorator.py b/python/paddle/fluid/wrapped_decorator.py index 224afcca5..7e7dbff65 100644 --- a/python/paddle/fluid/wrapped_decorator.py +++ b/python/paddle/fluid/wrapped_decorator.py @@ -15,7 +15,7 @@ import decorator import contextlib -__all__ = ['wrap_decorator', 'contextmanager'] +__all__ = ['wrap_decorator', 'signature_safe_contextmanager'] def wrap_decorator(decorator_func): @@ -27,4 +27,4 @@ def wrap_decorator(decorator_func): return __impl__ -contextmanager = wrap_decorator(contextlib.contextmanager) +signature_safe_contextmanager = wrap_decorator(contextlib.contextmanager) -- GitLab