FeatureStore
¶
Bases: ABC
Abstract key-value store of arrays, following PyG's FeatureStore.
Subclasses implement _put_tensor(), _get_tensor(),
_remove_tensor(), _get_tensor_size() and
get_all_tensor_attrs(). Arrays are passed and returned as
mx.array (np.ndarray is also accepted when putting).
Attributes can be given as a TensorAttr, as positional
arguments (group_name, attr_name, index) or as keywords, and the
store can be indexed like a dict:
store.put_tensor(x, attr_name="x")
store["x"] = x # same, homogeneous graphs (group_name=None)
rows = store.get_tensor(attr_name="x", index=mx.array([0, 5]))
Methods:
| Name | Description |
|---|---|
get_all_tensor_attrs |
The attributes (without index) of all the stored arrays. |
put_tensor |
Adds an array (or overwrites rows of an existing one when an |
get_tensor |
Returns the rows |
multi_get_tensor |
|
remove_tensor |
Removes an array. Returns whether it existed. |
update_tensor |
Replaces an existing array (or its rows |
get_tensor_size |
Shape of the full array, |
get_all_tensor_attrs
abstractmethod
¶
get_all_tensor_attrs() -> list[TensorAttr]
put_tensor
¶
Adds an array (or overwrites rows of an existing one when an
index is given). Returns whether it succeeded.
Source code in mlx_graphs/data/feature_store.py
get_tensor
¶
Returns the rows index (all rows if None) of an array.
Raises:
| Type | Description |
|---|---|
KeyError
|
If the array does not exist. |
Source code in mlx_graphs/data/feature_store.py
multi_get_tensor
¶
multi_get_tensor(attrs: list[TensorAttr]) -> list[array]
update_tensor
¶
Replaces an existing array (or its rows index).
Source code in mlx_graphs/data/feature_store.py
get_tensor_size
¶
Shape of the full array, None if it does not exist.
from mlx_graphs.data import FeatureStore · mlx_graphs/data/feature_store.py