|
|
|
@ -16,6 +16,7 @@ from __future__ import print_function
|
|
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import unittest
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
import paddle.fluid as fluid
|
|
|
|
|
|
|
|
from paddle.fluid import compiler
|
|
|
|
import paddle.fluid.core as core
|
|
|
|
import paddle.fluid.core as core
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
|
@ -188,18 +189,18 @@ class TestPyReaderUsingExecutor(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
|
|
|
|
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
|
|
|
|
|
|
|
|
|
|
|
|
startup_exe = fluid.Executor(place)
|
|
|
|
exe = fluid.Executor(place)
|
|
|
|
startup_exe.run(startup_program)
|
|
|
|
exe.run(startup_program)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
train_cp = compiler.CompiledProgram(main_program)
|
|
|
|
if use_parallel_executor:
|
|
|
|
if use_parallel_executor:
|
|
|
|
main_exe = fluid.ParallelExecutor(use_cuda, loss_name=loss.name)
|
|
|
|
train_cp = train_cp.with_data_parallel(loss_name=loss.name)
|
|
|
|
if use_cuda:
|
|
|
|
if use_cuda:
|
|
|
|
self.batch_size_times = core.get_cuda_device_count()
|
|
|
|
self.batch_size_times = core.get_cuda_device_count()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.batch_size_times = int(
|
|
|
|
self.batch_size_times = int(
|
|
|
|
os.environ.get('CPU_NUM', multiprocessing.cpu_count()))
|
|
|
|
os.environ.get('CPU_NUM', multiprocessing.cpu_count()))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
main_exe = startup_exe
|
|
|
|
|
|
|
|
self.batch_size_times = 1
|
|
|
|
self.batch_size_times = 1
|
|
|
|
|
|
|
|
|
|
|
|
reader = self.tensor_reader(use_decorate_paddle_reader)
|
|
|
|
reader = self.tensor_reader(use_decorate_paddle_reader)
|
|
|
|
@ -214,7 +215,8 @@ class TestPyReaderUsingExecutor(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
|
|
self.outputs = []
|
|
|
|
self.outputs = []
|
|
|
|
for _ in range(self.iterations):
|
|
|
|
for _ in range(self.iterations):
|
|
|
|
fetches = main_exe.run(fetch_list=[in_data.name, label.name])
|
|
|
|
fetches = exe.run(train_cp,
|
|
|
|
|
|
|
|
fetch_list=[in_data.name, label.name])
|
|
|
|
fetches = [as_numpy(fetch) for fetch in fetches]
|
|
|
|
fetches = [as_numpy(fetch) for fetch in fetches]
|
|
|
|
self.outputs.append(fetches)
|
|
|
|
self.outputs.append(fetches)
|
|
|
|
|
|
|
|
|
|
|
|
|