:py:mod:`wolfgpu.tile_packer` ============================= .. py:module:: wolfgpu.tile_packer .. autoapi-nested-parse:: Author: HECE - University of Liege, Stéphane Champailler, Pierre Archambeau Date: 2024 Copyright (c) 2024 University of Liege. All rights reserved. This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited. Module Contents --------------- .. py:class:: TilePackingMode Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfgpu.tile_packer.TilePackingMode :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: REGULAR :value: 1 .. py:attribute:: TRANSPARENT :value: 3 .. py:function:: _unpack_and_deshuffle_array(a: numpy.ndarray, shape: tuple, height: int, width: int, active_tiles: numpy.ndarray, tile_size: int, tile_indirection_map: numpy.ndarray) -> numpy.ndarray .. py:class:: TilePacker(nap: numpy.array, tile_size: int, mode: TilePackingMode = TilePackingMode.REGULAR) .. py:method:: tile_reversed_indirection_map() .. py:method:: tile_indirection_map() The tile indirection map. Its shape is (nb_tiles_y,nb_tiles_x,2). The z-axis contains the indirected coordinates of the bottom-left corner of the tile denoted by the x and y axis values. For example, if you have the tile coordinates (t_i, t_j), then map[t_i, t_j, :] is a 2-tuple containing the coordinates (in meshes) of the bottom-left corner of that tile, on the indirected map. .. py:method:: mode() -> TilePackingMode .. py:method:: packed_size() Size of the arrays after padding them and packing them in tiles, expressed in meshes. Size is a (width, height) tuple. Note that this size can be very different than the actual computation domain size. .. py:method:: packed_size_in_tiles() Size of the arrays after padding them and packing them in tiles, expressed in tiles. Size is a (width, height) tuple. Note that this size can be very different than the actual computation domain size. .. py:method:: size_in_tiles() Size of the (original, non packed, non tiled) computation domain, in tiles. Not that we count full tiles. So if one dimension of the domain is not a multiple of the tile size, then we round one tile up. Size is a (width, height) tuple. .. py:method:: tile_size() -> int The tile size. Note that tiles are squared. .. py:method:: active_tiles_ndx() .. py:method:: unpack_and_deshuffle_array(a: numpy.ndarray) -> numpy.ndarray De-shuffle and un-pad an array of tiles that was shuffled and padded. .. py:method:: _unpad_array(a: numpy.array) -> numpy.array Undo `_pad_array_to_tiles`. .. py:method:: _pad_array_to_tiles(a: numpy.array, neutral_values) -> numpy.array Make an array fit in a given number of tiles (on x and y axis). After this, the array's dimensions are multiple of the tile_size. :param neutral_values: The value used to pad. .. py:method:: shuffle_and_pack_array(a: numpy.array, neutral_values=None, debug=False) -> numpy.array Reorganize an array by moving tiles around to follow the ordering given by `self._tile_indirection_map` The array is resized in order to be just as large as needed to hold the active tiles plus the "empty" tile. `neutral_values`: value to fill the empty tile with.