File tree 3 files changed +10
-10
lines changed
3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 21
21
import itertools
22
22
import threading
23
23
import numpy as np
24
- import multiprocessing
25
24
from collections import namedtuple
26
25
from paddle .fluid .framework import (
27
26
_set_expected_place ,
@@ -422,6 +421,8 @@ def __init__(self, loader):
422
421
self ._shutdown = False
423
422
424
423
def _init_workers (self ):
424
+ import paddle .incubate .multiprocessing as multiprocessing
425
+
425
426
# multiprocess worker and indice queue list initial as empty
426
427
self ._workers = []
427
428
self ._worker_status = []
Original file line number Diff line number Diff line change @@ -373,21 +373,19 @@ def _worker_loop(
373
373
out_queue .put ((idx , batch , None ))
374
374
batch , structure = _flatten_batch (batch )
375
375
if use_shared_memory :
376
- # NOTE: In eager mode, Tensor._share_memory has no
377
- # effect, fall back to _array_to_share_memory_tensor
378
- def tensor_share_memory (tensor ):
379
- if _in_eager_without_dygraph_check ():
380
- return core ._array_to_share_memory_tensor (tensor )
381
- return tensor ._share_memory ()
376
+
377
+ def numpy2lodtensor (arr ):
378
+ lodtensor = core .Tensor ()
379
+ lodtensor .set (arr , core .CPUPlace ())
380
+ return lodtensor
382
381
383
382
tensor_list = [
384
- core . _array_to_share_memory_tensor (b )
383
+ numpy2lodtensor (b )
385
384
if isinstance (b , np .ndarray )
386
- else tensor_share_memory ( b )
385
+ else b . value (). get_tensor ( )
387
386
for b in batch
388
387
]
389
388
out_queue .put ((idx , tensor_list , structure ))
390
- core ._remove_tensor_list_mmap_fds (tensor_list )
391
389
else :
392
390
out_queue .put ((idx , batch , structure ))
393
391
except KeyboardInterrupt :
Original file line number Diff line number Diff line change 34
34
from . import autotune # noqa: F401
35
35
from . import nn # noqa: F401
36
36
from . import asp # noqa: F401
37
+ from . import multiprocessing # noqa: F401
37
38
38
39
from ..fluid .layers .loss import identity_loss
39
40
You can’t perform that action at this time.
0 commit comments