- Non-blocking transfer:
- Blocking transfer:
load(path, dtype, broadcastable, mmap_mode=None)¶
Load an array from an .npy file.
- path – A Generic symbolic variable, that will contain a string
- dtype (data-type) – The data type of the array to be read.
- broadcastable – The broadcastable pattern of the loaded array, for instance, (False,) for a vector, (False, True) for a column, (False, False) for a matrix.
- mmap_mode – How the file will be loaded. None means that the data will be copied into an array in memory, ‘c’ means that the file will be mapped into virtual memory, so only the parts that are needed will be actually read from disk and put into memory. Other modes supported by numpy.load (‘r’, ‘r+’, ‘w+’) cannot be supported by Aesara.
>>> from aesara import * >>> path = Variable(Generic()) >>> x = tensor.load(path, 'int64', (False,)) >>> y = x*2 >>> fn = function([path], y) >>> fn("stored-array.npy") array([0, 2, 4, 6, 8], dtype=int64)