MCPcopy
hub / github.com/dmlc/dgl / empty

Function empty

python/dgl/_ffi/ndarray.py:104–139  ·  view source on GitHub ↗

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))

Source from the content-addressed store, hash-verified

102
103
104def 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
142def empty_shared_mem(name, is_create, shape, dtype="float32"):

Callers 2

copytoMethod · 0.70
arrayFunction · 0.50

Calls 5

c_arrayFunction · 0.85
DGLDataTypeClass · 0.85
check_callFunction · 0.85
_make_arrayFunction · 0.85
contextFunction · 0.70

Tested by

no test coverage detected