array_split.split.calculate_tile_shape_for_max_bytes¶
-
array_split.split.calculate_tile_shape_for_max_bytes(array_shape, array_itemsize, max_tile_bytes, max_tile_shape=None, sub_tile_shape=None, halo=None)[source]¶ Returns a tile shape
tile_shapesuch thatnumpy.product(tile_shape)*numpy.sum(array_itemsize) <= max_tile_bytes. Also, ifmax_tile_shape is not Nonethennumpy.all(tile_shape <= max_tile_shape) is Trueand ifsub_tile_shape is not Nonethenumpy.all((tile_shape % sub_tile_shape) == 0) is True.Parameters: - array_shape (sequence of
int) – Shape of the array which is to be split into tiles. - array_itemsize (
int) – The number of bytes per element of the array to be tiled. - max_tile_bytes (
int) – The maximum number of bytes for the returnedtile_shape. - max_tile_shape (sequence of
int) – Per axis maximum shapes for the returnedtile_shape. - sub_tile_shape (sequence of
int) – The returnedtile_shapewill be an even multiple of this sub-tile shape. - halo (
int, sequence ofint, or(len(array_shape), 2)shapednumpy.ndarray) – How tiles are extended in each axis direction with halo elements. See The halo parameter for meaning ofhalovalues.
Return type: Returns: A 1D array of shape
(len(array_shape),)indicating a tile shape which will (approximately) uniformly divide the givenarray_shapeinto tiles (sub-arrays).Examples:
>>> from array_split.split import calculate_tile_shape_for_max_bytes >>> calculate_tile_shape_for_max_bytes( ... array_shape=[512,], ... array_itemsize=1, ... max_tile_bytes=512 ... ) array([512]) >>> calculate_tile_shape_for_max_bytes( ... array_shape=[512,], ... array_itemsize=2, # Doubling the itemsize halves the tile size. ... max_tile_bytes=512 ... ) array([256]) >>> calculate_tile_shape_for_max_bytes( ... array_shape=[512,], ... array_itemsize=1, ... max_tile_bytes=512-1 # tile shape will now be halved ... ) array([256])
- array_shape (sequence of