vortex_torch.abs.context_base

Classes

ContextBase()

Abstract base class for runtime contexts.

class vortex_torch.abs.context_base.ContextBase[source]

Bases: ABC

Abstract 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 via create().

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.

name: str

Human-readable context name.

mode: Literal['profile', 'execute']

Current operating mode.

property created: bool
abstractmethod create(*args, **kwargs)[source]

Populate the context (idempotency/overwrite rules are up to the subclass).

Parameters:
Return type:

ContextBase

profile()[source]
Return type:

None

execute()[source]
Return type:

None

assert_created()[source]
Return type:

None

missing()[source]
Return type:

list[str]

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 a torch.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:

int

Raises:
  • TypeError – If obj is neither an int nor a torch.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.

add_aux_flops(nflops)[source]
Parameters:

nflops (int)

Return type:

int

clear_aux_memory()[source]

Reset the total auxiliary memory to zero.

Return type:

None

clear_aux_flops()[source]
Return type:

None

summary()[source]

Print fields; tensor fields show shape/dtype/device, and append memory totals incl. auxiliary.

Return type:

None