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: Optional[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
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 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
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