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

Function numpy_save_aligned

python/dgl/graphbolt/internal/utils.py:15–27  ·  view source on GitHub ↗

A wrapper for numpy.save(), ensures the array is stored 4KiB aligned.

(*args, **kwargs)

Source from the content-addressed store, hash-verified

13
14
15def numpy_save_aligned(*args, **kwargs):
16 """A wrapper for numpy.save(), ensures the array is stored 4KiB aligned."""
17 # https://github.com/numpy/numpy/blob/2093a6d5b933f812d15a3de0eafeeb23c61f948a/numpy/lib/format.py#L179
18 has_array_align = hasattr(np.lib.format, "ARRAY_ALIGN")
19 if has_array_align:
20 default_alignment = np.lib.format.ARRAY_ALIGN
21 # The maximum allowed alignment by the numpy code linked above is 4K.
22 # Most filesystems work with block sizes of 4K so in practice, the file
23 # size on the disk won't be larger.
24 np.lib.format.ARRAY_ALIGN = 4096
25 np.save(*args, **kwargs)
26 if has_array_align:
27 np.lib.format.ARRAY_ALIGN = default_alignment
28
29
30def _read_torch_data(path):

Callers 1

save_dataFunction · 0.85

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected