MCPcopy Index your code
hub / github.com/dmlc/dgl / numpyasarray

Function numpyasarray

python/dgl/_ffi/ndarray.py:88–101  ·  view source on GitHub ↗

Return a DGLArray representation of a numpy array.

(np_data)

Source from the content-addressed store, hash-verified

86
87
88def numpyasarray(np_data):
89 """Return a DGLArray representation of a numpy array."""
90 data = np_data
91 assert data.flags["C_CONTIGUOUS"]
92 arr = DGLArray()
93 shape = c_array(dgl_shape_index_t, data.shape)
94 arr.data = data.ctypes.data_as(ctypes.c_void_p)
95 arr.shape = shape
96 arr.strides = None
97 arr.dtype = DGLDataType(np.dtype(data.dtype).name)
98 arr.ndim = data.ndim
99 # CPU device
100 arr.ctx = context(1, 0)
101 return arr, shape
102
103
104def empty(shape, dtype="float32", ctx=context(1, 0)):

Callers 1

zerocopy_from_numpyFunction · 0.85

Calls 5

DGLArrayClass · 0.85
c_arrayFunction · 0.85
DGLDataTypeClass · 0.85
contextFunction · 0.70
dtypeMethod · 0.45

Tested by

no test coverage detected