From ca6fc145e3c6ec1d2a4dd3648f9564e48e311e7a Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Wed, 1 Mar 2017 12:19:52 +0800 Subject: [PATCH] add some comments --- paddle/py_paddle/dataprovider_converter.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddle/py_paddle/dataprovider_converter.py b/paddle/py_paddle/dataprovider_converter.py index 60a0f2c0444..57e58e077d7 100644 --- a/paddle/py_paddle/dataprovider_converter.py +++ b/paddle/py_paddle/dataprovider_converter.py @@ -26,7 +26,14 @@ class IScanner(object): if not isinstance(self.input_type, dp2.InputType): raise ValueError("input type should be dataprovider2.InputType") self.pos = pos - self.use_gpu = True if swig_paddle.isUsingGpu() and ( + # data_in_gpu is used to indicate whether to create argument on GPU + # or not in GPU mode. Now if using one thread (trainer_count=1), + # trainer uses NeuralNetwork which needs to create argument on GPU + # before calling forward function. So, set data_in_gpu to True. + # Otherwise, trainer uses MultiGradientMachine which will transfer + # data from CPU to GPU in the forward function, set data_in_gpu to + # False in this case. + self.data_in_gpu = True if swig_paddle.isUsingGpu() and ( swig_paddle.getTrainerCount() == 1) else False def scan(self, dat): -- GitLab