Skip to content

Commit 5d22b8f

Browse files
committed
Fix doc
test=release/1.3
1 parent b1e5699 commit 5d22b8f

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

python/paddle/fluid/executor.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -261,45 +261,42 @@ def _as_lodtensor(data, place):
261261

262262
class Executor(object):
263263
"""
264-
An Executor in Python, only support the single-GPU running. For multi-cards, please refer to
265-
ParallelExecutor.
266-
Python executor takes a program, add feed operators and fetch operators to this program according
264+
An Executor in Python, supports single/multiple-GPU running, and single/multiple-CPU running.
265+
Python executor takes a program, adds feed operators and fetch operators to this program according
267266
to feed map and fetch_list. Feed map provides input data for the program. fetch_list provides
268-
the variables(or names) that user want to get after program run. Note: the executor will run all
267+
the variables(or names) that user wants to get after program runs. Note: the executor will run all
269268
operators in the program but not only the operators dependent by the fetch_list.
270-
It store the global variables into the global scope, and create a local scope for the temporary
271-
variables. The local scope contents will be discarded after every minibatch forward/backward finished.
272-
But the global scope variables will be persistent through different runs.
273-
All of ops in program will be running in sequence.
269+
It stores the global variables into the global scope, and creates a local scope for the temporary
270+
variables. The contents in local scope may be discarded after every minibatch forward/backward
271+
finished. But the global scope variables will be persistent through different runs.
274272
275273
276274
Example:
277-
.. code-block:: python
278-
# First create the Executor.
279-
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
280-
exe = fluid.Executor(place)
281-
282-
# Run the startup program once and only once.
283-
# Not need to optimize/compile the startup program.
284-
exe.run(fluid.default_startup_program())
285-
286-
# Run the main program directly without compile.
287-
loss, = exe.run(fluid.default_main_program(),
288-
feed=feed_dict,
289-
fetch_list=[loss.name])
290-
# Or, compiled the program and run. See `CompiledProgram` for more detail.
291-
compiled_prog = compiler.CompiledProgram(
292-
fluid.default_main_program()).with_data_parallel(
293-
loss_name=loss.name)
294-
loss, = exe.run(compiled_prog,
295-
feed=feed_dict,
296-
fetch_list=[loss.name])
275+
276+
.. code-block:: python
277+
278+
# First create the Executor.
279+
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
280+
exe = fluid.Executor(place)
281+
282+
# Run the startup program once and only once.
283+
# Not need to optimize/compile the startup program.
284+
exe.run(fluid.default_startup_program())
285+
286+
# Run the main program directly without compile.
287+
loss, = exe.run(fluid.default_main_program(),
288+
feed=feed_dict,
289+
fetch_list=[loss.name])
290+
# Or, compiled the program and run. See `CompiledProgram` for more detail.
291+
compiled_prog = compiler.CompiledProgram(
292+
fluid.default_main_program()).with_data_parallel(
293+
loss_name=loss.name)
294+
loss, = exe.run(compiled_prog,
295+
feed=feed_dict,
296+
fetch_list=[loss.name])
297297
298298
Args:
299299
place(core.CPUPlace|core.CUDAPlace(n)): indicate the executor run on which device
300-
301-
Note: For debugging complicated network in parallel-GPUs, you can test it on the executor.
302-
They has the exactly same arguments, and expected the same results.
303300
"""
304301

305302
def __init__(self, place):
@@ -382,16 +379,19 @@ def _fetch_data(self, fetch_list, fetch_var_name, scope):
382379
]
383380
return outs
384381

382+
'''
383+
TODO(typhoonzero): Define "no longer use" meaning? Can user create
384+
a new Executor for the same program and run?
385+
TODO(panyx0718): Why ParallelExecutor doesn't have close?
386+
'''
387+
385388
def close(self):
386389
"""
387390
Close this executor.
388391
389392
You can no longer use this executor after calling this method.
390393
For the distributed training, this method would free the resource on PServers related to
391394
the current Trainer.
392-
TODO(typhoonzero): Define "no longer use" meaning? Can user create
393-
a new Executor for the same program and run?
394-
TODO(panyx0718): Why ParallelExecutor doesn't have close?
395395
396396
Example:
397397
>>> cpu = core.CPUPlace()

0 commit comments

Comments
 (0)