def empty(shape, ctx=cpu(0)):
"""Create an empty array given shape and device
Parameters
----------
shape : tuple of int
The shape of the array
ctx : DLContext
The context of the array
Returns
-------
arr : ndarray
The array dlsys supported.
"""
shape = c_array(ctypes.c_int64, shape)
ndim = ctypes.c_int(len(shape))
handle = DLArrayHandle()
check_call(_LIB.DLArrayAlloc(
shape, ndim, ctx, ctypes.byref(handle)))
return NDArray(handle)
评论列表
文章目录