Create an array from source arr. Parameters ---------- arr : numpy.ndarray The array to be copied from ctx : DGLContext, optional The device context to create the array Returns ------- ret : NDArray The created array
(arr, ctx=cpu(0))
| 84 | |
| 85 | |
| 86 | def array(arr, ctx=cpu(0)): |
| 87 | """Create an array from source arr. |
| 88 | |
| 89 | Parameters |
| 90 | ---------- |
| 91 | arr : numpy.ndarray |
| 92 | The array to be copied from |
| 93 | |
| 94 | ctx : DGLContext, optional |
| 95 | The device context to create the array |
| 96 | |
| 97 | Returns |
| 98 | ------- |
| 99 | ret : NDArray |
| 100 | The created array |
| 101 | """ |
| 102 | if not isinstance(arr, (_np.ndarray, NDArray)): |
| 103 | arr = _np.array(arr) |
| 104 | return empty(arr.shape, arr.dtype, ctx).copyfrom(arr) |
| 105 | |
| 106 | |
| 107 | def zerocopy_from_numpy(np_data): |
no test coverage detected