Create an empty array given shape and device Parameters ---------- shape : tuple of int The shape of the array dtype : type or str The data type of the array. ctx : DGLContext The context of the array Returns ------- arr : dgl.nd.NDArray
(shape, dtype="float32", ctx=context(1, 0))
| 102 | |
| 103 | |
| 104 | def empty(shape, dtype="float32", ctx=context(1, 0)): |
| 105 | """Create an empty array given shape and device |
| 106 | |
| 107 | Parameters |
| 108 | ---------- |
| 109 | shape : tuple of int |
| 110 | The shape of the array |
| 111 | |
| 112 | dtype : type or str |
| 113 | The data type of the array. |
| 114 | |
| 115 | ctx : DGLContext |
| 116 | The context of the array |
| 117 | |
| 118 | Returns |
| 119 | ------- |
| 120 | arr : dgl.nd.NDArray |
| 121 | The array dgl supported. |
| 122 | """ |
| 123 | shape = c_array(dgl_shape_index_t, shape) |
| 124 | ndim = ctypes.c_int(len(shape)) |
| 125 | handle = DGLArrayHandle() |
| 126 | dtype = DGLDataType(dtype) |
| 127 | check_call( |
| 128 | _LIB.DGLArrayAlloc( |
| 129 | shape, |
| 130 | ndim, |
| 131 | ctypes.c_int(dtype.type_code), |
| 132 | ctypes.c_int(dtype.bits), |
| 133 | ctypes.c_int(dtype.lanes), |
| 134 | ctx.device_type, |
| 135 | ctx.device_id, |
| 136 | ctypes.byref(handle), |
| 137 | ) |
| 138 | ) |
| 139 | return _make_array(handle, False) |
| 140 | |
| 141 | |
| 142 | def empty_shared_mem(name, is_create, shape, dtype="float32"): |
no test coverage detected