def _sync_copyfrom(self, source_array):
"""Peform an synchronize copy from the array.
Parameters
----------
source_array : array_like
The data source we should like to copy from.
"""
if not isinstance(source_array, np.ndarray):
try:
source_array = np.array(source_array, dtype=np.float32)
except:
raise TypeError('array must be an array_like data,' +
'type %s is not supported'
% str(type(source_array)))
source_array = np.ascontiguousarray(source_array, dtype=np.float32)
if source_array.shape != self.shape:
raise ValueError('array shape do not match the shape of NDArray')
source_arr, shape = NDArray._numpyasarray(source_array)
check_call(_LIB.DLArrayCopyFromTo(
ctypes.byref(source_arr), self.handle, None))
# de-allocate shape until now
_ = shape
评论列表
文章目录