For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo trait
DeviceGraphInput
A device graph input that contributes to the graph's cache key.
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
Movable
Required methods
__init__
def __init__(out self, *, copy: Self)
Create a new instance of the value by copying an existing one.
Args:
- copy (
_Self): The value to copy.
Returns:
_Self
def __init__(out self, *, deinit move: Self)
Create a new instance of the value by moving the value of another.
Args:
- move (
_Self): The value to move.
Returns:
_Self
write_graph_key
def write_graph_key(self, mut writer: T)
Writes this input's contribution to a graph's cache key.
Write whatever distinguishes graphs that must not be shared: two inputs
that write the same bytes are treated as interchangeable. Contributions
are separated from each other by
DeviceGraphCache.make_key(),
so there is no need to delimit or tag the output for that purpose.
Args:
- writer (
T): The writer accumulating the cache key.
allocate_stable
def allocate_stable(self, mut builder: DeviceGraphBuilder) -> Self
Returns a graph-owned value of this type for the graph to record.
Allocate through
DeviceGraphBuilder.create_input_buffer(),
which reserves the address for the graph's lifetime and registers it, and
describe the result with the same shape and dtype as self.
Read only self's shape. The result must not retain self's
storage: doing so pins the caller's memory for as long as the graph
lives, which is exactly the coupling a stable location exists to remove.
A mutable input the graph writes in place (a KV cache, for example)
must instead call
DeviceGraphBuilder.register_in_place_input()
and return a value aliasing self: a private stable copy would
silently discard the graph's writes. Such an implementation must
include the input's address in write_graph_key, so a moved buffer
misses the cache and forces a rebuild instead of replaying stale
addresses.
Args:
- builder (
DeviceGraphBuilder): The builder for the graph under construction.
Returns:
_Self: A value of the same type backed by the graph's memory pool, or —
for a mutable in-place input — a value aliasing self.
Raises:
If allocating from the graph's memory pool fails.
Provided methods
copy
def copy(self) -> Self
Explicitly construct a copy of self, a convenience method for Self(copy=self) when the type is inconvenient to write out.
Overriding this method is not allowed.
Returns:
_Self: A copy of this value.