|
|
|
@ -247,6 +247,7 @@ class Executor(object):
|
|
|
|
|
p.set_place(place)
|
|
|
|
|
self.executor = core.Executor(p)
|
|
|
|
|
self.program_caches = dict()
|
|
|
|
|
self._closed = False
|
|
|
|
|
|
|
|
|
|
def as_lodtensor(self, data):
|
|
|
|
|
"""
|
|
|
|
@ -348,8 +349,23 @@ class Executor(object):
|
|
|
|
|
]
|
|
|
|
|
return outs
|
|
|
|
|
|
|
|
|
|
def complete(self):
|
|
|
|
|
self.executor.complete()
|
|
|
|
|
def close(self):
|
|
|
|
|
"""
|
|
|
|
|
Close this executor.
|
|
|
|
|
|
|
|
|
|
You can no long use this executor after calling this method.
|
|
|
|
|
For the distributed training, this method would free the resource on PServers related to
|
|
|
|
|
the current Trainer.
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
>>> cpu = core.CPUPlace()
|
|
|
|
|
>>> exe = Executor(cpu)
|
|
|
|
|
>>> ...
|
|
|
|
|
>>> exe.close()
|
|
|
|
|
"""
|
|
|
|
|
if not self._closed:
|
|
|
|
|
self.executor.close()
|
|
|
|
|
self._closed = True
|
|
|
|
|
|
|
|
|
|
def run(self,
|
|
|
|
|
program=None,
|
|
|
|
@ -402,6 +418,10 @@ class Executor(object):
|
|
|
|
|
>>> feed={'X': x},
|
|
|
|
|
>>> fetch_list=[loss.name])
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
if self._closed:
|
|
|
|
|
raise RuntimeError("Attempted to use a closed Executor")
|
|
|
|
|
|
|
|
|
|
if feed is None:
|
|
|
|
|
feed = {}
|
|
|
|
|
if not isinstance(feed, dict):
|
|
|
|
|