diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index 60ae85d6e73bcb18606c1132cc71651a17a285df..05b73730a23a47d24eb109965984e016d3696038 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -42,8 +42,8 @@ paddle.fluid.DistributeTranspiler.get_pserver_programs (ArgSpec(args=['self', 'e paddle.fluid.DistributeTranspiler.get_startup_program (ArgSpec(args=['self', 'endpoint', 'pserver_program', 'startup_program'], varargs=None, keywords=None, defaults=(None, None)), ('document', '90a40b80e0106f69262cc08b861c3e39')) paddle.fluid.DistributeTranspiler.get_trainer_program (ArgSpec(args=['self', 'wait_port'], varargs=None, keywords=None, defaults=(True,)), ('document', '0e47f020304e2b824e87ff03475c17cd')) paddle.fluid.DistributeTranspiler.transpile (ArgSpec(args=['self', 'trainer_id', 'program', 'pservers', 'trainers', 'sync_mode', 'startup_program', 'current_endpoint'], varargs=None, keywords=None, defaults=(None, '127.0.0.1:6174', 1, True, None, '127.0.0.1:6174')), ('document', '418c7e8b268e9be4104f2809e654c2f7')) -paddle.fluid.memory_optimize (ArgSpec(args=['input_program', 'skip_opt_set', 'print_log', 'level', 'skip_grads'], varargs=None, keywords=None, defaults=(None, False, 0, True)), ('document', '2348247f684bfd5bb9466470f35be064')) -paddle.fluid.release_memory (ArgSpec(args=['input_program', 'skip_opt_set'], varargs=None, keywords=None, defaults=(None,)), ('document', 'd38c5b8b2b2e0bb19bcf1b581a80a7e4')) +paddle.fluid.memory_optimize (ArgSpec(args=['input_program', 'skip_opt_set', 'print_log', 'level', 'skip_grads'], varargs=None, keywords=None, defaults=(None, False, 0, True)), ('document', '2be29dc8ecdec9baa7728fb0c7f80e24')) +paddle.fluid.release_memory (ArgSpec(args=['input_program', 'skip_opt_set'], varargs=None, keywords=None, defaults=(None,)), ('document', '2be29dc8ecdec9baa7728fb0c7f80e24')) paddle.fluid.DistributeTranspilerConfig ('paddle.fluid.transpiler.distribute_transpiler.DistributeTranspilerConfig', ('document', 'beac6f89fe97eb8c66a25de5a09c56d2')) paddle.fluid.DistributeTranspilerConfig.__init__ (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.ParallelExecutor ('paddle.fluid.parallel_executor.ParallelExecutor', ('document', '2b4d2e859f2e0c6161f4fed995f7956d')) @@ -891,8 +891,8 @@ paddle.fluid.transpiler.DistributeTranspiler.get_pserver_programs (ArgSpec(args= paddle.fluid.transpiler.DistributeTranspiler.get_startup_program (ArgSpec(args=['self', 'endpoint', 'pserver_program', 'startup_program'], varargs=None, keywords=None, defaults=(None, None)), ('document', '90a40b80e0106f69262cc08b861c3e39')) paddle.fluid.transpiler.DistributeTranspiler.get_trainer_program (ArgSpec(args=['self', 'wait_port'], varargs=None, keywords=None, defaults=(True,)), ('document', '0e47f020304e2b824e87ff03475c17cd')) paddle.fluid.transpiler.DistributeTranspiler.transpile (ArgSpec(args=['self', 'trainer_id', 'program', 'pservers', 'trainers', 'sync_mode', 'startup_program', 'current_endpoint'], varargs=None, keywords=None, defaults=(None, '127.0.0.1:6174', 1, True, None, '127.0.0.1:6174')), ('document', '418c7e8b268e9be4104f2809e654c2f7')) -paddle.fluid.transpiler.memory_optimize (ArgSpec(args=['input_program', 'skip_opt_set', 'print_log', 'level', 'skip_grads'], varargs=None, keywords=None, defaults=(None, False, 0, True)), ('document', '2348247f684bfd5bb9466470f35be064')) -paddle.fluid.transpiler.release_memory (ArgSpec(args=['input_program', 'skip_opt_set'], varargs=None, keywords=None, defaults=(None,)), ('document', 'd38c5b8b2b2e0bb19bcf1b581a80a7e4')) +paddle.fluid.transpiler.memory_optimize (ArgSpec(args=['input_program', 'skip_opt_set', 'print_log', 'level', 'skip_grads'], varargs=None, keywords=None, defaults=(None, False, 0, True)), ('document', '2be29dc8ecdec9baa7728fb0c7f80e24')) +paddle.fluid.transpiler.release_memory (ArgSpec(args=['input_program', 'skip_opt_set'], varargs=None, keywords=None, defaults=(None,)), ('document', '2be29dc8ecdec9baa7728fb0c7f80e24')) paddle.fluid.transpiler.HashName ('paddle.fluid.transpiler.ps_dispatcher.HashName', ('document', '8190ddc66ee412441f5d97fd3f702bdd')) paddle.fluid.transpiler.HashName.__init__ (ArgSpec(args=['self', 'pserver_endpoints'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.transpiler.HashName.dispatch (ArgSpec(args=['self', 'varlist'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) diff --git a/python/paddle/fluid/transpiler/memory_optimization_transpiler.py b/python/paddle/fluid/transpiler/memory_optimization_transpiler.py index 29812812af6961fd6c1cef9b659f56c1dac1efbf..3530637231e4fdbfed67936c87f96ffc13b66116 100755 --- a/python/paddle/fluid/transpiler/memory_optimization_transpiler.py +++ b/python/paddle/fluid/transpiler/memory_optimization_transpiler.py @@ -21,56 +21,8 @@ def memory_optimize(input_program, level=0, skip_grads=True): """ - | Legacy memory optimization strategy, reduce total memory consumption by reuse variable memory between different operators. - | Simple sample to explain the algorithm: - - .. code-block:: python - - c = a + b # assume this is the last time a is used - d = b * c - - | since **a** will not be used anymore after **"c = a + b"**, and the size of **a** and **d** are the same, - we can use variable **a** to replace variable **d**, so actually we can optimize the above code to below: - - .. code-block:: python - - c = a + b - a = b * c - - - | Please notice that, in this legacy design, we are using variable **a** to replace **d** directly, which means - after you call this API, some variables may disappear, and some variables may hold unexpected values, like - the above case, actually **a** holds the value of **d** after execution. - - | So to protect important variables from being reused/removed in the optimization, we provide skip_opt_set - to allow you specify a variable whitelist. - The variables in the skip_opt_set will not be affected by memory_optimize API. - - Note: - | **This API is deprecated, please avoid to use it in your new code.** - | Does not support operators which will create sub-block like While, IfElse etc. - - Args: - input_program(str): Input Program - skip_opt_set(set): vars wil be skipped in memory optimze - print_log(bool): whether to print debug log. - level(int): 0 or 1, 0 means we replace a with b only when a.size == b.size, 1 means we can replace a with b if a.size <= b.size - Returns: - None - - Examples: - .. code-block:: python - - import paddle.fluid as fluid - main_prog = fluid.Program() - startup_prog = fluid.Program() - - place = fluid.CPUPlace() - exe = fluid.Executor(place) - - exe.run(startup_prog) - fluid.memory_optimize(main_prog) - + This API is deprecated since 1.6. Please do not use it. The better + memory optimization strategies are enabled by default. """ logging.warn( 'Caution! paddle.fluid.memory_optimize() is deprecated ' @@ -89,29 +41,8 @@ def memory_optimize(input_program, def release_memory(input_program, skip_opt_set=None): """ - Modify the input program and insert :code:`delete_op` to early drop not used - variables. The modification will be performed inplace. - - Notes: This is an experimental API and could be removed in next few - releases. Users should not use this API. - - Args: - input_program(Program): The program will be inserted :code:`delete_op`. - skip_opt_set(set): vars wil be skipped in memory optimze - Returns: - None - - Examples: - .. code-block:: python - - import paddle.fluid as fluid - - # build network - # ... - - # deprecated API - fluid.release_memory(fluid.default_main_program()) - + This API is deprecated since 1.6. Please do not use it. The better + memory optimization strategies are enabled by default. """ logging.warn('paddle.fluid.release_memory() is deprecated, it would not' ' take any memory release on your program')