openfold.utils.chunk_utils¶
Classes
|
Functions
|
Implements the "chunking" procedure described in section 1.11.8. |
- class ChunkSizeTuner(max_chunk_size=512)¶
- chunk_layer(layer, inputs, chunk_size, no_batch_dims, low_mem=False, _out=None, _add_into_out=False)¶
Implements the “chunking” procedure described in section 1.11.8.
Layer outputs and inputs are assumed to be simple “pytrees,” consisting only of (arbitrarily nested) lists, tuples, and dicts with torch.Tensor leaves.
- Parameters:
layer (Callable) – The layer to be applied chunk-wise
inputs (Dict[str, Any]) – A (non-nested) dictionary of keyworded inputs. All leaves must be tensors and must share the same batch dimensions.
chunk_size (int) – The number of sub-batches per chunk. If multiple batch dimensions are specified, a “sub-batch” is defined as a single indexing of all batch dimensions simultaneously (s.t. the number of sub-batches is the product of the batch dimensions).
no_batch_dims (int) – How many of the initial dimensions of each input tensor can be considered batch dimensions.
low_mem (bool) – Avoids flattening potentially large input tensors. Unnecessary in most cases, and is ever so slightly slower than the default setting.
_out (Any | None)
_add_into_out (bool)
- Returns:
The reassembled output of the layer on the inputs.
- Return type: