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 = None,
_mmap=None,
**options,
)
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). |
default_device
|
The default device to use if no device info is provided in the batch spec.
TYPE:
|
_mmap
|
Internal memory map for efficient device transfers. Created automatically on the first call. Probably don't set this manually.
TYPE:
|
**options
|
Additional options to pass to downstream container linops. threaded : bool Whether to run the sub-linops in parallel threads or not. num_workers : int Number of concurrent workers to allow. accumulate : bool Whether to accumulate batches of outputs. Batch size determined by num_workers (threaded=True) or automatically 1 (threaded=False)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NamedLinop
|
A composite linop (tree of |
Source code in src/torchlinops/linops/split.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
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