Skip to content

Commit

Permalink
Make copy_to_external in framework iterators non-blocking.
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
  • Loading branch information
mzient committed Jun 2, 2022
1 parent 73203a6 commit 664c462
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dali/python/nvidia/dali/plugin/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def feed_ndarray(dali_tensor, arr, cuda_stream = None):

# Copy data from DALI tensor to ptr
if isinstance(dali_tensor, (TensorGPU, TensorListGPU)):
dali_tensor.copy_to_external(ptr, None if cuda_stream is None else ctypes.c_void_p(cuda_stream))
stream = None if cuda_stream is None else ctypes.c_void_p(cuda_stream)
dali_tensor.copy_to_external(ptr, stream, non_blocking=True)
else:
dali_tensor.copy_to_external(ptr)

Expand Down
4 changes: 2 additions & 2 deletions dali/python/nvidia/dali/plugin/paddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def feed_ndarray(dali_tensor, ptr, cuda_stream=None):

c_type_pointer = ctypes.c_void_p(ptr)
if isinstance(dali_tensor, (TensorGPU, TensorListGPU)):
dali_tensor.copy_to_external(
c_type_pointer, None if cuda_stream is None else ctypes.c_void_p(cuda_stream))
stream = None if cuda_stream is None else ctypes.c_void_p(cuda_stream)
dali_tensor.copy_to_external(c_type_pointer, stream, non_blocking=True)
else:
dali_tensor.copy_to_external(c_type_pointer)
return ptr
Expand Down
3 changes: 2 additions & 1 deletion dali/python/nvidia/dali/plugin/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def feed_ndarray(dali_tensor, arr, cuda_stream = None):
# turn raw int to a c void pointer
c_type_pointer = ctypes.c_void_p(arr.data_ptr())
if isinstance(dali_tensor, (TensorGPU, TensorListGPU)):
dali_tensor.copy_to_external(c_type_pointer, None if cuda_stream is None else ctypes.c_void_p(cuda_stream))
stream = None if cuda_stream is None else ctypes.c_void_p(cuda_stream)
dali_tensor.copy_to_external(c_type_pointer, stream, non_blocking=True)
else:
dali_tensor.copy_to_external(c_type_pointer)
return arr
Expand Down

0 comments on commit 664c462

Please sign in to comment.