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

Function array

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

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

Source from the content-addressed store, hash-verified

84
85
86def 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
107def zerocopy_from_numpy(np_data):

Callers 1

ndarray.pyFile · 0.85

Calls 3

copyfromMethod · 0.80
cpuFunction · 0.70
emptyFunction · 0.50

Tested by

no test coverage detected