qimpy.io.CheckpointPath
- class CheckpointPath(checkpoint=None, path='')
Bases:
NamedTuple
Combination of optional checkpoint and path within it. Useful as construction parameter for objects, to load data from checkpoint when available.
- Parameters
checkpoint (Optional[Checkpoint]) –
path (str) –
- __init__()
Methods
count
Return number of occurrences of value.
index
Return first index of value.
Member name at path within checkpoint, if present.
Read entire dataset from name, reporting to log if report.
Handle optional dataset with read, returning None if not found.
Create CpPath with path relative to current one.
Write data available on all processes to name within current path.
Attributes
Access attributes at path within checkpoint.
Checkpoint, if available.
Path within checkpoint
- member(name)
Member name at path within checkpoint, if present. Otherwise, return an empty CpPath.
- Parameters
name (str) –
- Return type
- read(name, report=True)
Read entire dataset from name, reporting to log if report.
- Parameters
name (str) –
report (bool) –
- Return type
Tensor
- read_optional(name, report=True)
Handle optional dataset with read, returning None if not found.
- Parameters
name (str) –
report (bool) –
- Return type
Optional[Tensor]
- relative(relative_path)
Create CpPath with path relative to current one. Specifically, relative_path is the path of the result relative to self.path.
- Parameters
relative_path (str) –
- Return type
- write(name, data)
Write data available on all processes to name within current path. This is convenient for small tensors that are not split over MPI. For complex data, pass a real view that has a final dimension of length 2. Returns name, which is convenient for accumulating the names of written datasets during reporting.
- Parameters
name (str) –
data (Tensor) –
- Return type
str
- property attrs
Access attributes at path within checkpoint.
- checkpoint: Optional[Checkpoint]
Checkpoint, if available.
- path: str
Path within checkpoint