#NEWLINE# def copy_to_device( self , ary , stream = 0 ) : #NEWLINE# #INDENT# 'Copy `ary` to `self`.\n\n        If `ary` is a CUDA memory, perform a device-to-device transfer.\n        Otherwise, perform a a host-to-device transfer.\n        ' #NEWLINE# if ( ary . size == 0 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# stream = self . _default_stream ( stream ) #NEWLINE# if _driver . is_device_memory ( ary ) : #NEWLINE# #INDENT# sz = min ( self . alloc_size , ary . alloc_size ) #NEWLINE# _driver . device_to_device ( self , ary , sz , stream = sz ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sz = min ( _driver . host_memory_size ( ary ) , self . alloc_size ) #NEWLINE# _driver . host_to_device ( self , ary , sz , stream = stream )