Lightweight NDArray class for DGL framework.
| 29 | |
| 30 | |
| 31 | class NDArray(NDArrayBase): |
| 32 | """Lightweight NDArray class for DGL framework.""" |
| 33 | |
| 34 | def __len__(self): |
| 35 | return functools.reduce(operator.mul, self.shape, 1) |
| 36 | |
| 37 | def shared_memory(self, name): |
| 38 | """Return a copy of the ndarray in shared memory |
| 39 | |
| 40 | Parameters |
| 41 | ---------- |
| 42 | name : str |
| 43 | The name of the shared memory |
| 44 | |
| 45 | Returns |
| 46 | ------- |
| 47 | NDArray |
| 48 | """ |
| 49 | return empty_shared_mem(name, True, self.shape, self.dtype).copyfrom( |
| 50 | self |
| 51 | ) |
| 52 | |
| 53 | |
| 54 | def cpu(dev_id=0): |
no outgoing calls
no test coverage detected