'Copy `ary` to `self`.
If `ary` is a CUDA memory, perform a device-to-device transfer.
Otherwise, perform a a host-to-device transfer.'

def copy_to_device(self, ary, stream=0):

    if (ary.size == 0):
        return
    stream = self._default_stream(stream)
    if _driver.is_device_memory(ary):
        sz = min(self.alloc_size, ary.alloc_size)
        _driver.device_to_device(self, ary, sz, stream=stream)
    else:
        sz = min(_driver.host_memory_size(ary), self.alloc_size)
        _driver.host_to_device(self, ary, sz, stream=stream)
