Splitting
torchlinops.linops.split_linop
Split a linop into an nd-array of sub-linops according to batch sizes.
| PARAMETER | DESCRIPTION |
|---|---|
linop
|
The linop to be split.
TYPE:
|
batch_sizes
|
Dictionary mapping dimension names to chunk sizes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
linops
|
Array of sub-linops with shape determined by the number of tiles per dimension.
TYPE:
|
input_batches
|
Corresponding input slices for each tile.
TYPE:
|
output_batches
|
Corresponding output slices for each tile.
TYPE:
|
Source code in src/torchlinops/linops/split.py
torchlinops.linops.create_batched_linop
create_batched_linop(
linop,
batch_specs: BatchSpec | list[BatchSpec],
default_device: device = None,
_mmap=None,
)
Split and distribute a linop across devices according to batch specs.
Recursively processes a list of BatchSpec objects: the first spec
splits the linop into tiles, optionally places each tile on a target
device, then passes remaining specs to each tile recursively. Tiles are
reassembled via Concat (for partitioned dimensions) or Add (for
reduced dimensions).
| PARAMETER | DESCRIPTION |
|---|---|
linop
|
The operator to split and distribute.
TYPE:
|
batch_specs
|
One or more batch specifications to apply (processed in order). |
_mmap
|
Internal memory map for efficient device transfers. Created automatically on the first call. Probably don't set this manually.
TYPE:
|
_default_device
|
The default device to use if no device info is provided in the batch spec.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NamedLinop
|
A composite linop (tree of |
Source code in src/torchlinops/linops/split.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
torchlinops.linops.BatchSpec
dataclass
Specification for splitting and distributing a linop across devices.
| PARAMETER | DESCRIPTION |
|---|---|
batch_sizes
|
Mapping from dimension names to chunk sizes for tiling.
TYPE:
|
device_matrix
|
Array of
TYPE:
|
base_device
|
The device where input/output data resides. Default is CPU.
TYPE:
|
Source code in src/torchlinops/linops/split.py
__init__
__init__(
batch_sizes: dict[NamedDimension | str, int],
device_matrix: ndarray | None = None,
base_device: device | None = None,
) -> None