vortex_torch.abs.context_base¶
Classes
Abstract base class for runtime contexts. |
- class vortex_torch.abs.context_base.ContextBase[source]¶
Bases:
ABCAbstract base class for runtime contexts.
This class defines the minimal contract that all context implementations must follow. It exposes two primary public attributes:
mode(str): The current operating mode, e.g."profile"or"execute"._created(bool): Whether the context has been populated viacreate().
Subclasses are responsible for implementing the lifecycle behavior and may carry additional internal state as needed, but the public surface should stay minimal and consistent.
- abstractmethod create(*args, **kwargs)[source]¶
Populate the context (idempotency/overwrite rules are up to the subclass).
- Parameters:
- Return type:
- add_aux_memory(obj)[source]¶
Accumulate auxiliary memory usage and return the number of bytes added.
- Parameters:
obj (int | torch.Tensor) – If an
int, it is treated as a number of bytes to add. If atorch.Tensor, its size in bytes is computed via_tensor_nbytes()and added.- Returns:
The number of bytes that were added to the auxiliary total.
- Return type:
- Raises:
TypeError – If
objis neither anintnor atorch.Tensor.ValueError – If the computed number of bytes is negative.
Notes
This is a simple accumulator. Calling it multiple times on tensors that share storage (or on the same tensor) will double-count.